Completed
Push — master ( 82b4a5...e0a298 )
by
unknown
11:45
created
assets/snippets/DocLister/core/controller/site_content.php 2 patches
Spacing   +14 added lines, -14 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
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
68 68
         if ($tvlist != '' && count($this->_docs) > 0) {
69 69
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
70
-            if (!is_array($tv)) {
70
+            if ( ! is_array($tv)) {
71 71
                 $tv = array();
72 72
             }
73 73
             foreach ($tv as $docID => $TVitem) {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                     }
144 144
                     $date = $this->getCFGDef('dateSource', 'pub_date');
145 145
                     if (isset($item[$date])) {
146
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
146
+                        if ( ! $item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
147 147
                             $date = 'createdon';
148 148
                         }
149 149
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
             if (array('1') == $fields || in_array('date', $fields)) {
227 227
                 if (isset($row[$date])) {
228
-                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
228
+                    if ( ! $row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
229 229
                         $date = 'createdon';
230 230
                     }   
231 231
                     $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle'];
245 245
                 }
246 246
             }
247
-            if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields))
247
+            if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url', $fields))
248 248
             ) {
249 249
                 if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
250 250
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 
292 292
             $where = "WHERE {$where}";
293 293
             $whereArr = array();
294
-            if (!$this->getCFGDef('showNoPublish', 0)) {
294
+            if ( ! $this->getCFGDef('showNoPublish', 0)) {
295 295
                 $whereArr[] = "c.deleted=0 AND c.published=1";
296 296
             }
297
-            else{
297
+            else {
298 298
                 $q_true = 1;
299 299
             }
300 300
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
347 347
 
348 348
             $q_true = $q_true ? $q_true : $group != '';
349
-            if ( $q_true ){
349
+            if ($q_true) {
350 350
                 $maxDocs = $this->getCFGDef('maxDocs', 0);
351 351
                 $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : '';
352 352
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`");
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     protected function injectSortByTV($table, $sort)
453 453
     {
454 454
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
455
-        if (!is_array($out) || empty($out)) {
455
+        if ( ! is_array($out) || empty($out)) {
456 456
             $out = array($table, $sort);
457 457
         }
458 458
 
@@ -469,12 +469,12 @@  discard block
 block discarded – undo
469 469
 
470 470
         $tmpWhere = $this->getCFGDef('addWhereList', '');
471 471
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
472
-        if (!empty($tmpWhere)) {
472
+        if ( ! empty($tmpWhere)) {
473 473
             $where[] = $tmpWhere;
474 474
         }
475 475
 
476 476
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
477
-        if (!empty($tmpWhere)) {
477
+        if ( ! empty($tmpWhere)) {
478 478
             $where[] = $tmpWhere;
479 479
         }
480 480
 
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
508 508
             }
509 509
         }
510
-        if (!empty($tmpWhere)) {
510
+        if ( ! empty($tmpWhere)) {
511 511
             $where[] = $tmpWhere;
512 512
         }
513
-        if (!$this->getCFGDef('showNoPublish', 0)) {
513
+        if ( ! $this->getCFGDef('showNoPublish', 0)) {
514 514
             $where[] = "c.deleted=0 AND c.published=1";
515 515
         }
516
-        if (!empty($where)) {
516
+        if ( ! empty($where)) {
517 517
             $where = "WHERE " . implode(" AND ", $where);
518 518
         } else {
519 519
             $where = '';
Please login to merge, or discard this patch.
Braces   +108 added lines, -110 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,9 +41,9 @@  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
         
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
          */
55 55
         $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
56 56
 
57
-        if ($extJotCount) {
57
+        if ($extJotCount) {
58 58
             $extJotCount->init($this);
59 59
         }
60 60
 
61
-        if ($this->extPaginate = $this->getExtender('paginate')) {
61
+        if ($this->extPaginate = $this->getExtender('paginate')) {
62 62
             $this->extPaginate->init($this);
63
-        } else {
63
+        } else {
64 64
             $this->config->setConfig(array('start' => 0));
65 65
         }
66 66
         $type = $this->getCFGDef('idType', 'parents');
67 67
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
68
-        if ($tvlist != '' && count($this->_docs) > 0) {
68
+        if ($tvlist != '' && count($this->_docs) > 0) {
69 69
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
70
-            if (!is_array($tv)) {
70
+            if (!is_array($tv)) {
71 71
                 $tv = array();
72 72
             }
73
-            foreach ($tv as $docID => $TVitem) {
74
-                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
73
+            foreach ($tv as $docID => $TVitem) {
74
+                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
75 75
                     $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);
76
-                } else {
76
+                } else {
77 77
                     unset($this->_docs[$docID]);
78 78
                 }
79 79
             }
80 80
         }
81
-        if (1 == $this->getCFGDef('tree', '0')) {
81
+        if (1 == $this->getCFGDef('tree', '0')) {
82 82
             $this->treeBuild('id', 'parent');
83 83
         }
84 84
 
@@ -89,22 +89,22 @@  discard block
 block discarded – undo
89 89
      * @param string $tpl
90 90
      * @return string
91 91
      */
92
-    public function _render($tpl = '')
93
-    {
92
+    public function _render($tpl = '')
93
+    {
94 94
         $out = '';
95
-        if ($tpl == '') {
95
+        if ($tpl == '') {
96 96
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
97 97
         }
98
-        if ($tpl != '') {
98
+        if ($tpl != '') {
99 99
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
100 100
 
101 101
             $i = 1;
102 102
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
103
-            if (count($this->_docs) > 0) {
103
+            if (count($this->_docs) > 0) {
104 104
                 /**
105 105
                  * @var $extUser user_DL_Extender
106 106
                  */
107
-                if ($extUser = $this->getExtender('user')) {
107
+                if ($extUser = $this->getExtender('user')) {
108 108
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
109 109
                 }
110 110
 
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                 $extPrepare = $this->getExtender('prepare');
120 120
 
121 121
                 $this->skippedDocs = 0;
122
-                foreach ($this->_docs as $item) {
122
+                foreach ($this->_docs as $item) {
123 123
                     $this->renderTPL = $tpl;
124
-                    if ($extUser) {
124
+                    if ($extUser) {
125 125
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
126 126
                     }
127 127
 
@@ -133,24 +133,24 @@  discard block
 block discarded – undo
133 133
 
134 134
                     $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);
135 135
 
136
-                    if ($this->getCFGDef('makeUrl', 1)) {
137
-                        if ($item['type'] == 'reference') {
136
+                    if ($this->getCFGDef('makeUrl', 1)) {
137
+                        if ($item['type'] == 'reference') {
138 138
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
139 139
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
140
-                        } else {
140
+                        } else {
141 141
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
142 142
                         }
143 143
                     }
144 144
                     $date = $this->getCFGDef('dateSource', 'pub_date');
145
-                    if (isset($item[$date])) {
146
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
145
+                    if (isset($item[$date])) {
146
+                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
147 147
                             $date = 'createdon';
148 148
                         }
149 149
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
150
-                        if ($_date !== false) {
150
+                        if ($_date !== false) {
151 151
                             $_date = $_date + $this->modx->config['server_offset_time'];
152 152
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
153
-                            if ($dateFormat) {
153
+                            if ($dateFormat) {
154 154
                                 $item['date'] = strftime($dateFormat, $_date);
155 155
                             }
156 156
                         }
@@ -159,30 +159,30 @@  discard block
 block discarded – undo
159 159
                     $findTpl = $this->renderTPL;
160 160
                     $tmp = $this->uniformPrepare($item, $i);
161 161
                     extract($tmp, EXTR_SKIP);
162
-                    if ($this->renderTPL == '') {
162
+                    if ($this->renderTPL == '') {
163 163
                         $this->renderTPL = $findTpl;
164 164
                     }
165 165
 
166
-                    if ($extPrepare) {
166
+                    if ($extPrepare) {
167 167
                         $item = $extPrepare->init($this, array(
168 168
                             'data'      => $item,
169 169
                             'nameParam' => 'prepare'
170 170
                         ));
171
-                        if (is_bool($item) && $item === false) {
171
+                        if (is_bool($item) && $item === false) {
172 172
                             $this->skippedDocs++;
173 173
                             continue;
174 174
                         }
175 175
                     }
176 176
                     $tmp = $this->parseChunk($this->renderTPL, $item);
177 177
 
178
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
178
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
179 179
                         $this->toPlaceholders($tmp, 1,
180 180
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
181 181
                     }
182 182
                     $out .= $tmp;
183 183
                     $i++;
184 184
                 }
185
-            } else {
185
+            } else {
186 186
                 $noneTPL = $this->getCFGDef("noneTPL", "");
187 187
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
188 188
             }
@@ -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');
@@ -218,50 +218,50 @@  discard block
 block discarded – undo
218 218
          */
219 219
         $extE = $this->getExtender('e', true, true);
220 220
 
221
-        foreach ($data as $num => $row) {
222
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
221
+        foreach ($data as $num => $row) {
222
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
223 223
                 $row['summary'] = $this->getSummary($row, $extSummary, 'introtext', 'content');
224 224
             }
225 225
 
226
-            if (array('1') == $fields || in_array('date', $fields)) {
227
-                if (isset($row[$date])) {
228
-                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
226
+            if (array('1') == $fields || in_array('date', $fields)) {
227
+                if (isset($row[$date])) {
228
+                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
229 229
                         $date = 'createdon';
230 230
                     }   
231 231
                     $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
232
-                    if ($_date !== false) {
232
+                    if ($_date !== false) {
233 233
                         $_date = $_date + $this->modx->config['server_offset_time'];
234 234
                         $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
235
-                        if ($dateFormat) {
235
+                        if ($dateFormat) {
236 236
                             $row['date'] = strftime($dateFormat, $_date);
237 237
                         }
238 238
                     }
239 239
                 }
240 240
             }
241 241
 
242
-            if (array('1') == $fields || in_array('title', $fields)) {
243
-                if (isset($row['pagetitle'])) {
242
+            if (array('1') == $fields || in_array('title', $fields)) {
243
+                if (isset($row['pagetitle'])) {
244 244
                     $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle'];
245 245
                 }
246 246
             }
247 247
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields))
248
-            ) {
249
-                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
248
+            ) {
249
+                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
250 250
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
251 251
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
252
-                } elseif (isset($row['id'])) {
252
+                } elseif (isset($row['id'])) {
253 253
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
254 254
                 }
255 255
             }
256
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
257
-                if (is_array($tmp)) {
256
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
257
+                if (is_array($tmp)) {
258 258
                     $row = $tmp;
259 259
                 }
260 260
             }
261 261
 
262
-            if ($extPrepare) {
262
+            if ($extPrepare) {
263 263
                 $row = $extPrepare->init($this, array('data' => $row));
264
-                if (is_bool($row) && $row === false) {
264
+                if (is_bool($row) && $row === false) {
265 265
                     continue;
266 266
                 }
267 267
             }
@@ -274,36 +274,35 @@  discard block
 block discarded – undo
274 274
     /**
275 275
      * @abstract
276 276
      */
277
-    public function getChildrenCount()
278
-    {
277
+    public function getChildrenCount()
278
+    {
279 279
         $out = 0;
280 280
         $sanitarInIDs = $this->sanitarIn($this->IDs);
281
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
281
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
282 282
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
283 283
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
284 284
             $where = $this->getCFGDef('addWhereList', '');
285 285
             $where = sqlHelper::trimLogicalOp($where);
286 286
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
287
-            if ($where != '' && $this->_filters['where'] != '') {
287
+            if ($where != '' && $this->_filters['where'] != '') {
288 288
                 $where .= " AND ";
289 289
             }
290 290
             $where = sqlHelper::trimLogicalOp($where);
291 291
 
292 292
             $where = "WHERE {$where}";
293 293
             $whereArr = array();
294
-            if (!$this->getCFGDef('showNoPublish', 0)) {
294
+            if (!$this->getCFGDef('showNoPublish', 0)) {
295 295
                 $whereArr[] = "c.deleted=0 AND c.published=1";
296
-            }
297
-            else{
296
+            } else {
298 297
                 $q_true = 1;
299 298
             }
300 299
 
301 300
             $tbl_site_content = $this->getTable('site_content', 'c');
302 301
 
303
-            if ($sanitarInIDs != "''") {
304
-                switch ($this->getCFGDef('idType', 'parents')) {
302
+            if ($sanitarInIDs != "''") {
303
+                switch ($this->getCFGDef('idType', 'parents')) {
305 304
                     case 'parents':
306
-                        switch ($this->getCFGDef('showParent', '0')) {
305
+                        switch ($this->getCFGDef('showParent', '0')) {
307 306
                             case '-1':
308 307
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
309 308
                                 break;
@@ -315,10 +314,10 @@  discard block
 block discarded – undo
315 314
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
316 315
                                 break;
317 316
                         }
318
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
317
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
319 318
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
320 319
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
321
-                        } else {
320
+                        } else {
322 321
                             $whereArr[] = $tmpWhere;
323 322
                         }
324 323
 
@@ -333,26 +332,25 @@  discard block
 block discarded – undo
333 332
 
334 333
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
335 334
 
336
-            if (trim($where) != 'WHERE') {
335
+            if (trim($where) != 'WHERE') {
337 336
                 $where .= " AND ";
338 337
             }
339 338
 
340 339
             $where .= implode(" AND ", $whereArr);
341 340
             $where = sqlHelper::trimLogicalOp($where);
342 341
 
343
-            if (trim($where) == 'WHERE') {
342
+            if (trim($where) == 'WHERE') {
344 343
                 $where = '';
345 344
             }
346 345
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
347 346
 
348 347
             $q_true = $q_true ? $q_true : $group != '';
349
-            if ( $q_true ){
348
+            if ( $q_true ) {
350 349
                 $maxDocs = $this->getCFGDef('maxDocs', 0);
351 350
                 $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : '';
352 351
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`");
353 352
                 $out = $this->modx->db->getValue($rs);
354
-            }
355
-            else {
353
+            } else {
356 354
                 $out = count($this->IDs);
357 355
             }
358 356
         }
@@ -363,11 +361,11 @@  discard block
 block discarded – undo
363 361
     /**
364 362
      * @return array
365 363
      */
366
-    protected function getDocList()
367
-    {
364
+    protected function getDocList()
365
+    {
368 366
         $out = array();
369 367
         $sanitarInIDs = $this->sanitarIn($this->IDs);
370
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
368
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
371 369
             $where = $this->getCFGDef('addWhereList', '');
372 370
             $where = sqlHelper::trimLogicalOp($where);
373 371
 
@@ -375,21 +373,21 @@  discard block
 block discarded – undo
375 373
             $where = sqlHelper::trimLogicalOp($where);
376 374
 
377 375
             $tbl_site_content = $this->getTable('site_content', 'c');
378
-            if ($sanitarInIDs != "''") {
376
+            if ($sanitarInIDs != "''") {
379 377
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
380 378
             }
381 379
             $where = sqlHelper::trimLogicalOp($where);
382 380
 
383
-            if ($this->getCFGDef('showNoPublish', 0)) {
384
-                if ($where != '') {
381
+            if ($this->getCFGDef('showNoPublish', 0)) {
382
+                if ($where != '') {
385 383
                     $where = "WHERE {$where}";
386
-                } else {
384
+                } else {
387 385
                     $where = '';
388 386
                 }
389
-            } else {
390
-                if ($where != '') {
387
+            } else {
388
+                if ($where != '') {
391 389
                     $where = "WHERE {$where} AND ";
392
-                } else {
390
+                } else {
393 391
                     $where = "WHERE {$where} ";
394 392
                 }
395 393
                 $where .= "c.deleted=0 AND c.published=1";
@@ -406,7 +404,7 @@  discard block
 block discarded – undo
406 404
 
407 405
             $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
408 406
 
409
-            while ($item = $this->modx->db->getRow($rs)) {
407
+            while ($item = $this->modx->db->getRow($rs)) {
410 408
                 $out[$item['id']] = $item;
411 409
             };
412 410
         }
@@ -418,26 +416,26 @@  discard block
 block discarded – undo
418 416
      * @param string $id
419 417
      * @return array
420 418
      */
421
-    public function getChildrenFolder($id)
422
-    {
419
+    public function getChildrenFolder($id)
420
+    {
423 421
         $out = array();
424 422
         $where = $this->getCFGDef('addWhereFolder', '');
425 423
         $where = sqlHelper::trimLogicalOp($where);
426
-        if ($where != '') {
424
+        if ($where != '') {
427 425
             $where .= " AND ";
428 426
         }
429 427
 
430 428
         $tbl_site_content = $this->getTable('site_content', 'c');
431 429
         $sanitarInIDs = $this->sanitarIn($id);
432
-        if ($this->getCFGDef('showNoPublish', 0)) {
430
+        if ($this->getCFGDef('showNoPublish', 0)) {
433 431
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
434
-        } else {
432
+        } else {
435 433
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
436 434
         }
437 435
 
438 436
         $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
439 437
 
440
-        while ($item = $this->modx->db->getRow($rs)) {
438
+        while ($item = $this->modx->db->getRow($rs)) {
441 439
             $out[] = $item['id'];
442 440
         }
443 441
 
@@ -449,10 +447,10 @@  discard block
 block discarded – undo
449 447
      * @param $sort
450 448
      * @return array
451 449
      */
452
-    protected function injectSortByTV($table, $sort)
453
-    {
450
+    protected function injectSortByTV($table, $sort)
451
+    {
454 452
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
455
-        if (!is_array($out) || empty($out)) {
453
+        if (!is_array($out) || empty($out)) {
456 454
             $out = array($table, $sort);
457 455
         }
458 456
 
@@ -462,19 +460,19 @@  discard block
 block discarded – undo
462 460
     /**
463 461
      * @return array
464 462
      */
465
-    protected function getChildrenList()
466
-    {
463
+    protected function getChildrenList()
464
+    {
467 465
         $where = array();
468 466
         $out = array();
469 467
 
470 468
         $tmpWhere = $this->getCFGDef('addWhereList', '');
471 469
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
472
-        if (!empty($tmpWhere)) {
470
+        if (!empty($tmpWhere)) {
473 471
             $where[] = $tmpWhere;
474 472
         }
475 473
 
476 474
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
477
-        if (!empty($tmpWhere)) {
475
+        if (!empty($tmpWhere)) {
478 476
             $where[] = $tmpWhere;
479 477
         }
480 478
 
@@ -485,8 +483,8 @@  discard block
 block discarded – undo
485 483
         $sanitarInIDs = $this->sanitarIn($this->IDs);
486 484
 
487 485
         $tmpWhere = null;
488
-        if ($sanitarInIDs != "''") {
489
-            switch ($this->getCFGDef('showParent', '0')) {
486
+        if ($sanitarInIDs != "''") {
487
+            switch ($this->getCFGDef('showParent', '0')) {
490 488
                 case '-1':
491 489
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
492 490
                     break;
@@ -499,36 +497,36 @@  discard block
 block discarded – undo
499 497
                     break;
500 498
             }
501 499
         }
502
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
500
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
503 501
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
504
-            if (empty($tmpWhere)) {
502
+            if (empty($tmpWhere)) {
505 503
                 $tmpWhere = "c.id IN({$addDocs})";
506
-            } else {
504
+            } else {
507 505
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
508 506
             }
509 507
         }
510
-        if (!empty($tmpWhere)) {
508
+        if (!empty($tmpWhere)) {
511 509
             $where[] = $tmpWhere;
512 510
         }
513
-        if (!$this->getCFGDef('showNoPublish', 0)) {
511
+        if (!$this->getCFGDef('showNoPublish', 0)) {
514 512
             $where[] = "c.deleted=0 AND c.published=1";
515 513
         }
516
-        if (!empty($where)) {
514
+        if (!empty($where)) {
517 515
             $where = "WHERE " . implode(" AND ", $where);
518
-        } else {
516
+        } else {
519 517
             $where = '';
520 518
         }
521 519
         $fields = $this->getCFGDef('selectFields', 'c.*');
522 520
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
523 521
 
524
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
522
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
525 523
             $rs = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
526 524
                 $group . " " .
527 525
                 $sort . " " .
528 526
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
529 527
             );
530 528
 
531
-            while ($item = $this->modx->db->getRow($rs)) {
529
+            while ($item = $this->modx->db->getRow($rs)) {
532 530
                 $out[$item['id']] = $item;
533 531
             }
534 532
         }
@@ -541,10 +539,10 @@  discard block
 block discarded – undo
541 539
      * @param string $type
542 540
      * @return string
543 541
      */
544
-    public function changeSortType($field, $type)
545
-    {
542
+    public function changeSortType($field, $type)
543
+    {
546 544
         $type = trim($type);
547
-        switch (strtoupper($type)) {
545
+        switch (strtoupper($type)) {
548 546
             case 'TVDATETIME':
549 547
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
550 548
                 break;
Please login to merge, or discard this patch.