| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | // $Id: partners.php,v 1.9.14.1 2005/08/15 15:04:59 skalpa Exp $ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | //  ------------------------------------------------------------------------ // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | //                XOOPS - PHP Content Management System                      // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | //                    Copyright (c) 2000 XOOPS.org                           // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | //                       <http://www.xoops.org/>                             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | //  ------------------------------------------------------------------------ // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | //  This program is free software; you can redistribute it and/or modify     // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | //  it under the terms of the GNU General Public License as published by     // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | //  the Free Software Foundation; either version 2 of the License, or        // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | //  (at your option) any later version.                                      // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | //                                                                           // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | //  You may not change or alter any portion of this comment or credits       // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | //  of supporting developers from this source code or any supporting         // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | //  source code which is considered copyrighted (c) material of the          // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | //  original comment or credit authors.                                      // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | //                                                                           // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | //  This program is distributed in the hope that it will be useful,          // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | //  but WITHOUT ANY WARRANTY; without even the implied warranty of           // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | //  GNU General Public License for more details.                             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | //                                                                           // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | //  You should have received a copy of the GNU General Public License        // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | //  along with this program; if not, write to the Free Software              // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | //  ------------------------------------------------------------------------ // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | // Author: Raul Recio (AKA UNFOR)                                            // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | // Project: The XOOPS Project                                                // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | // ------------------------------------------------------------------------- // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * XoopsPartners - a partner affiliation links module | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @category     Module | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @package      xoopspartners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @subpackage   class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @author       Raul Recio (aka UNFOR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * @author       XOOPS Module Development Team | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @copyright    {@link http://xoops.org 2001-2016 XOOPS Project} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @link         http://xoops.org XOOPS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  * Class XoopspartnersPartners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | class XoopspartnersPartners extends XoopsObject | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected $db; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @TODO change 'url' to XOBJ_DTYPE_URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @param null $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     public function __construct($id = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->db = XoopsDatabaseFactory::getDatabaseConnection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->initVar('id', XOBJ_DTYPE_INT, null, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->initVar('weight', XOBJ_DTYPE_INT, null, false, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->initVar('hits', XOBJ_DTYPE_INT, null, true, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->initVar('image', XOBJ_DTYPE_TXTBOX, null, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->initVar('description', XOBJ_DTYPE_TXTBOX, null, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->initVar('status', XOBJ_DTYPE_INT, null, false, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         if (!empty($id)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             if (is_array($id)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 $this->assignVars($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 $this->load((int)$id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * Returns category title using PHP5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function __toString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $this->getVar('title', 's'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  * @copyright copyright © 2000 XOOPS.org | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  | class XoopspartnersPartnersHandler extends XoopsPersistableObjectHandler | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      * XoopspartnersPartnersHandler constructor. | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |      * @param XoopsDatabase $db | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     public function __construct(XoopsDatabase $db) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         parent::__construct($db, 'partners', 'XoopspartnersPartners', 'id'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 102 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 103 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.