Completed
Pull Request — master (#248)
by
unknown
02:37
created
assets/snippets/DocLister/core/controller/site_content.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
59 59
         if ($tvlist != '' && count($this->_docs) > 0) {
60 60
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
61
-            if (!is_array($tv)) {
61
+            if ( ! is_array($tv)) {
62 62
                 $tv = array();
63 63
             }
64 64
             foreach ($tv as $docID => $TVitem) {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
             $where = "WHERE {$where}";
280 280
             $whereArr = array();
281
-            if (!$this->getCFGDef('showNoPublish', 0)) {
281
+            if ( ! $this->getCFGDef('showNoPublish', 0)) {
282 282
                 $whereArr[] = "c.deleted=0 AND c.published=1";
283 283
             }
284 284
 
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
             $sort = $this->SortOrderSQL("if(c.pub_date=0,c.createdon,c.pub_date)");
330 330
             list($from) = $this->injectSortByTV($from, $sort);
331 331
             
332
-            if ( $this->getCFGDef('idType', 'parents') == 'parents' || $this->getCFGDef('filters') ){
332
+            if ($this->getCFGDef('idType', 'parents') == 'parents' || $this->getCFGDef('filters')) {
333 333
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
334 334
                 $out = $this->modx->db->getValue($rs);
335 335
             }
336
-            else{
336
+            else {
337 337
                 $out = count($this->IDs);
338 338
             }
339 339
         }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
     protected function injectSortByTV($table, $sort)
437 437
     {
438 438
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
439
-        if (!is_array($out) || empty($out)) {
439
+        if ( ! is_array($out) || empty($out)) {
440 440
             $out = array($table, $sort);
441 441
         }
442 442
 
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 
454 454
         $tmpWhere = $this->getCFGDef('addWhereList', '');
455 455
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
456
-        if (!empty($tmpWhere)) {
456
+        if ( ! empty($tmpWhere)) {
457 457
             $where[] = $tmpWhere;
458 458
         }
459 459
 
460 460
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
461
-        if (!empty($tmpWhere)) {
461
+        if ( ! empty($tmpWhere)) {
462 462
             $where[] = $tmpWhere;
463 463
         }
464 464
 
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
492 492
             }
493 493
         }
494
-        if (!empty($tmpWhere)) {
494
+        if ( ! empty($tmpWhere)) {
495 495
             $where[] = $tmpWhere;
496 496
         }
497
-        if (!$this->getCFGDef('showNoPublish', 0)) {
497
+        if ( ! $this->getCFGDef('showNoPublish', 0)) {
498 498
             $where[] = "c.deleted=0 AND c.published=1";
499 499
         }
500
-        if (!empty($where)) {
500
+        if ( ! empty($where)) {
501 501
             $where = "WHERE " . implode(" AND ", $where);
502 502
         } else {
503 503
             $where = '';
Please login to merge, or discard this patch.
Braces   +101 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
12 12
  * @author Agel_Nash <[email protected]>, kabachello <[email protected]>
13 13
  */
14
-class site_contentDocLister extends DocLister
15
-{
14
+class site_contentDocLister extends DocLister
15
+{
16 16
     /**
17 17
      * Экземпляр экстендера TV
18 18
      *
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
      * @param array $cfg
33 33
      * @param null $startTime
34 34
      */
35
-    public function __construct($modx, $cfg = array(), $startTime = null)
36
-    {
35
+    public function __construct($modx, $cfg = array(), $startTime = null)
36
+    {
37 37
         parent::__construct($modx, $cfg, $startTime);
38 38
         $this->extTV = $this->getExtender('tv', true, true);
39 39
     }
@@ -41,35 +41,35 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @absctract
43 43
      */
44
-    public function getDocs($tvlist = '')
45
-    {
46
-        if ($tvlist == '') {
44
+    public function getDocs($tvlist = '')
45
+    {
46
+        if ($tvlist == '') {
47 47
             $tvlist = $this->getCFGDef('tvList', '');
48 48
         }
49 49
         
50 50
         $this->extTV->getAllTV_Name();
51 51
 
52
-        if ($this->extPaginate = $this->getExtender('paginate')) {
52
+        if ($this->extPaginate = $this->getExtender('paginate')) {
53 53
             $this->extPaginate->init($this);
54
-        } else {
54
+        } else {
55 55
             $this->config->setConfig(array('start' => 0));
56 56
         }
57 57
         $type = $this->getCFGDef('idType', 'parents');
58 58
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
59
-        if ($tvlist != '' && count($this->_docs) > 0) {
59
+        if ($tvlist != '' && count($this->_docs) > 0) {
60 60
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
61
-            if (!is_array($tv)) {
61
+            if (!is_array($tv)) {
62 62
                 $tv = array();
63 63
             }
64
-            foreach ($tv as $docID => $TVitem) {
65
-                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
64
+            foreach ($tv as $docID => $TVitem) {
65
+                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
66 66
                     $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);
67
-                } else {
67
+                } else {
68 68
                     unset($this->_docs[$docID]);
69 69
                 }
70 70
             }
71 71
         }
72
-        if (1 == $this->getCFGDef('tree', '0')) {
72
+        if (1 == $this->getCFGDef('tree', '0')) {
73 73
             $this->treeBuild('id', 'parent');
74 74
         }
75 75
 
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
      * @param string $tpl
81 81
      * @return string
82 82
      */
83
-    public function _render($tpl = '')
84
-    {
83
+    public function _render($tpl = '')
84
+    {
85 85
         $out = '';
86
-        if ($tpl == '') {
86
+        if ($tpl == '') {
87 87
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
88 88
         }
89
-        if ($tpl != '') {
89
+        if ($tpl != '') {
90 90
             $date = $this->getCFGDef('dateSource', 'pub_date');
91 91
 
92 92
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
93 93
 
94 94
             $i = 1;
95 95
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
96
-            if (count($this->_docs) > 0) {
96
+            if (count($this->_docs) > 0) {
97 97
                 /**
98 98
                  * @var $extUser user_DL_Extender
99 99
                  */
100
-                if ($extUser = $this->getExtender('user')) {
100
+                if ($extUser = $this->getExtender('user')) {
101 101
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
102 102
                 }
103 103
 
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
                  */
117 117
                 $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
118 118
 
119
-                if ($extJotCount) {
119
+                if ($extJotCount) {
120 120
                     $comments = $extJotCount->countComments(array_keys($this->_docs));
121 121
                 }
122 122
 
123 123
                 $this->skippedDocs = 0;
124
-                foreach ($this->_docs as $item) {
124
+                foreach ($this->_docs as $item) {
125 125
                     $this->renderTPL = $tpl;
126
-                    if ($extUser) {
126
+                    if ($extUser) {
127 127
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
128 128
                     }
129 129
 
130 130
                     $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, 'introtext', 'content') : '';
131 131
 
132
-                    if ($extJotCount) {
132
+                    if ($extJotCount) {
133 133
                         $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0);
134 134
                     }
135 135
 
@@ -139,53 +139,53 @@  discard block
 block discarded – undo
139 139
 
140 140
                     $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);
141 141
 
142
-                    if ($this->getCFGDef('makeUrl', 1)) {
143
-                        if ($item['type'] == 'reference') {
142
+                    if ($this->getCFGDef('makeUrl', 1)) {
143
+                        if ($item['type'] == 'reference') {
144 144
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
145 145
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
146
-                        } else {
146
+                        } else {
147 147
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
148 148
                         }
149 149
                     }
150 150
 
151 151
                     $item['date'] = (isset($item[$date]) && $date != 'createdon' && $item[$date] != 0 && $item[$date] == (int)$item[$date]) ? $item[$date] : $item['createdon'];
152 152
                     $item['date'] = $item['date'] + $this->modx->config['server_offset_time'];
153
-                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
153
+                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
154 154
                         $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $item['date']);
155 155
                     }
156 156
 
157 157
                     $findTpl = $this->renderTPL;
158 158
                     $tmp = $this->uniformPrepare($item, $i);
159 159
                     extract($tmp, EXTR_SKIP);
160
-                    if ($this->renderTPL == '') {
160
+                    if ($this->renderTPL == '') {
161 161
                         $this->renderTPL = $findTpl;
162 162
                     }
163 163
 
164
-                    if ($extPrepare) {
164
+                    if ($extPrepare) {
165 165
                         $item = $extPrepare->init($this, array(
166 166
                             'data'      => $item,
167 167
                             'nameParam' => 'prepare'
168 168
                         ));
169
-                        if (is_bool($item) && $item === false) {
169
+                        if (is_bool($item) && $item === false) {
170 170
                             $this->skippedDocs++;
171 171
                             continue;
172 172
                         }
173 173
                     }
174 174
                     $tmp = $this->parseChunk($this->renderTPL, $item);
175 175
 
176
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
176
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
177 177
                         $this->toPlaceholders($tmp, 1,
178 178
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
179 179
                     }
180 180
                     $out .= $tmp;
181 181
                     $i++;
182 182
                 }
183
-            } else {
183
+            } else {
184 184
                 $noneTPL = $this->getCFGDef("noneTPL", "");
185 185
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
186 186
             }
187 187
             $out = $this->renderWrap($out);
188
-        } else {
188
+        } else {
189 189
             $out = 'no template';
190 190
         }
191 191
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
      * @param array $array
199 199
      * @return string
200 200
      */
201
-    public function getJSON($data, $fields, $array = array())
202
-    {
201
+    public function getJSON($data, $fields, $array = array())
202
+    {
203 203
         $out = array();
204 204
         $fields = is_array($fields) ? $fields : explode(",", $fields);
205 205
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
          */
220 220
         $extE = $this->getExtender('e', true, true);
221 221
 
222
-        foreach ($data as $num => $item) {
222
+        foreach ($data as $num => $item) {
223 223
             $row = $item;
224
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
224
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
225 225
                 $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext', 'content');
226 226
             }
227
-            if (array('1') == $fields || in_array('date', $fields)) {
227
+            if (array('1') == $fields || in_array('date', $fields)) {
228 228
                 $tmp = (isset($this->_docs[$num][$date]) && $date != 'createdon' && $this->_docs[$num][$date] != 0 && $this->_docs[$num][$date] == (int)$this->_docs[$num][$date]) ? $this->_docs[$num][$date] : $this->_docs[$num]['createdon'];
229 229
                 $row['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'),
230 230
                     $tmp + $this->modx->config['server_offset_time']);
231 231
             }
232
-            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
232
+            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
233 233
                 $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']);
234 234
             }
235 235
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'),
236 236
                         $fields))
237
-            ) {
238
-                if ($row['type'] == 'reference') {
237
+            ) {
238
+                if ($row['type'] == 'reference') {
239 239
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
240 240
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
241
-                } else {
241
+                } else {
242 242
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
243 243
                 }
244 244
             }
245
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
246
-                if (is_array($tmp)) {
245
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
246
+                if (is_array($tmp)) {
247 247
                     $row = $tmp;
248 248
                 }
249 249
             }
250 250
 
251
-            if ($extPrepare) {
251
+            if ($extPrepare) {
252 252
                 $row = $extPrepare->init($this, array('data' => $row));
253
-                if (is_bool($row) && $row === false) {
253
+                if (is_bool($row) && $row === false) {
254 254
                     continue;
255 255
                 }
256 256
             }
@@ -263,31 +263,31 @@  discard block
 block discarded – undo
263 263
     /**
264 264
      * @abstract
265 265
      */
266
-    public function getChildrenCount()
267
-    {
266
+    public function getChildrenCount()
267
+    {
268 268
         $out = 0;
269 269
         $sanitarInIDs = $this->sanitarIn($this->IDs);
270
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
270
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
271 271
             $where = $this->getCFGDef('addWhereList', '');
272 272
             $where = sqlHelper::trimLogicalOp($where);
273 273
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
274
-            if ($where != '' && $this->_filters['where'] != '') {
274
+            if ($where != '' && $this->_filters['where'] != '') {
275 275
                 $where .= " AND ";
276 276
             }
277 277
             $where = sqlHelper::trimLogicalOp($where);
278 278
 
279 279
             $where = "WHERE {$where}";
280 280
             $whereArr = array();
281
-            if (!$this->getCFGDef('showNoPublish', 0)) {
281
+            if (!$this->getCFGDef('showNoPublish', 0)) {
282 282
                 $whereArr[] = "c.deleted=0 AND c.published=1";
283 283
             }
284 284
 
285 285
             $tbl_site_content = $this->getTable('site_content', 'c');
286 286
 
287
-            if ($sanitarInIDs != "''") {
288
-                switch ($this->getCFGDef('idType', 'parents')) {
287
+            if ($sanitarInIDs != "''") {
288
+                switch ($this->getCFGDef('idType', 'parents')) {
289 289
                     case 'parents':
290
-                        switch ($this->getCFGDef('showParent', '0')) {
290
+                        switch ($this->getCFGDef('showParent', '0')) {
291 291
                             case '-1':
292 292
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
293 293
                                 break;
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
300 300
                                 break;
301 301
                         }
302
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
302
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
303 303
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
304 304
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
305
-                        } else {
305
+                        } else {
306 306
                             $whereArr[] = $tmpWhere;
307 307
                         }
308 308
 
@@ -315,25 +315,24 @@  discard block
 block discarded – undo
315 315
             $from = $tbl_site_content . " " . $this->_filters['join'];
316 316
             $where = sqlHelper::trimLogicalOp($where);
317 317
 
318
-            if (trim($where) != 'WHERE') {
318
+            if (trim($where) != 'WHERE') {
319 319
                 $where .= " AND ";
320 320
             }
321 321
 
322 322
             $where .= implode(" AND ", $whereArr);
323 323
             $where = sqlHelper::trimLogicalOp($where);
324 324
 
325
-            if (trim($where) == 'WHERE') {
325
+            if (trim($where) == 'WHERE') {
326 326
                 $where = '';
327 327
             }
328 328
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
329 329
             $sort = $this->SortOrderSQL("if(c.pub_date=0,c.createdon,c.pub_date)");
330 330
             list($from) = $this->injectSortByTV($from, $sort);
331 331
             
332
-            if ( $this->getCFGDef('idType', 'parents') == 'parents' || $this->getCFGDef('filters') ){
332
+            if ( $this->getCFGDef('idType', 'parents') == 'parents' || $this->getCFGDef('filters') ) {
333 333
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
334 334
                 $out = $this->modx->db->getValue($rs);
335
-            }
336
-            else{
335
+            } else {
337 336
                 $out = count($this->IDs);
338 337
             }
339 338
         }
@@ -344,11 +343,11 @@  discard block
 block discarded – undo
344 343
     /**
345 344
      * @return array
346 345
      */
347
-    protected function getDocList()
348
-    {
346
+    protected function getDocList()
347
+    {
349 348
         $out = array();
350 349
         $sanitarInIDs = $this->sanitarIn($this->IDs);
351
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
350
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
352 351
             $where = $this->getCFGDef('addWhereList', '');
353 352
             $where = sqlHelper::trimLogicalOp($where);
354 353
 
@@ -356,21 +355,21 @@  discard block
 block discarded – undo
356 355
             $where = sqlHelper::trimLogicalOp($where);
357 356
 
358 357
             $tbl_site_content = $this->getTable('site_content', 'c');
359
-            if ($sanitarInIDs != "''") {
358
+            if ($sanitarInIDs != "''") {
360 359
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
361 360
             }
362 361
             $where = sqlHelper::trimLogicalOp($where);
363 362
 
364
-            if ($this->getCFGDef('showNoPublish', 0)) {
365
-                if ($where != '') {
363
+            if ($this->getCFGDef('showNoPublish', 0)) {
364
+                if ($where != '') {
366 365
                     $where = "WHERE {$where}";
367
-                } else {
366
+                } else {
368 367
                     $where = '';
369 368
                 }
370
-            } else {
371
-                if ($where != '') {
369
+            } else {
370
+                if ($where != '') {
372 371
                     $where = "WHERE {$where} AND ";
373
-                } else {
372
+                } else {
374 373
                     $where = "WHERE {$where} ";
375 374
                 }
376 375
                 $where .= "c.deleted=0 AND c.published=1";
@@ -389,7 +388,7 @@  discard block
 block discarded – undo
389 388
 
390 389
             $rows = $this->modx->db->makeArray($rs);
391 390
 
392
-            foreach ($rows as $item) {
391
+            foreach ($rows as $item) {
393 392
                 $out[$item['id']] = $item;
394 393
             }
395 394
         }
@@ -401,19 +400,19 @@  discard block
 block discarded – undo
401 400
      * @param string $id
402 401
      * @return array
403 402
      */
404
-    public function getChildrenFolder($id)
405
-    {
403
+    public function getChildrenFolder($id)
404
+    {
406 405
         $where = $this->getCFGDef('addWhereFolder', '');
407 406
         $where = sqlHelper::trimLogicalOp($where);
408
-        if ($where != '') {
407
+        if ($where != '') {
409 408
             $where .= " AND ";
410 409
         }
411 410
 
412 411
         $tbl_site_content = $this->getTable('site_content', 'c');
413 412
         $sanitarInIDs = $this->sanitarIn($id);
414
-        if ($this->getCFGDef('showNoPublish', 0)) {
413
+        if ($this->getCFGDef('showNoPublish', 0)) {
415 414
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
416
-        } else {
415
+        } else {
417 416
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
418 417
         }
419 418
 
@@ -421,7 +420,7 @@  discard block
 block discarded – undo
421 420
 
422 421
         $rows = $this->modx->db->makeArray($rs);
423 422
         $out = array();
424
-        foreach ($rows as $item) {
423
+        foreach ($rows as $item) {
425 424
             $out[] = $item['id'];
426 425
         }
427 426
 
@@ -433,10 +432,10 @@  discard block
 block discarded – undo
433 432
      * @param $sort
434 433
      * @return array
435 434
      */
436
-    protected function injectSortByTV($table, $sort)
437
-    {
435
+    protected function injectSortByTV($table, $sort)
436
+    {
438 437
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
439
-        if (!is_array($out) || empty($out)) {
438
+        if (!is_array($out) || empty($out)) {
440 439
             $out = array($table, $sort);
441 440
         }
442 441
 
@@ -446,19 +445,19 @@  discard block
 block discarded – undo
446 445
     /**
447 446
      * @return array
448 447
      */
449
-    protected function getChildrenList()
450
-    {
448
+    protected function getChildrenList()
449
+    {
451 450
         $where = array();
452 451
         $out = array();
453 452
 
454 453
         $tmpWhere = $this->getCFGDef('addWhereList', '');
455 454
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
456
-        if (!empty($tmpWhere)) {
455
+        if (!empty($tmpWhere)) {
457 456
             $where[] = $tmpWhere;
458 457
         }
459 458
 
460 459
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
461
-        if (!empty($tmpWhere)) {
460
+        if (!empty($tmpWhere)) {
462 461
             $where[] = $tmpWhere;
463 462
         }
464 463
 
@@ -469,8 +468,8 @@  discard block
 block discarded – undo
469 468
         $sanitarInIDs = $this->sanitarIn($this->IDs);
470 469
 
471 470
         $tmpWhere = null;
472
-        if ($sanitarInIDs != "''") {
473
-            switch ($this->getCFGDef('showParent', '0')) {
471
+        if ($sanitarInIDs != "''") {
472
+            switch ($this->getCFGDef('showParent', '0')) {
474 473
                 case '-1':
475 474
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
476 475
                     break;
@@ -483,29 +482,29 @@  discard block
 block discarded – undo
483 482
                     break;
484 483
             }
485 484
         }
486
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
485
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
487 486
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
488
-            if (empty($tmpWhere)) {
487
+            if (empty($tmpWhere)) {
489 488
                 $tmpWhere = "c.id IN({$addDocs})";
490
-            } else {
489
+            } else {
491 490
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
492 491
             }
493 492
         }
494
-        if (!empty($tmpWhere)) {
493
+        if (!empty($tmpWhere)) {
495 494
             $where[] = $tmpWhere;
496 495
         }
497
-        if (!$this->getCFGDef('showNoPublish', 0)) {
496
+        if (!$this->getCFGDef('showNoPublish', 0)) {
498 497
             $where[] = "c.deleted=0 AND c.published=1";
499 498
         }
500
-        if (!empty($where)) {
499
+        if (!empty($where)) {
501 500
             $where = "WHERE " . implode(" AND ", $where);
502
-        } else {
501
+        } else {
503 502
             $where = '';
504 503
         }
505 504
         $fields = $this->getCFGDef('selectFields', 'c.*');
506 505
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
507 506
 
508
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
507
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
509 508
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
510 509
                 $group . " " .
511 510
                 $sort . " " .
@@ -514,7 +513,7 @@  discard block
 block discarded – undo
514 513
 
515 514
             $rows = $this->modx->db->makeArray($sql);
516 515
 
517
-            foreach ($rows as $item) {
516
+            foreach ($rows as $item) {
518 517
                 $out[$item['id']] = $item;
519 518
             }
520 519
         }
@@ -527,10 +526,10 @@  discard block
 block discarded – undo
527 526
      * @param string $type
528 527
      * @return string
529 528
      */
530
-    public function changeSortType($field, $type)
531
-    {
529
+    public function changeSortType($field, $type)
530
+    {
532 531
         $type = trim($type);
533
-        switch (strtoupper($type)) {
532
+        switch (strtoupper($type)) {
534 533
             case 'TVDATETIME':
535 534
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
536 535
                 break;
Please login to merge, or discard this patch.