|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.5 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops <[email protected]> |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: 1.91 fieldelements.php 11297 2014-03-24 09:11:10Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
25
|
|
|
|
|
26
|
|
|
/* |
|
27
|
|
|
* @Class TDMCreateFieldElements |
|
28
|
|
|
* @extends XoopsObject |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Class TDMCreateFieldElements. |
|
33
|
|
|
*/ |
|
34
|
|
|
class TDMCreateFieldElements extends XoopsObject |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
/* |
|
37
|
|
|
* @public function constructor class |
|
38
|
|
|
* @param null |
|
39
|
|
|
*/ |
|
40
|
|
|
/** |
|
41
|
|
|
* |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->initVar('fieldelement_id', XOBJ_DTYPE_INT); |
|
46
|
|
|
$this->initVar('fieldelement_mid', XOBJ_DTYPE_INT); |
|
47
|
|
|
$this->initVar('fieldelement_tid', XOBJ_DTYPE_INT); |
|
48
|
|
|
$this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX); |
|
49
|
|
|
$this->initVar('fieldelement_value', XOBJ_DTYPE_TXTBOX); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param string $method |
|
54
|
|
|
* @param array $args |
|
55
|
|
|
* |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __call($method, $args) |
|
59
|
|
|
{ |
|
60
|
|
|
$arg = isset($args[0]) ? $args[0] : null; |
|
61
|
|
|
|
|
62
|
|
|
return $this->getVar($method, $arg); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/* |
|
66
|
|
|
* @static function &getInstance |
|
67
|
|
|
* @param null |
|
68
|
|
|
*/ |
|
69
|
|
|
/** |
|
70
|
|
|
* @return TDMCreateFieldElements |
|
71
|
|
|
*/ |
|
72
|
|
|
public static function &getInstance() |
|
73
|
|
|
{ |
|
74
|
|
|
static $instance = false; |
|
75
|
|
|
if (!$instance) { |
|
76
|
|
|
$instance = new self(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $instance; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get Values. |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getValuesFieldElements($keys = null, $format = null, $maxDepth = null) |
|
86
|
|
|
{ |
|
87
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
|
88
|
|
|
// Values |
|
89
|
|
|
$ret['id'] = $this->getVar('fieldelement_id'); |
|
90
|
|
|
$ret['mid'] = $this->getVar('fieldelement_mid'); |
|
91
|
|
|
$ret['tid'] = $this->getVar('fieldelement_tid'); |
|
92
|
|
|
$ret['name'] = $this->getVar('fieldelement_name'); |
|
93
|
|
|
$ret['value'] = $this->getVar('fieldelement_value'); |
|
94
|
|
|
|
|
95
|
|
|
return $ret; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/* |
|
100
|
|
|
* @Class TDMCreateFieldElementsHandler |
|
101
|
|
|
* @extends XoopsPersistableObjectHandler |
|
102
|
|
|
*/ |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Class TDMCreateFieldElementsHandler. |
|
106
|
|
|
*/ |
|
107
|
|
|
class TDMCreateFieldElementsHandler extends XoopsPersistableObjectHandler |
|
|
|
|
|
|
108
|
|
|
{ |
|
109
|
|
|
/* |
|
110
|
|
|
* @public function constructor class |
|
111
|
|
|
* @param mixed $db |
|
112
|
|
|
*/ |
|
113
|
|
|
/** |
|
114
|
|
|
* @param null|object $db |
|
115
|
|
|
*/ |
|
116
|
|
|
public function __construct(&$db) |
|
117
|
|
|
{ |
|
118
|
|
|
parent::__construct($db, 'tdmcreate_fieldelements', 'tdmcreatefieldelements', 'fieldelement_id', 'fieldelement_name'); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Get Count Fields. |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getCountFieldElements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') |
|
125
|
|
|
{ |
|
126
|
|
|
$criteriaCountFieldElements = new CriteriaCompo(); |
|
127
|
|
|
$criteriaCountFieldElements = $this->getFieldElementsCriteria($criteriaCountFieldElements, $start, $limit, $sort, $order); |
|
128
|
|
|
|
|
129
|
|
|
return parent::getCount($criteriaCountFieldElements); |
|
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Get Objects Fields. |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getObjectsFieldElements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') |
|
136
|
|
|
{ |
|
137
|
|
|
$criteriaObjectsFieldElements = new CriteriaCompo(); |
|
138
|
|
|
$criteriaObjectsFieldElements = $this->getFieldElementsCriteria($criteriaObjectsFieldElements, $start, $limit, $sort, $order); |
|
139
|
|
|
|
|
140
|
|
|
return $this->getObjects($criteriaObjectsFieldElements); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Get All Fields. |
|
145
|
|
|
*/ |
|
146
|
|
|
public function getAllFieldElements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') |
|
147
|
|
|
{ |
|
148
|
|
|
$criteriaAllFieldElements = new CriteriaCompo(); |
|
149
|
|
|
$criteriaAllFieldElements = $this->getFieldElementsCriteria($criteriaAllFieldElements, $start, $limit, $sort, $order); |
|
150
|
|
|
|
|
151
|
|
|
return $this->getAll($criteriaAllFieldElements); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Get All Fields By Module & Table Id. |
|
156
|
|
|
*/ |
|
157
|
|
View Code Duplication |
public function getAllFieldElementsByModuleAndTableId($modId, $tabId, $start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') |
|
|
|
|
|
|
158
|
|
|
{ |
|
159
|
|
|
$criteriaAllFieldElementsByModule = new CriteriaCompo(); |
|
160
|
|
|
$criteriaAllFieldElementsByModule->add(new Criteria('fieldelement_mid', $modId)); |
|
161
|
|
|
$criteriaAllFieldElementsByModule->add(new Criteria('fieldelement_tid', $tabId)); |
|
162
|
|
|
$criteriaAllFieldElementsByModule = $this->getFieldElementsCriteria($criteriaAllFieldElementsByModule, $start, $limit, $sort, $order); |
|
163
|
|
|
|
|
164
|
|
|
return $this->getAll($criteriaAllFieldElementsByModule); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Get FieldElements Criteria. |
|
169
|
|
|
*/ |
|
170
|
|
|
private function getFieldElementsCriteria($criteriaFieldElements, $start, $limit, $sort, $order) |
|
171
|
|
|
{ |
|
172
|
|
|
$criteriaFieldElements->setStart($start); |
|
173
|
|
|
$criteriaFieldElements->setLimit($limit); |
|
174
|
|
|
$criteriaFieldElements->setSort($sort); |
|
175
|
|
|
$criteriaFieldElements->setOrder($order); |
|
176
|
|
|
|
|
177
|
|
|
return $criteriaFieldElements; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
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.