1
|
|
|
<?php |
|
|
|
|
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2016 XOOPS.org // |
6
|
|
|
// <http://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
|
|
|
// This program is distributed in the hope that it will be useful, // |
18
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
19
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
20
|
|
|
// GNU General Public License for more details. // |
21
|
|
|
|
22
|
|
|
// You should have received a copy of the GNU General Public License // |
23
|
|
|
// along with this program; if not, write to the Free Software // |
24
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
25
|
|
|
// ------------------------------------------------------------------------ // |
26
|
|
|
// URL: http://xoops.org/ // |
27
|
|
|
// Project: XOOPS Project // |
28
|
|
|
// -------------------------------------------------------------------------// |
29
|
|
|
|
30
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
|
|
|
31
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
32
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecthandler.php'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class SmartpartnerPartnerCatLink |
36
|
|
|
*/ |
37
|
|
View Code Duplication |
class SmartpartnerPartner_cat_link extends SmartObject |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* SmartpartnerPartnerCatLink constructor. |
41
|
|
|
*/ |
42
|
|
|
public function __construct() |
43
|
|
|
{ |
44
|
|
|
$this->initVar('partner_cat_linkid', XOBJ_DTYPE_INT, '', true); |
45
|
|
|
$this->initVar('partnerid', XOBJ_DTYPE_INT, '', true); |
46
|
|
|
$this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Class SmartpartnerPartnerCatLinkHandler |
52
|
|
|
*/ |
53
|
|
View Code Duplication |
class SmartpartnerPartner_cat_linkHandler extends SmartPersistableObjectHandler |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
/** |
56
|
|
|
* SmartpartnerPartnerCatLinkHandler constructor. |
57
|
|
|
* @param object|XoopsDatabase $db |
58
|
|
|
*/ |
59
|
|
|
public function __construct(XoopsDatabase $db) |
60
|
|
|
{ |
61
|
|
|
parent::__construct($db, 'partner_cat_link', array('partnerid', 'categoryid'), '', false, 'smartpartner'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param $partnerid |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getParentIds($partnerid) |
69
|
|
|
{ |
70
|
|
|
$criteria = new CriteriaCompo(); |
71
|
|
|
$criteria->add(new Criteria('partnerid', $partnerid)); |
72
|
|
|
$links = $this->getObjects($criteria); |
73
|
|
|
$parent_array = array(); |
74
|
|
|
foreach ($links as $link) { |
75
|
|
|
$parent_array[] = $link->getVar('categoryid'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return implode('|', $parent_array); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
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.