Completed
Push — master ( 67ebf1...f718f9 )
by
unknown
02:24
created
assets/snippets/DocLister/core/controller/onetable.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
         if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
211 211
             $where = $this->getCFGDef('addWhereList', '');
212 212
             
213
-           	//====== block added by Dreamer to enable filters ======
213
+                //====== block added by Dreamer to enable filters ======
214 214
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
215 215
             $where = sqlHelper::trimLogicalOp($where);
216
-        	//------- end of block -------
216
+            //------- end of block -------
217 217
 
218 218
             
219 219
             if ($where != '') {
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
         $tmpWhere = $this->getCFGDef('addWhereList', '');
252 252
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
253 253
         
254
-    	//====== block added by Dreamer to enable filters ======
254
+        //====== block added by Dreamer to enable filters ======
255 255
         $tmpWhere = ($tmpWhere ? $tmpWhere . ' AND ' : '') . $this->_filters['where'];
256 256
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
257
-	    //------- end of block -------
257
+        //------- end of block -------
258 258
         
259 259
         
260 260
         if (!empty($tmpWhere)) {
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
         if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
325 325
             $where = $this->getCFGDef('addWhereList', '');
326 326
             
327
-        	//====== block added by Dreamer ======
327
+            //====== block added by Dreamer ======
328 328
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
329 329
             $where = sqlHelper::trimLogicalOp($where);
330
-	        //------- end of block -------
330
+            //------- end of block -------
331 331
             
332 332
             if ($where != '') {
333 333
                 $where = array($where);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                 $where[] = "{$this->getPK()} IN ({$sanitarInIDs})";
224 224
             }
225 225
 
226
-            if (!empty($where)) {
226
+            if ( ! empty($where)) {
227 227
                 $where = "WHERE " . implode(" AND ", $where);
228 228
             }
229 229
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	    //------- end of block -------
258 258
         
259 259
         
260
-        if (!empty($tmpWhere)) {
260
+        if ( ! empty($tmpWhere)) {
261 261
             $where[] = $tmpWhere;
262 262
         }
263 263
         $sanitarInIDs = $this->sanitarIn($this->IDs);
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
                 $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
287 287
             }
288 288
         }
289
-        if (!empty($tmpWhere)) {
289
+        if ( ! empty($tmpWhere)) {
290 290
             $where[] = $tmpWhere;
291 291
         }
292
-        if (!empty($where)) {
292
+        if ( ! empty($where)) {
293 293
             $where = "WHERE " . implode(" AND ", $where);
294 294
         } else {
295 295
             $where = '';
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                     }
364 364
                 }
365 365
             }
366
-            if (!empty($where)) {
366
+            if ( ! empty($where)) {
367 367
                 $where = "WHERE " . implode(" AND ", $where);
368 368
             } else {
369 369
                 $where = '';
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
         $tmp = $this->getCFGDef('addWhereFolder', '');
392 392
         $where = "{$this->getParentField()} IN ({$sanitarInIDs})";
393
-        if (!empty($tmp)) {
393
+        if ( ! empty($tmp)) {
394 394
             $where .= " AND " . $tmp;
395 395
         }
396 396
 
Please login to merge, or discard this patch.
Braces   +70 added lines, -70 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,25 +46,25 @@  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
-        if ($tpl == '') {
52
+        if ($tpl == '') {
53 53
             $tpl = $this->getCFGDef('tpl', '');
54 54
         }
55
-        if ($tpl != '') {
55
+        if ($tpl != '') {
56 56
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
57 57
 
58 58
             $i = 1;
59 59
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
60 60
             $noneTPL = $this->getCFGDef("noneTPL", "");
61
-            if (count($this->_docs) == 0 && $noneTPL != '') {
61
+            if (count($this->_docs) == 0 && $noneTPL != '') {
62 62
                 $out = $this->parseChunk($noneTPL, $sysPlh);
63
-            } else {
63
+            } else {
64 64
                 /**
65 65
                  * @var $extUser user_DL_Extender
66 66
                  */
67
-                if ($extUser = $this->getExtender('user')) {
67
+                if ($extUser = $this->getExtender('user')) {
68 68
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
69 69
                 }
70 70
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
                  */
79 79
                 $extPrepare = $this->getExtender('prepare');
80 80
                 $this->skippedDocs = 0;
81
-                foreach ($this->_docs as $item) {
81
+                foreach ($this->_docs as $item) {
82 82
                     $this->renderTPL = $tpl;
83
-                    if ($extUser) {
83
+                    if ($extUser) {
84 84
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
85 85
                     }
86 86
 
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
                         "dl") . '.iteration'] = $i; //[+iteration+] - Number element. Starting from zero
94 94
 
95 95
                     $date = $this->getCFGDef('dateSource', 'pub_date');
96
-                    if (isset($item[$date])) {
96
+                    if (isset($item[$date])) {
97 97
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
98
-                        if ($_date !== false) {
98
+                        if ($_date !== false) {
99 99
                             $_date = $_date + $this->modx->config['server_offset_time'];
100 100
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
101
-                            if ($dateFormat) {
101
+                            if ($dateFormat) {
102 102
                                 $item['date'] = strftime($dateFormat, $_date);
103 103
                             }
104 104
                         }
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
                     $findTpl = $this->renderTPL;
108 108
                     $tmp = $this->uniformPrepare($item, $i);
109 109
                     extract($tmp, EXTR_SKIP);
110
-                    if ($this->renderTPL == '') {
110
+                    if ($this->renderTPL == '') {
111 111
                         $this->renderTPL = $findTpl;
112 112
                     }
113 113
 
114
-                    if ($extPrepare) {
114
+                    if ($extPrepare) {
115 115
                         $item = $extPrepare->init($this, array(
116 116
                             'data'      => $item,
117 117
                             'nameParam' => 'prepare'
118 118
                         ));
119
-                        if (is_bool($item) && $item === false) {
119
+                        if (is_bool($item) && $item === false) {
120 120
                             $this->skippedDocs++;
121 121
                             continue;
122 122
                         }
123 123
                     }
124 124
                     $tmp = $this->parseChunk($this->renderTPL, $item);
125
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
125
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
126 126
                         $this->toPlaceholders($tmp, 1,
127 127
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
128 128
                     }
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
      * @param array $array
143 143
      * @return string
144 144
      */
145
-    public function getJSON($data, $fields, $array = array())
146
-    {
145
+    public function getJSON($data, $fields, $array = array())
146
+    {
147 147
         $out = array();
148 148
         $fields = is_array($fields) ? $fields : explode(",", $fields);
149 149
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
          * @var $extE e_DL_Extender
163 163
          */
164 164
         $extE = $this->getExtender('e', true, true);
165
-        foreach ($data as $num => $row) {
165
+        foreach ($data as $num => $row) {
166 166
 
167
-            switch (true) {
167
+            switch (true) {
168 168
                 case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary):
169 169
                     $row['summary'] = $this->getSummary($row, $extSummary, 'introtext');
170 170
                 //without break
171 171
                 case ((array('1') == $fields || in_array('date', $fields)) && $date != 'date'):
172
-                    if (isset($row[$date])) {
172
+                    if (isset($row[$date])) {
173 173
                         $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
174
-                        if ($_date !== false) {
174
+                        if ($_date !== false) {
175 175
                             $_date = $_date + $this->modx->config['server_offset_time'];
176 176
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
177
-                            if ($dateFormat) {
177
+                            if ($dateFormat) {
178 178
                                 $row['date'] = strftime($dateFormat, $_date);
179 179
                             }
180 180
                         }
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
                 //nobreak    
183 183
             }
184 184
 
185
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
186
-                if (is_array($tmp)) {
185
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
186
+                if (is_array($tmp)) {
187 187
                     $row = $tmp;
188 188
                 }
189 189
             }
190 190
 
191
-            if ($extPrepare) {
191
+            if ($extPrepare) {
192 192
                 $row = $extPrepare->init($this, array('data' => $row));
193
-                if (is_bool($row) && $row === false) {
193
+                if (is_bool($row) && $row === false) {
194 194
                     continue;
195 195
                 }
196 196
             }
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
     /**
204 204
      * @return array
205 205
      */
206
-    protected function getDocList()
207
-    {
206
+    protected function getDocList()
207
+    {
208 208
         $out = array();
209 209
         $sanitarInIDs = $this->sanitarIn($this->IDs);
210
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
210
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
211 211
             $where = $this->getCFGDef('addWhereList', '');
212 212
             
213 213
            	//====== block added by Dreamer to enable filters ======
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
         	//------- end of block -------
217 217
 
218 218
             
219
-            if ($where != '') {
219
+            if ($where != '') {
220 220
                 $where = array($where);
221 221
             }
222
-            if ($sanitarInIDs != "''") {
222
+            if ($sanitarInIDs != "''") {
223 223
                 $where[] = "{$this->getPK()} IN ({$sanitarInIDs})";
224 224
             }
225 225
 
226
-            if (!empty($where)) {
226
+            if (!empty($where)) {
227 227
                 $where = "WHERE " . implode(" AND ", $where);
228 228
             }
229 229
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}");
233 233
 
234 234
             $pk = $this->getPK(false);
235
-            while ($item = $this->modx->db->getRow($rs)) {
235
+            while ($item = $this->modx->db->getRow($rs)) {
236 236
                 $out[$item[$pk]] = $item;
237 237
             }
238 238
         }
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
     /**
244 244
      * @return array
245 245
      */
246
-    protected function getChildrenList()
247
-    {
246
+    protected function getChildrenList()
247
+    {
248 248
         $where = array();
249 249
         $out = array();
250 250
 
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
 	    //------- end of block -------
258 258
         
259 259
         
260
-        if (!empty($tmpWhere)) {
260
+        if (!empty($tmpWhere)) {
261 261
             $where[] = $tmpWhere;
262 262
         }
263 263
         $sanitarInIDs = $this->sanitarIn($this->IDs);
264 264
 
265 265
         $tmpWhere = null;
266
-        if ($sanitarInIDs != "''") {
266
+        if ($sanitarInIDs != "''") {
267 267
             $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")";
268
-            switch ($this->getCFGDef('showParent', '0')) {
268
+            switch ($this->getCFGDef('showParent', '0')) {
269 269
                 case -1:
270 270
                     $tmpWhere .= ")";
271 271
                     break;
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
                     break;
279 279
             }
280 280
         }
281
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
281
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
282 282
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
283
-            if (empty($tmpWhere)) {
283
+            if (empty($tmpWhere)) {
284 284
                 $tmpWhere = $this->getPK() . " IN({$addDocs})";
285
-            } else {
285
+            } else {
286 286
                 $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
287 287
             }
288 288
         }
289
-        if (!empty($tmpWhere)) {
289
+        if (!empty($tmpWhere)) {
290 290
             $where[] = $tmpWhere;
291 291
         }
292
-        if (!empty($where)) {
292
+        if (!empty($where)) {
293 293
             $where = "WHERE " . implode(" AND ", $where);
294
-        } else {
294
+        } else {
295 295
             $where = '';
296 296
         }
297 297
         $fields = $this->getCFGDef('selectFields', '*');
298 298
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
299
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
299
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
300 300
             $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " .
301 301
                 $group . " " .
302 302
                 $this->SortOrderSQL($this->getPK()) . " " .
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
             $pk = $this->getPK(false);
307 307
 
308
-            while ($item = $this->modx->db->getRow($rs)) {
308
+            while ($item = $this->modx->db->getRow($rs)) {
309 309
                 $out[$item[$pk]] = $item;
310 310
             }
311 311
 
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
     /**
318 318
      * @absctract
319 319
      */
320
-    public function getChildrenCount()
321
-    {
320
+    public function getChildrenCount()
321
+    {
322 322
         $out = 0;
323 323
         $sanitarInIDs = $this->sanitarIn($this->IDs);
324
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
324
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
325 325
             $where = $this->getCFGDef('addWhereList', '');
326 326
             
327 327
         	//====== block added by Dreamer ======
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
             $where = sqlHelper::trimLogicalOp($where);
330 330
 	        //------- end of block -------
331 331
             
332
-            if ($where != '') {
332
+            if ($where != '') {
333 333
                 $where = array($where);
334
-            } else {
334
+            } else {
335 335
                 $where = array();
336 336
             }
337
-            if ($sanitarInIDs != "''") {
338
-                if ($sanitarInIDs != "''") {
339
-                    switch ($this->getCFGDef('idType', 'parents')) {
337
+            if ($sanitarInIDs != "''") {
338
+                if ($sanitarInIDs != "''") {
339
+                    switch ($this->getCFGDef('idType', 'parents')) {
340 340
                         case 'parents':
341
-                            switch ($this->getCFGDef('showParent', '0')) {
341
+                            switch ($this->getCFGDef('showParent', '0')) {
342 342
                                 case '-1':
343 343
                                     $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})";
344 344
                                     break;
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
                                     $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))";
351 351
                                     break;
352 352
                             }
353
-                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
353
+                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
354 354
                                 $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
355 355
                                 $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
356
-                            } else {
356
+                            } else {
357 357
                                 $where[] = $tmpWhere;
358 358
                             }
359 359
                             break;
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
                     }
364 364
                 }
365 365
             }
366
-            if (!empty($where)) {
366
+            if (!empty($where)) {
367 367
                 $where = "WHERE " . implode(" AND ", $where);
368
-            } else {
368
+            } else {
369 369
                 $where = '';
370 370
             }
371 371
 
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
      * @param string $id
384 384
      * @return array
385 385
      */
386
-    public function getChildrenFolder($id)
387
-    {
386
+    public function getChildrenFolder($id)
387
+    {
388 388
         $out = array();
389 389
         $sanitarInIDs = $this->sanitarIn($id);
390 390
 
391 391
         $tmp = $this->getCFGDef('addWhereFolder', '');
392 392
         $where = "{$this->getParentField()} IN ({$sanitarInIDs})";
393
-        if (!empty($tmp)) {
393
+        if (!empty($tmp)) {
394 394
             $where .= " AND " . $tmp;
395 395
         }
396 396
 
397 397
         $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}");
398 398
         $pk = $this->getPK(false);
399
-        while ($item = $this->modx->db->getRow($rs)) {
399
+        while ($item = $this->modx->db->getRow($rs)) {
400 400
             $out[] = $item[$pk];
401 401
         }
402 402
 
Please login to merge, or discard this patch.