|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Zakladni objekt urceny k rodicovstvi pokročilým objektum. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Vitex <[email protected]> |
|
6
|
|
|
* @copyright 2009-2019 [email protected] (G) |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Ease; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Zakladni objekt urceny k rodicovstvi vsem pouzivanym objektum. |
|
13
|
|
|
* |
|
14
|
|
|
* @author Vitex <[email protected]> |
|
15
|
|
|
* @copyright 2009-2012 [email protected] (G) |
|
16
|
|
|
*/ |
|
17
|
|
|
class Sand extends Molecule |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Default Language Code. |
|
21
|
|
|
* |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
public $langCode = null; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Common object data holder. |
|
28
|
|
|
* |
|
29
|
|
|
* @var array |
|
30
|
|
|
*/ |
|
31
|
|
|
public $data = null; |
|
32
|
|
|
|
|
33
|
|
|
// /** |
|
34
|
|
|
// * Obsahuje všechna pole souhrně považovaná za identitu. Toto pole je plněno |
|
35
|
|
|
// * v metodě SaveObjectIdentity {volá se automaticky v EaseSand::__construct()}. |
|
36
|
|
|
// * |
|
37
|
|
|
// * @var array |
|
38
|
|
|
// */ |
|
39
|
|
|
// public $identity = []; |
|
40
|
|
|
// |
|
41
|
|
|
// /** |
|
42
|
|
|
// * Původní identita sloužící jako záloha k zrekonstruování počátečního stavu objektu. |
|
43
|
|
|
// * |
|
44
|
|
|
// * @var array |
|
45
|
|
|
// */ |
|
46
|
|
|
// public $initialIdentity = []; |
|
47
|
|
|
// |
|
48
|
|
|
// /** |
|
49
|
|
|
// * Tyto sloupecky jsou uchovavany pri operacich s identitou objektu. |
|
50
|
|
|
// * |
|
51
|
|
|
// * @deprecated since version 2.0 |
|
52
|
|
|
// * |
|
53
|
|
|
// * @var array |
|
54
|
|
|
// */ |
|
55
|
|
|
// public $identityColumns = ['ObjectName', |
|
56
|
|
|
// 'keyColumn', |
|
57
|
|
|
// 'myTable', |
|
58
|
|
|
// 'MyIDSColumn', |
|
59
|
|
|
// 'MyRefIDColumn', |
|
60
|
|
|
// 'myCreateColumn', |
|
61
|
|
|
// 'myLastModifiedColumn',]; |
|
62
|
|
|
// /** |
|
63
|
|
|
// * Synchronizační sloupeček. napr products_ids. |
|
64
|
|
|
// * |
|
65
|
|
|
// * @var string |
|
66
|
|
|
// */ |
|
67
|
|
|
// public $myIDSColumn = null; |
|
68
|
|
|
// |
|
69
|
|
|
// /** |
|
70
|
|
|
// * Sloupeček obsahující datum vložení záznamu do shopu. |
|
71
|
|
|
// * |
|
72
|
|
|
// * @var string |
|
73
|
|
|
// */ |
|
74
|
|
|
// public $myCreateColumn = null; |
|
75
|
|
|
// |
|
76
|
|
|
// /** |
|
77
|
|
|
// * Slopecek obsahujici datum poslení modifikace záznamu do shopu. |
|
78
|
|
|
// * |
|
79
|
|
|
// * @var string |
|
80
|
|
|
// */ |
|
81
|
|
|
// public $myLastModifiedColumn = null; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Objekt pro logování. |
|
85
|
|
|
* |
|
86
|
|
|
* @var Logger\Regent |
|
87
|
|
|
*/ |
|
88
|
|
|
public $logger = null; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Odkaz na vlastnící objekt. |
|
92
|
|
|
* |
|
93
|
|
|
* @var Sand|mixed object |
|
94
|
|
|
*/ |
|
95
|
|
|
public $parentObject = null; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Sdílený objekt frameworku. |
|
99
|
|
|
* |
|
100
|
|
|
* @var Shared |
|
101
|
|
|
*/ |
|
102
|
|
|
public $easeShared = null; |
|
103
|
|
|
|
|
104
|
|
|
// /** |
|
105
|
|
|
// * Prapředek všech objektů. |
|
106
|
|
|
// */ |
|
107
|
|
|
// public function __construct() |
|
108
|
|
|
// { |
|
109
|
|
|
// parent::__construct(); |
|
110
|
|
|
// $this->initialIdentity = $this->saveObjectIdentity(); |
|
111
|
|
|
// } |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Přidá zprávu do sdíleného zásobníku p$this->getLogger()ro zobrazení uživateli. |
|
115
|
|
|
* |
|
116
|
|
|
* @param string $message Text zprávy |
|
117
|
|
|
* @param string $type Fronta zpráv (warning|info|error|success) |
|
118
|
|
|
* |
|
119
|
|
|
* @return |
|
120
|
|
|
*/ |
|
121
|
|
|
public function addStatusMessage($message, $type = 'info') |
|
122
|
|
|
{ |
|
123
|
|
|
return Shared::singleton()->takeMessage(new Logger\Message($message, |
|
|
|
|
|
|
124
|
|
|
$type, get_class($this))); |
|
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Předá zprávy. |
|
129
|
|
|
* |
|
130
|
|
|
* @return array |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getStatusMessages() |
|
133
|
|
|
{ |
|
134
|
|
|
return Shared::singleton()->getStatusMessages(); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Vymaže zprávy. |
|
139
|
|
|
*/ |
|
140
|
|
|
public function cleanMessages() |
|
141
|
|
|
{ |
|
142
|
|
|
return Shared::singleton()->cleanMessages(); |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
// /** |
|
145
|
|
|
// * Nastaví novou identitu objektu. |
|
146
|
|
|
// * |
|
147
|
|
|
// * @deprecated since version 0.1 |
|
148
|
|
|
// * |
|
149
|
|
|
// * @param array $newIdentity |
|
150
|
|
|
// */ |
|
151
|
|
|
// public function setObjectIdentity($newIdentity) |
|
152
|
|
|
// { |
|
153
|
|
|
// $changes = 0; |
|
154
|
|
|
// $this->saveObjectIdentity(); |
|
155
|
|
|
// foreach ($this->identityColumns as $column) { |
|
156
|
|
|
// if (isset($newIdentity[$column])) { |
|
157
|
|
|
// $this->$column = $newIdentity[$column]; |
|
158
|
|
|
// ++$changes; |
|
159
|
|
|
// } |
|
160
|
|
|
// } |
|
161
|
|
|
// |
|
162
|
|
|
// return $changes; |
|
163
|
|
|
// } |
|
164
|
|
|
// |
|
165
|
|
|
// /** |
|
166
|
|
|
// * Uloží identitu objektu do pole $this->identity. |
|
167
|
|
|
// * |
|
168
|
|
|
// * @deprecated since version 0.1 |
|
169
|
|
|
// * |
|
170
|
|
|
// * @return array pole s identitou |
|
171
|
|
|
// */ |
|
172
|
|
|
// public function saveObjectIdentity() |
|
173
|
|
|
// { |
|
174
|
|
|
// foreach ($this->identityColumns as $column) { |
|
175
|
|
|
// if (isset($this->$column)) { |
|
176
|
|
|
// $this->identity[$column] = $this->$column; |
|
177
|
|
|
// } |
|
178
|
|
|
// } |
|
179
|
|
|
// |
|
180
|
|
|
// return $this->identity; |
|
181
|
|
|
// } |
|
182
|
|
|
// |
|
183
|
|
|
// /** |
|
184
|
|
|
// * Obnoví uloženou identitu objektu. |
|
185
|
|
|
// * |
|
186
|
|
|
// * @deprecated since version 0.1 |
|
187
|
|
|
// * |
|
188
|
|
|
// * @param array $identity pole s identitou např. array('myTable'=>'user'); |
|
189
|
|
|
// */ |
|
190
|
|
|
// public function restoreObjectIdentity($identity = null) |
|
191
|
|
|
// { |
|
192
|
|
|
// if (is_null($identity)) { |
|
193
|
|
|
// foreach ($this->identityColumns as $column) { |
|
194
|
|
|
// if (isset($this->identity[$column])) { |
|
195
|
|
|
// $this->$column = $this->identity[$column]; |
|
196
|
|
|
// } |
|
197
|
|
|
// } |
|
198
|
|
|
// } else { |
|
199
|
|
|
// foreach ($identity as $column) { |
|
200
|
|
|
// if (isset($this->identity[$column])) { |
|
201
|
|
|
// $this->$column = $this->identity[$column]; |
|
202
|
|
|
// } |
|
203
|
|
|
// } |
|
204
|
|
|
// } |
|
205
|
|
|
// } |
|
206
|
|
|
// |
|
207
|
|
|
// /** |
|
208
|
|
|
// * Obnoví poslední použitou identitu. |
|
209
|
|
|
// * |
|
210
|
|
|
// * @deprecated since version 0.1 |
|
211
|
|
|
// */ |
|
212
|
|
|
// public function resetObjectIdentity() |
|
213
|
|
|
// { |
|
214
|
|
|
// $this->identity = $this->initialIdentity; |
|
215
|
|
|
// $this->restoreObjectIdentity(); |
|
216
|
|
|
// } |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Vynuluje všechny pole vlastností objektu. |
|
220
|
|
|
*/ |
|
221
|
|
|
public function dataReset() |
|
222
|
|
|
{ |
|
223
|
|
|
$this->data = []; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Načte $data do polí objektu. |
|
228
|
|
|
* |
|
229
|
|
|
* @param array $data asociativní pole dat |
|
230
|
|
|
* @param bool $reset vyprazdnit pole před naplněním ? |
|
231
|
|
|
* |
|
232
|
|
|
* @return int počet načtených položek |
|
233
|
|
|
*/ |
|
234
|
|
|
public function setData($data, $reset = false) |
|
235
|
|
|
{ |
|
236
|
|
|
$ret = null; |
|
237
|
|
|
if (!empty($data) && is_array($data) && count($data)) { |
|
238
|
|
|
if ($reset) { |
|
239
|
|
|
$this->dataReset(); |
|
240
|
|
|
} |
|
241
|
|
|
if (is_array($this->data)) { |
|
|
|
|
|
|
242
|
|
|
$this->data = array_merge($this->data, $data); |
|
243
|
|
|
} else { |
|
244
|
|
|
$this->data = $data; |
|
245
|
|
|
} |
|
246
|
|
|
$ret = count($data); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
return $ret; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Vrací celé pole dat objektu. |
|
254
|
|
|
* |
|
255
|
|
|
* @return array |
|
256
|
|
|
*/ |
|
257
|
|
|
public function getData() |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->data; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* Vrací počet položek dat objektu. |
|
264
|
|
|
* |
|
265
|
|
|
* @return int |
|
266
|
|
|
*/ |
|
267
|
|
|
public function getDataCount() |
|
268
|
|
|
{ |
|
269
|
|
|
return count($this->data); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Vrací hodnotu z pole dat pro MySQL. |
|
274
|
|
|
* |
|
275
|
|
|
* @param string $columnName název hodnoty/sloupečku |
|
276
|
|
|
* |
|
277
|
|
|
* @return mixed |
|
278
|
|
|
*/ |
|
279
|
|
|
public function getDataValue($columnName) |
|
280
|
|
|
{ |
|
281
|
|
|
if (isset($this->data[$columnName])) { |
|
282
|
|
|
return $this->data[$columnName]; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
return; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* Nastaví hodnotu poli objektu. |
|
290
|
|
|
* |
|
291
|
|
|
* @param string $columnName název datové kolonky |
|
292
|
|
|
* @param mixed $value hodnota dat |
|
293
|
|
|
* |
|
294
|
|
|
* @return bool Success |
|
295
|
|
|
*/ |
|
296
|
|
|
public function setDataValue($columnName, $value) |
|
297
|
|
|
{ |
|
298
|
|
|
$this->data[$columnName] = $value; |
|
299
|
|
|
|
|
300
|
|
|
return true; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* Odstrani polozku z pole dat pro MySQL. |
|
305
|
|
|
* |
|
306
|
|
|
* @param string $columnName název klíče k vymazání |
|
307
|
|
|
* |
|
308
|
|
|
* @return bool success |
|
309
|
|
|
*/ |
|
310
|
|
|
public function unsetDataValue($columnName) |
|
311
|
|
|
{ |
|
312
|
|
|
if (array_key_exists($columnName, $this->data)) { |
|
313
|
|
|
unset($this->data[$columnName]); |
|
314
|
|
|
|
|
315
|
|
|
return true; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
return false; |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Převezme data do aktuálního pole dat. |
|
323
|
|
|
* |
|
324
|
|
|
* @param array $data asociativní pole dat |
|
325
|
|
|
* |
|
326
|
|
|
* @return int |
|
327
|
|
|
*/ |
|
328
|
|
|
public function takeData($data) |
|
329
|
|
|
{ |
|
330
|
|
|
if (is_array($this->data) && is_array($data)) { |
|
|
|
|
|
|
331
|
|
|
$this->data = array_merge($this->data, $data); |
|
332
|
|
|
} else { |
|
333
|
|
|
$this->data = $data; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
return empty($data) ? null : count($data); |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
|
|
340
|
|
|
} |
|
341
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.