Completed
Push — master ( f718f9...3ab9ab )
by
unknown
02:15
created
assets/snippets/DocLister/core/controller/onetable.php 1 patch
Braces   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             $where = $this->getCFGDef('addWhereList', '');
216 216
             
217 217
            	//====== block added by Dreamer to enable filters ======
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
         	//------- end of block -------
221 221
 
222 222
             
223
-            if ($where != '') {
223
+            if ($where != '') {
224 224
                 $where = array($where);
225 225
             }
226
-            if ($sanitarInIDs != "''") {
226
+            if ($sanitarInIDs != "''") {
227 227
                 $where[] = "{$this->getPK()} IN ({$sanitarInIDs})";
228 228
             }
229 229
 
230
-            if (!empty($where)) {
230
+            if (!empty($where)) {
231 231
                 $where = "WHERE " . implode(" AND ", $where);
232 232
             }
233 233
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}");
237 237
 
238 238
             $pk = $this->getPK(false);
239
-            while ($item = $this->modx->db->getRow($rs)) {
239
+            while ($item = $this->modx->db->getRow($rs)) {
240 240
                 $out[$item[$pk]] = $item;
241 241
             }
242 242
         }
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
     /**
248 248
      * @return array
249 249
      */
250
-    protected function getChildrenList()
251
-    {
250
+    protected function getChildrenList()
251
+    {
252 252
         $where = array();
253 253
         $out = array();
254 254
 
@@ -261,15 +261,15 @@  discard block
 block discarded – undo
261 261
 	    //------- end of block -------
262 262
         
263 263
         
264
-        if (!empty($tmpWhere)) {
264
+        if (!empty($tmpWhere)) {
265 265
             $where[] = $tmpWhere;
266 266
         }
267 267
         $sanitarInIDs = $this->sanitarIn($this->IDs);
268 268
 
269 269
         $tmpWhere = null;
270
-        if ($sanitarInIDs != "''") {
270
+        if ($sanitarInIDs != "''") {
271 271
             $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")";
272
-            switch ($this->getCFGDef('showParent', '0')) {
272
+            switch ($this->getCFGDef('showParent', '0')) {
273 273
                 case -1:
274 274
                     $tmpWhere .= ")";
275 275
                     break;
@@ -282,25 +282,25 @@  discard block
 block discarded – undo
282 282
                     break;
283 283
             }
284 284
         }
285
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
285
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
286 286
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
287
-            if (empty($tmpWhere)) {
287
+            if (empty($tmpWhere)) {
288 288
                 $tmpWhere = $this->getPK() . " IN({$addDocs})";
289
-            } else {
289
+            } else {
290 290
                 $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
291 291
             }
292 292
         }
293
-        if (!empty($tmpWhere)) {
293
+        if (!empty($tmpWhere)) {
294 294
             $where[] = $tmpWhere;
295 295
         }
296
-        if (!empty($where)) {
296
+        if (!empty($where)) {
297 297
             $where = "WHERE " . implode(" AND ", $where);
298
-        } else {
298
+        } else {
299 299
             $where = '';
300 300
         }
301 301
         $fields = $this->getCFGDef('selectFields', '*');
302 302
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
303
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
303
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
304 304
             $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " .
305 305
                 $group . " " .
306 306
                 $this->SortOrderSQL($this->getPK()) . " " .
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             $where = $this->getCFGDef('addWhereList', '');
330 330
             
331 331
         	//====== block added by Dreamer ======
@@ -333,16 +333,16 @@  discard block
 block discarded – undo
333 333
             $where = sqlHelper::trimLogicalOp($where);
334 334
 	        //------- end of block -------
335 335
             
336
-            if ($where != '') {
336
+            if ($where != '') {
337 337
                 $where = array($where);
338
-            } else {
338
+            } else {
339 339
                 $where = array();
340 340
             }
341
-            if ($sanitarInIDs != "''") {
342
-                if ($sanitarInIDs != "''") {
343
-                    switch ($this->getCFGDef('idType', 'parents')) {
341
+            if ($sanitarInIDs != "''") {
342
+                if ($sanitarInIDs != "''") {
343
+                    switch ($this->getCFGDef('idType', 'parents')) {
344 344
                         case 'parents':
345
-                            switch ($this->getCFGDef('showParent', '0')) {
345
+                            switch ($this->getCFGDef('showParent', '0')) {
346 346
                                 case '-1':
347 347
                                     $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})";
348 348
                                     break;
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
                                     $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))";
355 355
                                     break;
356 356
                             }
357
-                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
357
+                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
358 358
                                 $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
359 359
                                 $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
360
-                            } else {
360
+                            } else {
361 361
                                 $where[] = $tmpWhere;
362 362
                             }
363 363
                             break;
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
                     }
368 368
                 }
369 369
             }
370
-            if (!empty($where)) {
370
+            if (!empty($where)) {
371 371
                 $where = "WHERE " . implode(" AND ", $where);
372
-            } else {
372
+            } else {
373 373
                 $where = '';
374 374
             }
375 375
 
@@ -387,20 +387,20 @@  discard block
 block discarded – undo
387 387
      * @param string $id
388 388
      * @return array
389 389
      */
390
-    public function getChildrenFolder($id)
391
-    {
390
+    public function getChildrenFolder($id)
391
+    {
392 392
         $out = array();
393 393
         $sanitarInIDs = $this->sanitarIn($id);
394 394
 
395 395
         $tmp = $this->getCFGDef('addWhereFolder', '');
396 396
         $where = "{$this->getParentField()} IN ({$sanitarInIDs})";
397
-        if (!empty($tmp)) {
397
+        if (!empty($tmp)) {
398 398
             $where .= " AND " . $tmp;
399 399
         }
400 400
 
401 401
         $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}");
402 402
         $pk = $this->getPK(false);
403
-        while ($item = $this->modx->db->getRow($rs)) {
403
+        while ($item = $this->modx->db->getRow($rs)) {
404 404
             $out[] = $item[$pk];
405 405
         }
406 406
 
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/controller/site_content.php 1 patch
Braces   +108 added lines, -110 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
8 8
  * @author Agel_Nash <[email protected]>, kabachello <[email protected]>
9 9
  */
10
-class site_contentDocLister extends DocLister
11
-{
10
+class site_contentDocLister extends DocLister
11
+{
12 12
     /**
13 13
      * Экземпляр экстендера TV
14 14
      *
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
      * @param array $cfg
29 29
      * @param null $startTime
30 30
      */
31
-    public function __construct($modx, $cfg = array(), $startTime = null)
32
-    {
31
+    public function __construct($modx, $cfg = array(), $startTime = null)
32
+    {
33 33
         parent::__construct($modx, $cfg, $startTime);
34 34
         $this->extTV = $this->getExtender('tv', true, true);
35 35
     }
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
     /**
38 38
      * @absctract
39 39
      */
40
-    public function getDocs($tvlist = '')
41
-    {
42
-        if ($tvlist == '') {
40
+    public function getDocs($tvlist = '')
41
+    {
42
+        if ($tvlist == '') {
43 43
             $tvlist = $this->getCFGDef('tvList', '');
44 44
         }
45 45
         
@@ -50,31 +50,31 @@  discard block
 block discarded – undo
50 50
          */
51 51
         $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
52 52
 
53
-        if ($extJotCount) {
53
+        if ($extJotCount) {
54 54
             $extJotCount->init($this);
55 55
         }
56 56
 
57
-        if ($this->extPaginate = $this->getExtender('paginate')) {
57
+        if ($this->extPaginate = $this->getExtender('paginate')) {
58 58
             $this->extPaginate->init($this);
59
-        } else {
59
+        } else {
60 60
             $this->config->setConfig(array('start' => 0));
61 61
         }
62 62
         $type = $this->getCFGDef('idType', 'parents');
63 63
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
64
-        if ($tvlist != '' && count($this->_docs) > 0) {
64
+        if ($tvlist != '' && count($this->_docs) > 0) {
65 65
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
66
-            if (!is_array($tv)) {
66
+            if (!is_array($tv)) {
67 67
                 $tv = array();
68 68
             }
69
-            foreach ($tv as $docID => $TVitem) {
70
-                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
69
+            foreach ($tv as $docID => $TVitem) {
70
+                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
71 71
                     $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);
72
-                } else {
72
+                } else {
73 73
                     unset($this->_docs[$docID]);
74 74
                 }
75 75
             }
76 76
         }
77
-        if (1 == $this->getCFGDef('tree', '0')) {
77
+        if (1 == $this->getCFGDef('tree', '0')) {
78 78
             $this->treeBuild('id', 'parent');
79 79
         }
80 80
 
@@ -85,23 +85,23 @@  discard block
 block discarded – undo
85 85
      * @param string $tpl
86 86
      * @return string
87 87
      */
88
-    public function _render($tpl = '')
89
-    {
88
+    public function _render($tpl = '')
89
+    {
90 90
         $out = '';
91 91
         $separator = $this->getCFGDef('outputSeparator', '');
92
-        if ($tpl == '') {
92
+        if ($tpl == '') {
93 93
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
94 94
         }
95
-        if ($tpl != '') {
95
+        if ($tpl != '') {
96 96
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
97 97
 
98 98
             $i = 1;
99 99
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
100
-            if (count($this->_docs) > 0) {
100
+            if (count($this->_docs) > 0) {
101 101
                 /**
102 102
                  * @var $extUser user_DL_Extender
103 103
                  */
104
-                if ($extUser = $this->getExtender('user')) {
104
+                if ($extUser = $this->getExtender('user')) {
105 105
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
106 106
                 }
107 107
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
                 $extPrepare = $this->getExtender('prepare');
117 117
 
118 118
                 $this->skippedDocs = 0;
119
-                foreach ($this->_docs as $item) {
119
+                foreach ($this->_docs as $item) {
120 120
                     $this->renderTPL = $tpl;
121
-                    if ($extUser) {
121
+                    if ($extUser) {
122 122
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
123 123
                     }
124 124
 
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
 
131 131
                     $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);
132 132
 
133
-                    if ($this->getCFGDef('makeUrl', 1)) {
134
-                        if ($item['type'] == 'reference') {
133
+                    if ($this->getCFGDef('makeUrl', 1)) {
134
+                        if ($item['type'] == 'reference') {
135 135
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
136 136
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
137
-                        } else {
137
+                        } else {
138 138
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
139 139
                         }
140 140
                     }
141 141
                     $date = $this->getCFGDef('dateSource', 'pub_date');
142
-                    if (isset($item[$date])) {
143
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
142
+                    if (isset($item[$date])) {
143
+                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
144 144
                             $date = 'createdon';
145 145
                         }
146 146
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
147
-                        if ($_date !== false) {
147
+                        if ($_date !== false) {
148 148
                             $_date = $_date + $this->modx->config['server_offset_time'];
149 149
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
150
-                            if ($dateFormat) {
150
+                            if ($dateFormat) {
151 151
                                 $item['date'] = strftime($dateFormat, $_date);
152 152
                             }
153 153
                         }
@@ -156,33 +156,33 @@  discard block
 block discarded – undo
156 156
                     $findTpl = $this->renderTPL;
157 157
                     $tmp = $this->uniformPrepare($item, $i);
158 158
                     extract($tmp, EXTR_SKIP);
159
-                    if ($this->renderTPL == '') {
159
+                    if ($this->renderTPL == '') {
160 160
                         $this->renderTPL = $findTpl;
161 161
                     }
162 162
 
163
-                    if ($extPrepare) {
163
+                    if ($extPrepare) {
164 164
                         $item = $extPrepare->init($this, array(
165 165
                             'data'      => $item,
166 166
                             'nameParam' => 'prepare'
167 167
                         ));
168
-                        if (is_bool($item) && $item === false) {
168
+                        if (is_bool($item) && $item === false) {
169 169
                             $this->skippedDocs++;
170 170
                             continue;
171 171
                         }
172 172
                     }
173 173
                     $tmp = $this->parseChunk($this->renderTPL, $item);
174 174
 
175
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
175
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
176 176
                         $this->toPlaceholders($tmp, 1,
177 177
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
178 178
                     }
179 179
                     $out .= $tmp;
180
-                    if (next($this->_docs) !== false) {
180
+                    if (next($this->_docs) !== false) {
181 181
                         $out .= $separator;
182 182
                     }
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.
assets/snippets/DocLister/core/controller/shopkeeper.php 1 patch
Braces   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Class shopkeeperDocLister
14 14
  */
15
-class shopkeeperDocLister extends site_contentDocLister
16
-{
15
+class shopkeeperDocLister extends site_contentDocLister
16
+{
17 17
     /**
18 18
      * shopkeeperDocLister constructor.
19 19
      * @param $modx
20 20
      * @param array $cfg
21 21
      * @param null $startTime
22 22
      */
23
-    public function __construct($modx, $cfg = array(), $startTime = null)
24
-    {
23
+    public function __construct($modx, $cfg = array(), $startTime = null)
24
+    {
25 25
         $cfg = array_merge(array('tvValuesTable' => 'catalog_tmplvar_contentvalues'), $cfg);
26 26
         parent::__construct($modx, $cfg, $startTime);
27 27
     }
@@ -30,23 +30,23 @@  discard block
 block discarded – undo
30 30
      * @param string $tpl
31 31
      * @return string
32 32
      */
33
-    public function _render($tpl = '')
34
-    {
33
+    public function _render($tpl = '')
34
+    {
35 35
         $out = '';
36 36
         $separator = $this->getCFGDef('outputSeparator', '');
37
-        if ($tpl == '') {
37
+        if ($tpl == '') {
38 38
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
39 39
         }
40
-        if ($tpl != '') {
40
+        if ($tpl != '') {
41 41
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
42 42
 
43 43
             $i = 1;
44 44
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
45
-            if (count($this->_docs) > 0) {
45
+            if (count($this->_docs) > 0) {
46 46
                 /**
47 47
                  * @var $extUser user_DL_Extender
48 48
                  */
49
-                if ($extUser = $this->getExtender('user')) {
49
+                if ($extUser = $this->getExtender('user')) {
50 50
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
51 51
                 }
52 52
 
@@ -65,20 +65,20 @@  discard block
 block discarded – undo
65 65
                  */
66 66
                 $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
67 67
 
68
-                if ($extJotCount) {
68
+                if ($extJotCount) {
69 69
                     $comments = $extJotCount->countComments(array_keys($this->_docs));
70 70
                 }
71 71
 
72 72
                 $this->skippedDocs = 0;
73
-                foreach ($this->_docs as $item) {
73
+                foreach ($this->_docs as $item) {
74 74
                     $this->renderTPL = $tpl;
75
-                    if ($extUser) {
75
+                    if ($extUser) {
76 76
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
77 77
                     }
78 78
 
79 79
                     $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, '', 'content') : '';
80 80
 
81
-                    if ($extJotCount) {
81
+                    if ($extJotCount) {
82 82
                         $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0);
83 83
                     }
84 84
 
@@ -86,50 +86,50 @@  discard block
 block discarded – undo
86 86
                         $sysPlh); //inside the chunks available all placeholders set via $modx->toPlaceholders with prefix id, and with prefix sysKey
87 87
                     $item['iteration'] = $i; //[+iteration+] - Number element. Starting from zero
88 88
 
89
-                    if ($this->getCFGDef('makeUrl', 1)) {
90
-                        if ($item['type'] == 'reference') {
89
+                    if ($this->getCFGDef('makeUrl', 1)) {
90
+                        if ($item['type'] == 'reference') {
91 91
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
92 92
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
93
-                        } else {
93
+                        } else {
94 94
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
95 95
                         }
96 96
                     }
97 97
 
98 98
                     $item['date'] = $item['createdon'] + $this->modx->config['server_offset_time'];
99
-                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
99
+                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
100 100
                         $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $item['date']);
101 101
                     }
102 102
 
103 103
                     $findTpl = $this->renderTPL;
104 104
                     $tmp = $this->uniformPrepare($item, $i);
105 105
                     extract($tmp, EXTR_SKIP);
106
-                    if ($this->renderTPL == '') {
106
+                    if ($this->renderTPL == '') {
107 107
                         $this->renderTPL = $findTpl;
108 108
                     }
109 109
 
110
-                    if ($extPrepare) {
110
+                    if ($extPrepare) {
111 111
                         $item = $extPrepare->init($this, array(
112 112
                             'data'      => $item,
113 113
                             'nameParam' => 'prepare'
114 114
                         ));
115
-                        if (is_bool($item) && $item === false) {
115
+                        if (is_bool($item) && $item === false) {
116 116
                             $this->skippedDocs++;
117 117
                             continue;
118 118
                         }
119 119
                     }
120 120
                     $tmp = $this->parseChunk($this->renderTPL, $item);
121 121
 
122
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
122
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
123 123
                         $this->toPlaceholders($tmp, 1,
124 124
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
125 125
                     }
126 126
                     $out .= $tmp;
127
-                    if (next($this->_docs) !== false) {
127
+                    if (next($this->_docs) !== false) {
128 128
                         $out .= $separator;
129 129
                     }
130 130
                     $i++;
131 131
                 }
132
-            } else {
132
+            } else {
133 133
                 $noneTPL = $this->getCFGDef("noneTPL", "");
134 134
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
135 135
             }
@@ -142,31 +142,31 @@  discard block
 block discarded – undo
142 142
     /**
143 143
      * @absctract
144 144
      */
145
-    public function getChildrenCount()
146
-    {
145
+    public function getChildrenCount()
146
+    {
147 147
         $out = 0;
148 148
         $sanitarInIDs = $this->sanitarIn($this->IDs);
149
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
149
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
150 150
             $where = $this->getCFGDef('addWhereList', '');
151 151
             $where = sqlHelper::trimLogicalOp($where);
152 152
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
153
-            if ($where != '' && $this->_filters['where'] != '') {
153
+            if ($where != '' && $this->_filters['where'] != '') {
154 154
                 $where .= " AND ";
155 155
             }
156 156
             $where = sqlHelper::trimLogicalOp($where);
157 157
 
158 158
             $where = "WHERE {$where}";
159 159
             $whereArr = array();
160
-            if (!$this->getCFGDef('showNoPublish', 0)) {
160
+            if (!$this->getCFGDef('showNoPublish', 0)) {
161 161
                 $whereArr[] = "c.published=1";
162 162
             }
163 163
 
164 164
             $tbl_site_content = $this->getTable('catalog', 'c');
165 165
 
166
-            if ($sanitarInIDs != "''") {
167
-                switch ($this->getCFGDef('idType', 'parents')) {
166
+            if ($sanitarInIDs != "''") {
167
+                switch ($this->getCFGDef('idType', 'parents')) {
168 168
                     case 'parents':
169
-                        switch ($this->getCFGDef('showParent', '0')) {
169
+                        switch ($this->getCFGDef('showParent', '0')) {
170 170
                             case '-1':
171 171
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
172 172
                                 break;
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
179 179
                                 break;
180 180
                         }
181
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
181
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
182 182
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
183 183
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
184
-                        } else {
184
+                        } else {
185 185
                             $whereArr[] = $tmpWhere;
186 186
                         }
187 187
                         break;
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
             $from = $tbl_site_content . " " . $this->_filters['join'];
194 194
             $where = sqlHelper::trimLogicalOp($where);
195 195
 
196
-            if (trim($where) != 'WHERE') {
196
+            if (trim($where) != 'WHERE') {
197 197
                 $where .= " AND ";
198 198
             }
199 199
 
200 200
             $where .= implode(" AND ", $whereArr);
201 201
             $where = sqlHelper::trimLogicalOp($where);
202 202
 
203
-            if (trim($where) == 'WHERE') {
203
+            if (trim($where) == 'WHERE') {
204 204
                 $where = '';
205 205
             }
206 206
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
     /**
218 218
      * @return array
219 219
      */
220
-    protected function getDocList()
221
-    {
220
+    protected function getDocList()
221
+    {
222 222
         $out = array();
223 223
         $sanitarInIDs = $this->sanitarIn($this->IDs);
224
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
224
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
225 225
             $where = $this->getCFGDef('addWhereList', '');
226 226
             $where = sqlHelper::trimLogicalOp($where);
227 227
 
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
             $where = sqlHelper::trimLogicalOp($where);
230 230
 
231 231
             $tbl_site_content = $this->getTable('catalog', 'c');
232
-            if ($sanitarInIDs != "''") {
232
+            if ($sanitarInIDs != "''") {
233 233
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
234 234
             }
235 235
             $where = sqlHelper::trimLogicalOp($where);
236 236
 
237
-            if ($this->getCFGDef('showNoPublish', 0)) {
238
-                if ($where != '') {
237
+            if ($this->getCFGDef('showNoPublish', 0)) {
238
+                if ($where != '') {
239 239
                     $where = "WHERE {$where}";
240
-                } else {
240
+                } else {
241 241
                     $where = '';
242 242
                 }
243
-            } else {
244
-                if ($where != '') {
243
+            } else {
244
+                if ($where != '') {
245 245
                     $where = "WHERE {$where} AND ";
246
-                } else {
246
+                } else {
247 247
                     $where = "WHERE {$where} ";
248 248
                 }
249 249
                 $where .= "c.published=1";
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
             $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
262 262
 
263
-            while ($item = $this->modx->db->getRow($rs)) {
263
+            while ($item = $this->modx->db->getRow($rs)) {
264 264
                 $out[$item['id']] = $item;
265 265
             }
266 266
         }
@@ -272,27 +272,27 @@  discard block
 block discarded – undo
272 272
      * @param $id
273 273
      * @return array
274 274
      */
275
-    public function getChildrenFolder($id)
276
-    {
275
+    public function getChildrenFolder($id)
276
+    {
277 277
         $out = array();
278 278
         $where = $this->getCFGDef('addWhereFolder', '');
279 279
         $where = sqlHelper::trimLogicalOp($where);
280
-        if ($where != '') {
280
+        if ($where != '') {
281 281
             $where .= " AND ";
282 282
         }
283 283
 
284 284
         $tbl_site_content = $this->getTable('site_content', 'c');
285 285
         $sanitarInIDs = $this->sanitarIn($id);
286
-        if ($this->getCFGDef('showNoPublish', 0)) {
286
+        if ($this->getCFGDef('showNoPublish', 0)) {
287 287
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}";
288
-        } else {
288
+        } else {
289 289
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1";
290 290
         }
291 291
 
292 292
         $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where} AND c.id IN(SELECT DISTINCT s.parent FROM " . $this->getTable('catalog',
293 293
                 's') . ")");
294 294
 
295
-        while ($item = $this->modx->db->getRow($rs)) {
295
+        while ($item = $this->modx->db->getRow($rs)) {
296 296
             $out[] = $item['id'];
297 297
         }
298 298
 
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
     /**
303 303
      * @return array
304 304
      */
305
-    protected function getChildrenList()
306
-    {
305
+    protected function getChildrenList()
306
+    {
307 307
         $where = array();
308 308
         $out = array();
309 309
 
310 310
         $tmpWhere = $this->getCFGDef('addWhereList', '');
311 311
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
312
-        if (!empty($tmpWhere)) {
312
+        if (!empty($tmpWhere)) {
313 313
             $where[] = $tmpWhere;
314 314
         }
315 315
 
316 316
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
317
-        if (!empty($tmpWhere)) {
317
+        if (!empty($tmpWhere)) {
318 318
             $where[] = $tmpWhere;
319 319
         }
320 320
 
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 
327 327
         $tmpWhere = null;
328 328
 
329
-        if ($sanitarInIDs != "''") {
330
-            switch ($this->getCFGDef('showParent', '0')) {
329
+        if ($sanitarInIDs != "''") {
330
+            switch ($this->getCFGDef('showParent', '0')) {
331 331
                 case '-1':
332 332
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
333 333
                     break;
@@ -340,35 +340,35 @@  discard block
 block discarded – undo
340 340
                     break;
341 341
             }
342 342
         }
343
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
343
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
344 344
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
345
-            if (empty($tmpWhere)) {
345
+            if (empty($tmpWhere)) {
346 346
                 $tmpWhere = "c.id IN({$addDocs})";
347
-            } else {
347
+            } else {
348 348
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
349 349
             }
350 350
         }
351
-        if (!empty($tmpWhere)) {
351
+        if (!empty($tmpWhere)) {
352 352
             $where[] = $tmpWhere;
353 353
         }
354
-        if (!$this->getCFGDef('showNoPublish', 0)) {
354
+        if (!$this->getCFGDef('showNoPublish', 0)) {
355 355
             $where[] = "c.published=1";
356 356
         }
357
-        if (!empty($where)) {
357
+        if (!empty($where)) {
358 358
             $where = "WHERE " . implode(" AND ", $where);
359
-        } else {
359
+        } else {
360 360
             $where = '';
361 361
         }
362 362
         $fields = $this->getCFGDef('selectFields', 'c.*');
363 363
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
364
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
364
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
365 365
             $rs = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
366 366
                 $group . " " .
367 367
                 $sort . " " .
368 368
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
369 369
             );
370 370
 
371
-            while ($item = $this->modx->db->getRow($rs)) {
371
+            while ($item = $this->modx->db->getRow($rs)) {
372 372
                 $out[$item['id']] = $item;
373 373
             }
374 374
         }
Please login to merge, or discard this patch.