@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | $from = $this->table . " " . $this->_filters['join']; |
216 | 216 | $where = $this->getCFGDef('addWhereList', ''); |
217 | 217 | |
218 | - //====== block added by Dreamer to enable filters ====== |
|
218 | + //====== block added by Dreamer to enable filters ====== |
|
219 | 219 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
220 | 220 | $where = sqlHelper::trimLogicalOp($where); |
221 | - //------- end of block ------- |
|
221 | + //------- end of block ------- |
|
222 | 222 | |
223 | 223 | |
224 | 224 | if ($where != '') { |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
258 | 258 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
259 | 259 | |
260 | - //====== block added by Dreamer to enable filters ====== |
|
260 | + //====== block added by Dreamer to enable filters ====== |
|
261 | 261 | $tmpWhere = ($tmpWhere ? $tmpWhere . ' AND ' : '') . $this->_filters['where']; |
262 | 262 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
263 | - //------- end of block ------- |
|
263 | + //------- end of block ------- |
|
264 | 264 | |
265 | 265 | |
266 | 266 | if (!empty($tmpWhere)) { |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | $from = $this->table . " " . $this->_filters['join']; |
330 | 330 | $where = $this->getCFGDef('addWhereList', ''); |
331 | 331 | |
332 | - //====== block added by Dreamer ====== |
|
332 | + //====== block added by Dreamer ====== |
|
333 | 333 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
334 | 334 | $where = sqlHelper::trimLogicalOp($where); |
335 | - //------- end of block ------- |
|
335 | + //------- end of block ------- |
|
336 | 336 | |
337 | 337 | if ($where != '') { |
338 | 338 | $where = array($where); |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @param contentField =`description` //content |
11 | 11 | * @param table =`` //table name |
12 | 12 | */ |
13 | -class onetableDocLister extends DocLister |
|
14 | -{ |
|
13 | +class onetableDocLister extends DocLister |
|
14 | +{ |
|
15 | 15 | /** |
16 | 16 | * @var string |
17 | 17 | */ |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @absctract |
31 | 31 | */ |
32 | - public function getDocs($tvlist = '') |
|
33 | - { |
|
34 | - if ($this->checkExtender('paginate')) { |
|
32 | + public function getDocs($tvlist = '') |
|
33 | + { |
|
34 | + if ($this->checkExtender('paginate')) { |
|
35 | 35 | $this->extender['paginate']->init($this); |
36 | - } else { |
|
36 | + } else { |
|
37 | 37 | $this->config->setConfig(array('start' => 0)); |
38 | 38 | } |
39 | 39 | $type = $this->getCFGDef('idType', 'parents'); |
@@ -46,26 +46,26 @@ discard block |
||
46 | 46 | * @param string $tpl |
47 | 47 | * @return string |
48 | 48 | */ |
49 | - public function _render($tpl = '') |
|
50 | - { |
|
49 | + public function _render($tpl = '') |
|
50 | + { |
|
51 | 51 | $out = ''; |
52 | 52 | $separator = $this->getCFGDef('outputSeparator', ''); |
53 | - if ($tpl == '') { |
|
53 | + if ($tpl == '') { |
|
54 | 54 | $tpl = $this->getCFGDef('tpl', ''); |
55 | 55 | } |
56 | - if ($tpl != '') { |
|
56 | + if ($tpl != '') { |
|
57 | 57 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице. |
58 | 58 | |
59 | 59 | $i = 1; |
60 | 60 | $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); |
61 | 61 | $noneTPL = $this->getCFGDef("noneTPL", ""); |
62 | - if (count($this->_docs) == 0 && $noneTPL != '') { |
|
62 | + if (count($this->_docs) == 0 && $noneTPL != '') { |
|
63 | 63 | $out = $this->parseChunk($noneTPL, $sysPlh); |
64 | - } else { |
|
64 | + } else { |
|
65 | 65 | /** |
66 | 66 | * @var $extUser user_DL_Extender |
67 | 67 | */ |
68 | - if ($extUser = $this->getExtender('user')) { |
|
68 | + if ($extUser = $this->getExtender('user')) { |
|
69 | 69 | $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); |
70 | 70 | } |
71 | 71 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | */ |
80 | 80 | $extPrepare = $this->getExtender('prepare'); |
81 | 81 | $this->skippedDocs = 0; |
82 | - foreach ($this->_docs as $item) { |
|
82 | + foreach ($this->_docs as $item) { |
|
83 | 83 | $this->renderTPL = $tpl; |
84 | - if ($extUser) { |
|
84 | + if ($extUser) { |
|
85 | 85 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+].... |
86 | 86 | } |
87 | 87 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | "dl") . '.iteration'] = $i; //[+iteration+] - Number element. Starting from zero |
95 | 95 | |
96 | 96 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
97 | - if (isset($item[$date])) { |
|
97 | + if (isset($item[$date])) { |
|
98 | 98 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]); |
99 | - if ($_date !== false) { |
|
99 | + if ($_date !== false) { |
|
100 | 100 | $_date = $_date + $this->modx->config['server_offset_time']; |
101 | 101 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
102 | - if ($dateFormat) { |
|
102 | + if ($dateFormat) { |
|
103 | 103 | $item['date'] = strftime($dateFormat, $_date); |
104 | 104 | } |
105 | 105 | } |
@@ -108,27 +108,27 @@ discard block |
||
108 | 108 | $findTpl = $this->renderTPL; |
109 | 109 | $tmp = $this->uniformPrepare($item, $i); |
110 | 110 | extract($tmp, EXTR_SKIP); |
111 | - if ($this->renderTPL == '') { |
|
111 | + if ($this->renderTPL == '') { |
|
112 | 112 | $this->renderTPL = $findTpl; |
113 | 113 | } |
114 | 114 | |
115 | - if ($extPrepare) { |
|
115 | + if ($extPrepare) { |
|
116 | 116 | $item = $extPrepare->init($this, array( |
117 | 117 | 'data' => $item, |
118 | 118 | 'nameParam' => 'prepare' |
119 | 119 | )); |
120 | - if (is_bool($item) && $item === false) { |
|
120 | + if (is_bool($item) && $item === false) { |
|
121 | 121 | $this->skippedDocs++; |
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | $tmp = $this->parseChunk($this->renderTPL, $item); |
126 | - if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
126 | + if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
127 | 127 | $this->toPlaceholders($tmp, 1, |
128 | 128 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page |
129 | 129 | } |
130 | 130 | $out .= $tmp; |
131 | - if (next($this->_docs) !== false) { |
|
131 | + if (next($this->_docs) !== false) { |
|
132 | 132 | $out .= $separator; |
133 | 133 | } |
134 | 134 | $i++; |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param array $array |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function getJSON($data, $fields, $array = array()) |
|
150 | - { |
|
149 | + public function getJSON($data, $fields, $array = array()) |
|
150 | + { |
|
151 | 151 | $out = array(); |
152 | 152 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
153 | 153 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | * @var $extE e_DL_Extender |
167 | 167 | */ |
168 | 168 | $extE = $this->getExtender('e', true, true); |
169 | - foreach ($data as $num => $row) { |
|
169 | + foreach ($data as $num => $row) { |
|
170 | 170 | |
171 | - switch (true) { |
|
171 | + switch (true) { |
|
172 | 172 | case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary): |
173 | 173 | $row['summary'] = $this->getSummary($row, $extSummary, 'introtext'); |
174 | 174 | //without break |
175 | 175 | case ((array('1') == $fields || in_array('date', $fields)) && $date != 'date'): |
176 | - if (isset($row[$date])) { |
|
176 | + if (isset($row[$date])) { |
|
177 | 177 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]); |
178 | - if ($_date !== false) { |
|
178 | + if ($_date !== false) { |
|
179 | 179 | $_date = $_date + $this->modx->config['server_offset_time']; |
180 | 180 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
181 | - if ($dateFormat) { |
|
181 | + if ($dateFormat) { |
|
182 | 182 | $row['date'] = strftime($dateFormat, $_date); |
183 | 183 | } |
184 | 184 | } |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | //nobreak |
187 | 187 | } |
188 | 188 | |
189 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
190 | - if (is_array($tmp)) { |
|
189 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
190 | + if (is_array($tmp)) { |
|
191 | 191 | $row = $tmp; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if ($extPrepare) { |
|
195 | + if ($extPrepare) { |
|
196 | 196 | $row = $extPrepare->init($this, array('data' => $row)); |
197 | - if (is_bool($row) && $row === false) { |
|
197 | + if (is_bool($row) && $row === false) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | } |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | /** |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - protected function getDocList() |
|
211 | - { |
|
210 | + protected function getDocList() |
|
211 | + { |
|
212 | 212 | $out = array(); |
213 | 213 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
214 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
214 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
215 | 215 | $from = $this->table . " " . $this->_filters['join']; |
216 | 216 | $where = $this->getCFGDef('addWhereList', ''); |
217 | 217 | |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | //------- end of block ------- |
222 | 222 | |
223 | 223 | |
224 | - if ($where != '') { |
|
224 | + if ($where != '') { |
|
225 | 225 | $where = array($where); |
226 | 226 | } |
227 | - if ($sanitarInIDs != "''") { |
|
227 | + if ($sanitarInIDs != "''") { |
|
228 | 228 | $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; |
229 | 229 | } |
230 | 230 | |
231 | - if (!empty($where)) { |
|
231 | + if (!empty($where)) { |
|
232 | 232 | $where = "WHERE " . implode(" AND ", $where); |
233 | 233 | } |
234 | 234 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
239 | 239 | |
240 | 240 | $pk = $this->getPK(false); |
241 | - while ($item = $this->modx->db->getRow($rs)) { |
|
241 | + while ($item = $this->modx->db->getRow($rs)) { |
|
242 | 242 | $out[$item[$pk]] = $item; |
243 | 243 | } |
244 | 244 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * @return array |
251 | 251 | */ |
252 | - protected function getChildrenList() |
|
253 | - { |
|
252 | + protected function getChildrenList() |
|
253 | + { |
|
254 | 254 | $where = array(); |
255 | 255 | $out = array(); |
256 | 256 | $from = $this->table . " " . $this->_filters['join']; |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | //------- end of block ------- |
264 | 264 | |
265 | 265 | |
266 | - if (!empty($tmpWhere)) { |
|
266 | + if (!empty($tmpWhere)) { |
|
267 | 267 | $where[] = $tmpWhere; |
268 | 268 | } |
269 | 269 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
270 | 270 | |
271 | 271 | $tmpWhere = null; |
272 | - if ($sanitarInIDs != "''") { |
|
272 | + if ($sanitarInIDs != "''") { |
|
273 | 273 | $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")"; |
274 | - switch ($this->getCFGDef('showParent', '0')) { |
|
274 | + switch ($this->getCFGDef('showParent', '0')) { |
|
275 | 275 | case -1: |
276 | 276 | $tmpWhere .= ")"; |
277 | 277 | break; |
@@ -284,32 +284,32 @@ discard block |
||
284 | 284 | break; |
285 | 285 | } |
286 | 286 | } |
287 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
287 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
288 | 288 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
289 | - if (empty($tmpWhere)) { |
|
289 | + if (empty($tmpWhere)) { |
|
290 | 290 | $tmpWhere = $this->getPK() . " IN({$addDocs})"; |
291 | - } else { |
|
291 | + } else { |
|
292 | 292 | $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
293 | 293 | } |
294 | 294 | } |
295 | - if (!empty($tmpWhere)) { |
|
295 | + if (!empty($tmpWhere)) { |
|
296 | 296 | $where[] = $tmpWhere; |
297 | 297 | } |
298 | - if (!empty($where)) { |
|
298 | + if (!empty($where)) { |
|
299 | 299 | $where = "WHERE " . implode(" AND ", $where); |
300 | - } else { |
|
300 | + } else { |
|
301 | 301 | $where = ''; |
302 | 302 | } |
303 | 303 | $fields = $this->getCFGDef('selectFields', '*'); |
304 | 304 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
305 | 305 | $sort = $this->SortOrderSQL($this->getPK()); |
306 | 306 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)) |
307 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
307 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
308 | 308 | $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
309 | 309 | |
310 | 310 | $pk = $this->getPK(false); |
311 | 311 | |
312 | - while ($item = $this->modx->db->getRow($rs)) { |
|
312 | + while ($item = $this->modx->db->getRow($rs)) { |
|
313 | 313 | $out[$item[$pk]] = $item; |
314 | 314 | } |
315 | 315 | |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @absctract |
323 | 323 | */ |
324 | - public function getChildrenCount() |
|
325 | - { |
|
324 | + public function getChildrenCount() |
|
325 | + { |
|
326 | 326 | $out = 0; |
327 | 327 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
328 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
328 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
329 | 329 | $from = $this->table . " " . $this->_filters['join']; |
330 | 330 | $where = $this->getCFGDef('addWhereList', ''); |
331 | 331 | |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $where = sqlHelper::trimLogicalOp($where); |
335 | 335 | //------- end of block ------- |
336 | 336 | |
337 | - if ($where != '') { |
|
337 | + if ($where != '') { |
|
338 | 338 | $where = array($where); |
339 | - } else { |
|
339 | + } else { |
|
340 | 340 | $where = array(); |
341 | 341 | } |
342 | - if ($sanitarInIDs != "''") { |
|
343 | - if ($sanitarInIDs != "''") { |
|
344 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
342 | + if ($sanitarInIDs != "''") { |
|
343 | + if ($sanitarInIDs != "''") { |
|
344 | + switch ($this->getCFGDef('idType', 'parents')) { |
|
345 | 345 | case 'parents': |
346 | - switch ($this->getCFGDef('showParent', '0')) { |
|
346 | + switch ($this->getCFGDef('showParent', '0')) { |
|
347 | 347 | case '-1': |
348 | 348 | $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
349 | 349 | break; |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))"; |
356 | 356 | break; |
357 | 357 | } |
358 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
358 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
359 | 359 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
360 | 360 | $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
361 | - } else { |
|
361 | + } else { |
|
362 | 362 | $where[] = $tmpWhere; |
363 | 363 | } |
364 | 364 | break; |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | - if (!empty($where)) { |
|
371 | + if (!empty($where)) { |
|
372 | 372 | $where = "WHERE " . implode(" AND ", $where); |
373 | - } else { |
|
373 | + } else { |
|
374 | 374 | $where = ''; |
375 | 375 | } |
376 | 376 | |
@@ -388,20 +388,20 @@ discard block |
||
388 | 388 | * @param string $id |
389 | 389 | * @return array |
390 | 390 | */ |
391 | - public function getChildrenFolder($id) |
|
392 | - { |
|
391 | + public function getChildrenFolder($id) |
|
392 | + { |
|
393 | 393 | $out = array(); |
394 | 394 | $sanitarInIDs = $this->sanitarIn($id); |
395 | 395 | |
396 | 396 | $tmp = $this->getCFGDef('addWhereFolder', ''); |
397 | 397 | $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
398 | - if (!empty($tmp)) { |
|
398 | + if (!empty($tmp)) { |
|
399 | 399 | $where .= " AND " . $tmp; |
400 | 400 | } |
401 | 401 | |
402 | 402 | $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
403 | 403 | $pk = $this->getPK(false); |
404 | - while ($item = $this->modx->db->getRow($rs)) { |
|
404 | + while ($item = $this->modx->db->getRow($rs)) { |
|
405 | 405 | $out[] = $item[$pk]; |
406 | 406 | } |
407 | 407 |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $fields = $this->getCFGDef('selectFields', '*'); |
236 | 236 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
237 | 237 | $sort = $this->SortOrderSQL($this->getPK()); |
238 | - $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
|
238 | + $rs = $this->dbQuery("select {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
|
239 | 239 | |
240 | 240 | $pk = $this->getPK(false); |
241 | 241 | while ($item = $this->modx->db->getRow($rs)) { |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $sort = $this->SortOrderSQL($this->getPK()); |
306 | 306 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)) |
307 | 307 | if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
308 | - $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
|
308 | + $rs = $this->dbQuery("select {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
|
309 | 309 | |
310 | 310 | $pk = $this->getPK(false); |
311 | 311 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $where .= " AND " . $tmp; |
400 | 400 | } |
401 | 401 | |
402 | - $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
|
402 | + $rs = $this->dbQuery("select {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
|
403 | 403 | $pk = $this->getPK(false); |
404 | 404 | while ($item = $this->modx->db->getRow($rs)) { |
405 | 405 | $out[] = $item[$pk]; |