Completed
Pull Request — master (#248)
by
unknown
02:31
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) {
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
             $where = "WHERE {$where}";
282 282
             $whereArr = array();
283
-            if (!$this->getCFGDef('showNoPublish', 0)) {
283
+            if ( ! $this->getCFGDef('showNoPublish', 0)) {
284 284
                 $whereArr[] = "c.deleted=0 AND c.published=1";
285 285
             }
286
-            else{
286
+            else {
287 287
                 $q_true = 1;
288 288
             }
289 289
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
             $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id';
340 340
 
341
-            if ( $q_true ){
341
+            if ($q_true) {
342 342
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
343 343
                 $out = $this->modx->db->getValue($rs);
344 344
             }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     protected function injectSortByTV($table, $sort)
446 446
     {
447 447
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
448
-        if (!is_array($out) || empty($out)) {
448
+        if ( ! is_array($out) || empty($out)) {
449 449
             $out = array($table, $sort);
450 450
         }
451 451
 
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
 
463 463
         $tmpWhere = $this->getCFGDef('addWhereList', '');
464 464
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
465
-        if (!empty($tmpWhere)) {
465
+        if ( ! empty($tmpWhere)) {
466 466
             $where[] = $tmpWhere;
467 467
         }
468 468
 
469 469
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
470
-        if (!empty($tmpWhere)) {
470
+        if ( ! empty($tmpWhere)) {
471 471
             $where[] = $tmpWhere;
472 472
         }
473 473
 
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
501 501
             }
502 502
         }
503
-        if (!empty($tmpWhere)) {
503
+        if ( ! empty($tmpWhere)) {
504 504
             $where[] = $tmpWhere;
505 505
         }
506
-        if (!$this->getCFGDef('showNoPublish', 0)) {
506
+        if ( ! $this->getCFGDef('showNoPublish', 0)) {
507 507
             $where[] = "c.deleted=0 AND c.published=1";
508 508
         }
509
-        if (!empty($where)) {
509
+        if ( ! empty($where)) {
510 510
             $where = "WHERE " . implode(" AND ", $where);
511 511
         } else {
512 512
             $where = '';
Please login to merge, or discard this patch.
Braces   +102 added lines, -104 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,36 +263,35 @@  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
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
272 272
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
273 273
             $where = $this->getCFGDef('addWhereList', '');
274 274
             $where = sqlHelper::trimLogicalOp($where);
275 275
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
276
-            if ($where != '' && $this->_filters['where'] != '') {
276
+            if ($where != '' && $this->_filters['where'] != '') {
277 277
                 $where .= " AND ";
278 278
             }
279 279
             $where = sqlHelper::trimLogicalOp($where);
280 280
 
281 281
             $where = "WHERE {$where}";
282 282
             $whereArr = array();
283
-            if (!$this->getCFGDef('showNoPublish', 0)) {
283
+            if (!$this->getCFGDef('showNoPublish', 0)) {
284 284
                 $whereArr[] = "c.deleted=0 AND c.published=1";
285
-            }
286
-            else{
285
+            } else {
287 286
                 $q_true = 1;
288 287
             }
289 288
 
290 289
             $tbl_site_content = $this->getTable('site_content', 'c');
291 290
 
292
-            if ($sanitarInIDs != "''") {
293
-                switch ($this->getCFGDef('idType', 'parents')) {
291
+            if ($sanitarInIDs != "''") {
292
+                switch ($this->getCFGDef('idType', 'parents')) {
294 293
                     case 'parents':
295
-                        switch ($this->getCFGDef('showParent', '0')) {
294
+                        switch ($this->getCFGDef('showParent', '0')) {
296 295
                             case '-1':
297 296
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
298 297
                                 break;
@@ -304,10 +303,10 @@  discard block
 block discarded – undo
304 303
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
305 304
                                 break;
306 305
                         }
307
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
306
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
308 307
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
309 308
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
310
-                        } else {
309
+                        } else {
311 310
                             $whereArr[] = $tmpWhere;
312 311
                         }
313 312
 
@@ -322,14 +321,14 @@  discard block
 block discarded – undo
322 321
 
323 322
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
324 323
 
325
-            if (trim($where) != 'WHERE') {
324
+            if (trim($where) != 'WHERE') {
326 325
                 $where .= " AND ";
327 326
             }
328 327
 
329 328
             $where .= implode(" AND ", $whereArr);
330 329
             $where = sqlHelper::trimLogicalOp($where);
331 330
 
332
-            if (trim($where) == 'WHERE') {
331
+            if (trim($where) == 'WHERE') {
333 332
                 $where = '';
334 333
             }
335 334
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
@@ -338,11 +337,10 @@  discard block
 block discarded – undo
338 337
 
339 338
             $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id';
340 339
 
341
-            if ( $q_true ){
340
+            if ( $q_true ) {
342 341
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
343 342
                 $out = $this->modx->db->getValue($rs);
344
-            }
345
-            else {
343
+            } else {
346 344
                 $out = count($this->IDs);
347 345
             }
348 346
         }
@@ -353,11 +351,11 @@  discard block
 block discarded – undo
353 351
     /**
354 352
      * @return array
355 353
      */
356
-    protected function getDocList()
357
-    {
354
+    protected function getDocList()
355
+    {
358 356
         $out = array();
359 357
         $sanitarInIDs = $this->sanitarIn($this->IDs);
360
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
358
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
361 359
             $where = $this->getCFGDef('addWhereList', '');
362 360
             $where = sqlHelper::trimLogicalOp($where);
363 361
 
@@ -365,21 +363,21 @@  discard block
 block discarded – undo
365 363
             $where = sqlHelper::trimLogicalOp($where);
366 364
 
367 365
             $tbl_site_content = $this->getTable('site_content', 'c');
368
-            if ($sanitarInIDs != "''") {
366
+            if ($sanitarInIDs != "''") {
369 367
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
370 368
             }
371 369
             $where = sqlHelper::trimLogicalOp($where);
372 370
 
373
-            if ($this->getCFGDef('showNoPublish', 0)) {
374
-                if ($where != '') {
371
+            if ($this->getCFGDef('showNoPublish', 0)) {
372
+                if ($where != '') {
375 373
                     $where = "WHERE {$where}";
376
-                } else {
374
+                } else {
377 375
                     $where = '';
378 376
                 }
379
-            } else {
380
-                if ($where != '') {
377
+            } else {
378
+                if ($where != '') {
381 379
                     $where = "WHERE {$where} AND ";
382
-                } else {
380
+                } else {
383 381
                     $where = "WHERE {$where} ";
384 382
                 }
385 383
                 $where .= "c.deleted=0 AND c.published=1";
@@ -398,7 +396,7 @@  discard block
 block discarded – undo
398 396
 
399 397
             $rows = $this->modx->db->makeArray($rs);
400 398
 
401
-            foreach ($rows as $item) {
399
+            foreach ($rows as $item) {
402 400
                 $out[$item['id']] = $item;
403 401
             }
404 402
         }
@@ -410,19 +408,19 @@  discard block
 block discarded – undo
410 408
      * @param string $id
411 409
      * @return array
412 410
      */
413
-    public function getChildrenFolder($id)
414
-    {
411
+    public function getChildrenFolder($id)
412
+    {
415 413
         $where = $this->getCFGDef('addWhereFolder', '');
416 414
         $where = sqlHelper::trimLogicalOp($where);
417
-        if ($where != '') {
415
+        if ($where != '') {
418 416
             $where .= " AND ";
419 417
         }
420 418
 
421 419
         $tbl_site_content = $this->getTable('site_content', 'c');
422 420
         $sanitarInIDs = $this->sanitarIn($id);
423
-        if ($this->getCFGDef('showNoPublish', 0)) {
421
+        if ($this->getCFGDef('showNoPublish', 0)) {
424 422
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
425
-        } else {
423
+        } else {
426 424
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
427 425
         }
428 426
 
@@ -430,7 +428,7 @@  discard block
 block discarded – undo
430 428
 
431 429
         $rows = $this->modx->db->makeArray($rs);
432 430
         $out = array();
433
-        foreach ($rows as $item) {
431
+        foreach ($rows as $item) {
434 432
             $out[] = $item['id'];
435 433
         }
436 434
 
@@ -442,10 +440,10 @@  discard block
 block discarded – undo
442 440
      * @param $sort
443 441
      * @return array
444 442
      */
445
-    protected function injectSortByTV($table, $sort)
446
-    {
443
+    protected function injectSortByTV($table, $sort)
444
+    {
447 445
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
448
-        if (!is_array($out) || empty($out)) {
446
+        if (!is_array($out) || empty($out)) {
449 447
             $out = array($table, $sort);
450 448
         }
451 449
 
@@ -455,19 +453,19 @@  discard block
 block discarded – undo
455 453
     /**
456 454
      * @return array
457 455
      */
458
-    protected function getChildrenList()
459
-    {
456
+    protected function getChildrenList()
457
+    {
460 458
         $where = array();
461 459
         $out = array();
462 460
 
463 461
         $tmpWhere = $this->getCFGDef('addWhereList', '');
464 462
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
465
-        if (!empty($tmpWhere)) {
463
+        if (!empty($tmpWhere)) {
466 464
             $where[] = $tmpWhere;
467 465
         }
468 466
 
469 467
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
470
-        if (!empty($tmpWhere)) {
468
+        if (!empty($tmpWhere)) {
471 469
             $where[] = $tmpWhere;
472 470
         }
473 471
 
@@ -478,8 +476,8 @@  discard block
 block discarded – undo
478 476
         $sanitarInIDs = $this->sanitarIn($this->IDs);
479 477
 
480 478
         $tmpWhere = null;
481
-        if ($sanitarInIDs != "''") {
482
-            switch ($this->getCFGDef('showParent', '0')) {
479
+        if ($sanitarInIDs != "''") {
480
+            switch ($this->getCFGDef('showParent', '0')) {
483 481
                 case '-1':
484 482
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
485 483
                     break;
@@ -492,29 +490,29 @@  discard block
 block discarded – undo
492 490
                     break;
493 491
             }
494 492
         }
495
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
493
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
496 494
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
497
-            if (empty($tmpWhere)) {
495
+            if (empty($tmpWhere)) {
498 496
                 $tmpWhere = "c.id IN({$addDocs})";
499
-            } else {
497
+            } else {
500 498
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
501 499
             }
502 500
         }
503
-        if (!empty($tmpWhere)) {
501
+        if (!empty($tmpWhere)) {
504 502
             $where[] = $tmpWhere;
505 503
         }
506
-        if (!$this->getCFGDef('showNoPublish', 0)) {
504
+        if (!$this->getCFGDef('showNoPublish', 0)) {
507 505
             $where[] = "c.deleted=0 AND c.published=1";
508 506
         }
509
-        if (!empty($where)) {
507
+        if (!empty($where)) {
510 508
             $where = "WHERE " . implode(" AND ", $where);
511
-        } else {
509
+        } else {
512 510
             $where = '';
513 511
         }
514 512
         $fields = $this->getCFGDef('selectFields', 'c.*');
515 513
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
516 514
 
517
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
515
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
518 516
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
519 517
                 $group . " " .
520 518
                 $sort . " " .
@@ -523,7 +521,7 @@  discard block
 block discarded – undo
523 521
 
524 522
             $rows = $this->modx->db->makeArray($sql);
525 523
 
526
-            foreach ($rows as $item) {
524
+            foreach ($rows as $item) {
527 525
                 $out[$item['id']] = $item;
528 526
             }
529 527
         }
@@ -536,10 +534,10 @@  discard block
 block discarded – undo
536 534
      * @param string $type
537 535
      * @return string
538 536
      */
539
-    public function changeSortType($field, $type)
540
-    {
537
+    public function changeSortType($field, $type)
538
+    {
541 539
         $type = trim($type);
542
-        switch (strtoupper($type)) {
540
+        switch (strtoupper($type)) {
543 541
             case 'TVDATETIME':
544 542
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
545 543
                 break;
Please login to merge, or discard this patch.