|
1
|
|
|
<?php |
|
|
|
|
|
|
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
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* oledrion |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright {@link http://xoops.org/ XOOPS Project} |
|
16
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
|
17
|
|
|
* @author Hossein Azizabadi ([email protected]) |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
require __DIR__ . '/classheader.php'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class Oledrion_location |
|
24
|
|
|
*/ |
|
25
|
|
View Code Duplication |
class Oledrion_location extends Oledrion_Object |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* constructor |
|
29
|
|
|
* |
|
30
|
|
|
* normally, this is called from child classes only |
|
31
|
|
|
* |
|
32
|
|
|
* @access public |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->initVar('location_id', XOBJ_DTYPE_INT, null, false); |
|
37
|
|
|
$this->initVar('location_pid', XOBJ_DTYPE_INT, null, false); |
|
38
|
|
|
$this->initVar('location_title', XOBJ_DTYPE_TXTBOX, null, false); |
|
39
|
|
|
$this->initVar('location_online', XOBJ_DTYPE_INT, null, false); |
|
40
|
|
|
$this->initVar('location_type', XOBJ_DTYPE_TXTBOX, null, false); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Retourne les éléments du produits formatés pour affichage |
|
45
|
|
|
* |
|
46
|
|
|
* @param string $format |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
|
public function toArray($format = 's') |
|
50
|
|
|
{ |
|
51
|
|
|
$ret = array(); |
|
|
|
|
|
|
52
|
|
|
$ret = parent::toArray($format); |
|
53
|
|
|
|
|
54
|
|
|
return $ret; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Class OledrionOledrion_locationHandler |
|
60
|
|
|
*/ |
|
61
|
|
|
class OledrionOledrion_locationHandler extends Oledrion_XoopsPersistableObjectHandler |
|
|
|
|
|
|
62
|
|
|
{ |
|
63
|
|
|
/** |
|
64
|
|
|
* OledrionOledrion_locationHandler constructor. |
|
65
|
|
|
* @param XoopsDatabase|null $db |
|
66
|
|
|
*/ |
|
67
|
|
|
public function __construct(XoopsDatabase $db) |
|
68
|
|
|
{ // Table Classe Id |
|
69
|
|
|
parent::__construct($db, 'oledrion_location', 'oledrion_location', 'location_id'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param Oledrion_parameters $parameters |
|
74
|
|
|
* @return array |
|
75
|
|
|
*/ |
|
76
|
|
View Code Duplication |
public function getAllLocation(Oledrion_parameters $parameters) |
|
|
|
|
|
|
77
|
|
|
{ |
|
78
|
|
|
$parameters = $parameters->extend(new Oledrion_parameters(array( |
|
|
|
|
|
|
79
|
|
|
'start' => 0, |
|
80
|
|
|
'limit' => 0, |
|
81
|
|
|
'sort' => 'location_id', |
|
82
|
|
|
'order' => 'ASC' |
|
83
|
|
|
))); |
|
84
|
|
|
$critere = new Criteria('location_id', 0, '<>'); |
|
85
|
|
|
$critere->setLimit($parameters['limit']); |
|
86
|
|
|
$critere->setStart($parameters['start']); |
|
87
|
|
|
$critere->setSort($parameters['sort']); |
|
88
|
|
|
$critere->setOrder($parameters['order']); |
|
89
|
|
|
$location = array(); |
|
|
|
|
|
|
90
|
|
|
$location = $this->getObjects($critere); |
|
91
|
|
|
|
|
92
|
|
|
return $location; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param Oledrion_parameters $parameters |
|
97
|
|
|
* @return array |
|
98
|
|
|
*/ |
|
99
|
|
View Code Duplication |
public function getAllPid(Oledrion_parameters $parameters) |
|
|
|
|
|
|
100
|
|
|
{ |
|
101
|
|
|
$parameters = $parameters->extend(new Oledrion_parameters(array( |
|
|
|
|
|
|
102
|
|
|
'start' => 0, |
|
103
|
|
|
'limit' => 0, |
|
104
|
|
|
'sort' => 'location_id', |
|
105
|
|
|
'order' => 'ASC' |
|
106
|
|
|
))); |
|
107
|
|
|
$critere = new CriteriaCompo(); |
|
108
|
|
|
$critere->add(new Criteria('location_type', 'parent')); |
|
109
|
|
|
$critere->setLimit($parameters['limit']); |
|
110
|
|
|
$critere->setStart($parameters['start']); |
|
111
|
|
|
$critere->setSort($parameters['sort']); |
|
112
|
|
|
$critere->setOrder($parameters['order']); |
|
113
|
|
|
$pid = array(); |
|
|
|
|
|
|
114
|
|
|
$pid = $this->getObjects($critere); |
|
115
|
|
|
|
|
116
|
|
|
return $pid; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param $id |
|
121
|
|
|
* @return array |
|
122
|
|
|
*/ |
|
123
|
|
View Code Duplication |
public function getLocation($id) |
|
|
|
|
|
|
124
|
|
|
{ |
|
125
|
|
|
$critere = new CriteriaCompo(); |
|
126
|
|
|
$critere->add(new Criteria('location_online', 1)); |
|
127
|
|
|
$critere->add(new Criteria('location_type', 'location')); |
|
128
|
|
|
$critere->add(new Criteria('location_pid', $id)); |
|
129
|
|
|
$location = array(); |
|
|
|
|
|
|
130
|
|
|
$location = $this->getObjects($critere); |
|
131
|
|
|
|
|
132
|
|
|
return $location; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @param $id |
|
137
|
|
|
* @return int |
|
138
|
|
|
*/ |
|
139
|
|
View Code Duplication |
public function haveChild($id) |
|
|
|
|
|
|
140
|
|
|
{ |
|
141
|
|
|
$critere = new CriteriaCompo(); |
|
142
|
|
|
$critere->add(new Criteria('location_online', 1)); |
|
143
|
|
|
$critere->add(new Criteria('location_type', 'location')); |
|
144
|
|
|
$critere->add(new Criteria('location_pid', $id)); |
|
145
|
|
|
$location = $this->getCount($critere); |
|
146
|
|
|
|
|
147
|
|
|
return $location; |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
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.