XoopsModules25x /
xoopspartners
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * This program is distributed in the hope that it will be useful, |
||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 9 | * |
||
| 10 | *------------------------------------ |
||
| 11 | * Author: Raul Recio (AKA UNFOR) |
||
| 12 | * Project: The XOOPS Project |
||
| 13 | *------------------------------------ |
||
| 14 | */ |
||
| 15 | /** |
||
| 16 | * XoopsPartners - a partner affiliation links module |
||
| 17 | * |
||
| 18 | * @package module\xoopspartners\class |
||
| 19 | * @author Raul Recio (aka UNFOR) |
||
| 20 | * @author XOOPS Module Development Team |
||
| 21 | * @copyright {@link https://xoops.org 2001-2016 XOOPS Project} |
||
| 22 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
| 23 | * @link https://xoops.org XOOPS |
||
| 24 | */ |
||
| 25 | |||
| 26 | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Class XoopspartnersPartners |
||
| 30 | * |
||
| 31 | * {@inheritDoc} |
||
| 32 | * @see XoopsObject |
||
| 33 | */ |
||
| 34 | class XoopspartnersPartners extends XoopsObject |
||
| 35 | { |
||
| 36 | protected $db; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * constructor |
||
| 40 | * |
||
| 41 | * @todo change 'url' to XOBJ_DTYPE_URL |
||
| 42 | * @param null $id |
||
| 43 | */ |
||
| 44 | public function __construct($id = null) |
||
| 45 | { |
||
| 46 | $this->db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 47 | |||
| 48 | $this->initVar('id', XOBJ_DTYPE_INT, null, false); |
||
| 49 | $this->initVar('weight', XOBJ_DTYPE_INT, null, false, 10); |
||
| 50 | $this->initVar('hits', XOBJ_DTYPE_INT, null, true, 10); |
||
| 51 | $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, true); |
||
| 52 | $this->initVar('image', XOBJ_DTYPE_TXTBOX, null, true); |
||
| 53 | $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 54 | $this->initVar('description', XOBJ_DTYPE_TXTBOX, null, true); |
||
| 55 | $this->initVar('status', XOBJ_DTYPE_INT, null, false, 0); |
||
| 56 | if (!empty($id)) { |
||
| 57 | if (is_array($id)) { |
||
| 58 | $this->assignVars($id); |
||
| 59 | } else { |
||
| 60 | $this->load((int)$id); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Returns category title |
||
| 67 | * |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | public function __toString() |
||
| 71 | { |
||
| 72 | return $this->getVar('title', 's'); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * |
||
| 78 | * {@inheritDoc} |
||
| 79 | * @see XoopsPersistableObjectHandler |
||
| 80 | * @copyright copyright © 2000 XOOPS.org |
||
| 81 | * |
||
| 82 | */ |
||
| 83 | class XoopspartnersPartnersHandler extends XoopsPersistableObjectHandler |
||
| 84 | { |
||
| 85 | /** |
||
| 86 | * XoopspartnersPartnersHandler constructor |
||
| 87 | * |
||
| 88 | * @param XoopsDatabase $db |
||
| 89 | */ |
||
| 90 | public function __construct(XoopsDatabase $db) |
||
| 91 | { |
||
| 92 | parent::__construct($db, 'partners', 'XoopspartnersPartners', 'id', 'title'); |
||
| 93 | } |
||
| 94 | } |
||
| 95 |
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.