Test Failed
Push — master ( b5962b...519209 )
by Maxim
03:24
created
assets/snippets/DocLister/core/controller/site_content_menu.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function setIDs($IDs)
29 29
     {
30
-        $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
30
+        $this->debug->debug('set ID list '.$this->debug->dumpData($IDs), 'setIDs', 2);
31 31
         $IDs = $this->cleanIDs($IDs);
32 32
         $this->debug->debugEnd("setIDs");
33 33
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
                         $data['wrap'] = $this->parseOuter($data);
346 346
                     }
347 347
                     $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
348
-                    $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
348
+                    $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int) $data['parent'],
349 349
                                 $this->activeBranch));
350 350
                     if ($hideSubMenus) {
351 351
                         $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data;
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
      */
499 499
     public function getHereId()
500 500
     {
501
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
502
-            $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
501
+        if (!$hereId = (int) $this->getCFGDef('hereId')) {
502
+            $hereId = isset($this->modx->documentIdentifier) ? (int) $this->modx->documentIdentifier : 0;
503 503
         }
504 504
 
505 505
         return $hereId;
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
             'evenClass'    => ''
526 526
         );
527 527
         if (isset($data['state'])) {
528
-            $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']);
528
+            $classes['stateClass'] = $this->getCFGDef($data['state'].'Class', $data['state']);
529 529
         }
530 530
         if (isset($data['here'])) {
531 531
             $classes['hereClass'] = $this->getCFGDef('hereClass', 'current');
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             $classes['lastClass'] = $this->getCFGDef('lastClass', 'last');
547 547
         }
548 548
         if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
549
-            $classes['levelClass'] = $levelClass . $data['level'];
549
+            $classes['levelClass'] = $levelClass.$data['level'];
550 550
         }
551 551
         if (isset($data['type']) && $data['type'] == 'reference') {
552 552
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                         }
640 640
 
641 641
                         $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
642
-                        $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
642
+                        $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int) $data['parent'],
643 643
                                     $this->activeBranch));
644 644
                         if ($hideSubMenus) {
645 645
                             $docs[$currentLevel - 1][$data['parent']]['children'][] = $data;
@@ -678,6 +678,6 @@  discard block
 block discarded – undo
678 678
      */
679 679
     public function getCFGDef($name, $def = null)
680 680
     {
681
-        return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def));
681
+        return parent::getCFGDef($name.$this->currentLevel, parent::getCFGDef($name, $def));
682 682
     }
683 683
 }
Please login to merge, or discard this patch.
Braces   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
10 10
  * @author Agel_Nash <[email protected]>, kabachello <[email protected]>
11 11
  */
12
-class site_content_menuDocLister extends site_contentDocLister
13
-{
12
+class site_content_menuDocLister extends site_contentDocLister
13
+{
14 14
     public $levels = array();
15 15
     protected $currentLevel = 1;
16 16
     protected $docTvs = array();
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
      * @param mixed $IDs список id документов по которым необходима выборка
26 26
      * @return array очищенный массив
27 27
      */
28
-    public function setIDs($IDs)
29
-    {
28
+    public function setIDs($IDs)
29
+    {
30 30
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
31 31
         $IDs = $this->cleanIDs($IDs);
32 32
         $this->debug->debugEnd("setIDs");
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
      * @param string $tvlist
39 39
      * @return array
40 40
      */
41
-    public function getDocs($tvlist = '')
42
-    {
41
+    public function getDocs($tvlist = '')
42
+    {
43 43
         $this->extTV->getAllTV_Name();
44
-        if ($ids = $this->getCFGDef('documents')) {
44
+        if ($ids = $this->getCFGDef('documents')) {
45 45
             $this->levels = $this->extCache->load('menudata');
46
-            if ($this->levels === false) {
46
+            if ($this->levels === false) {
47 47
                 $this->levels = array();
48 48
                 $this->setIDs($ids);
49 49
                 $docs = $this->getDocList();
50 50
                 $display = count($docs);
51 51
                 $iteration = 1;
52
-                foreach ($docs as $id => &$item) {
52
+                foreach ($docs as $id => &$item) {
53 53
                     $item['iteration'] = $iteration++;
54 54
                     $item['_display'] = $display;
55 55
                     $item['_parent'] = $item['parent'];
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                 $this->extCache->save($this->levels, 'menudata');
60 60
             }
61 61
             $this->setActiveBranch($this->getHereId(), 1);
62
-        } else {
62
+        } else {
63 63
             $this->_getChildren();
64 64
         }
65 65
 
@@ -71,72 +71,72 @@  discard block
 block discarded – undo
71 71
     /**
72 72
      *
73 73
      */
74
-    public function _getChildren()
75
-    {
74
+    public function _getChildren()
75
+    {
76 76
         $maxDepth = $this->getCFGDef('maxDepth', 10);
77
-        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
77
+        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
78 78
             $maxDepth = min($maxDepth, $this->setActiveBranch($this->getHereId()));
79
-            if (empty(array_intersect($this->IDs, $this->activeBranch))) {
79
+            if (empty(array_intersect($this->IDs, $this->activeBranch))) {
80 80
                 $maxDepth = 1;
81 81
                 $this->config->setConfig(array('hideSubMenus' => 0));
82 82
             };
83
-        } else {
83
+        } else {
84 84
             $this->setActiveBranch($this->getHereId());
85 85
         }
86
-        if ($oIds = $this->getCFGDef('openIds')) {
86
+        if ($oIds = $this->getCFGDef('openIds')) {
87 87
             $maxDepth = 1;
88 88
             $oIds = $this->cleanIDs($oIds);
89 89
             $oIds[] = $this->getHereId();
90
-            foreach ($oIds as $id) {
91
-                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
90
+            foreach ($oIds as $id) {
91
+                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
92 92
                     $maxDepth = $c;
93 93
                 }
94 94
             }
95 95
             $this->config->setConfig(array('hideSubMenus' => 1));
96 96
         }
97 97
         $this->levels = $this->extCache->load('menudata');
98
-        if ($this->levels === false) {
98
+        if ($this->levels === false) {
99 99
             $this->levels = array();
100 100
             $currentLevel = &$this->currentLevel;
101 101
             $currentLevel = 1;
102
-            if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
102
+            if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
103 103
                 $this->config->setConfig(array('showParent' => 0));
104 104
             }
105 105
             $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParent', 0);
106
-            while ($currentLevel <= $maxDepth) {
106
+            while ($currentLevel <= $maxDepth) {
107 107
                 $orderBy = $this->getCFGDef('orderBy');
108
-                if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) {
108
+                if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) {
109 109
                     $docs = $this->getDocList();
110 110
                     $this->config->setConfig(array('showParent' => 0));
111
-                } else {
111
+                } else {
112 112
                     $docs = $this->getChildrenList();
113 113
                 }
114
-                if ($currentLevel == 1 && $joinMenus) {
114
+                if ($currentLevel == 1 && $joinMenus) {
115 115
                     $tmp = array();
116 116
                     $display = 0;
117 117
                     $iteration = 1;
118
-                    foreach ($docs as $id => $item) {
118
+                    foreach ($docs as $id => $item) {
119 119
                         $tmp[$item['parent']][] = $item['id'];
120 120
                         $display++;
121 121
                     }
122
-                    foreach ($tmp as $id => $item) {
123
-                        foreach ($item as $_id) {
122
+                    foreach ($tmp as $id => $item) {
123
+                        foreach ($item as $_id) {
124 124
                             $docs[$_id]['_display'] = $display;
125 125
                             $docs[$_id]['iteration'] = $iteration++;
126 126
                         }
127 127
                     }
128 128
                     unset($tmp);
129
-                } else {
130
-                    foreach ($docs as $id => &$item) {
129
+                } else {
130
+                    foreach ($docs as $id => &$item) {
131 131
                         $parent = $item['parent'];
132
-                        if (!isset($this->display[$parent])) {
132
+                        if (!isset($this->display[$parent])) {
133 133
                             $this->display[$parent] = 1;
134 134
                         }
135 135
                         $item['iteration'] = $this->display[$parent]++;
136 136
                     }
137 137
                 }
138 138
                 $this->config->setConfig(array('orderBy' => $orderBy));
139
-                if (empty($docs)) {
139
+                if (empty($docs)) {
140 140
                     break;
141 141
                 }
142 142
                 $this->levels[$currentLevel++] = $docs;
@@ -151,23 +151,23 @@  discard block
 block discarded – undo
151 151
      * @param string $tvlist
152 152
      * @return site_content_menuDocLister
153 153
      */
154
-    protected function addTvs($tvlist = '')
155
-    {
156
-        if ($tvlist == '') {
154
+    protected function addTvs($tvlist = '')
155
+    {
156
+        if ($tvlist == '') {
157 157
             $tvlist = $this->getCFGDef('tvList', '');
158 158
         }
159 159
 
160
-        if ($tvlist != '') {
160
+        if ($tvlist != '') {
161 161
             $this->docTvs = $this->extCache->load('tvs');
162
-            if ($this->docTvs === false) {
162
+            if ($this->docTvs === false) {
163 163
                 $this->docTvs = array();
164 164
                 $ids = array();
165
-                foreach ($this->levels as $level => $docs) {
165
+                foreach ($this->levels as $level => $docs) {
166 166
                     $ids = array_merge($ids, array_keys($docs));
167 167
                 }
168
-                if (!empty($ids)) {
168
+                if (!empty($ids)) {
169 169
                     $tv = $this->extTV->getTVList($ids, $tvlist);
170
-                    if (!is_array($tv)) {
170
+                    if (!is_array($tv)) {
171 171
                         $tv = array();
172 172
                     }
173 173
                     $this->docTvs = $tv;
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
      * @param int $maxDepth
186 186
      * @return int
187 187
      */
188
-    public function setActiveBranch($id, $maxDepth = 10)
189
-    {
188
+    public function setActiveBranch($id, $maxDepth = 10)
189
+    {
190 190
         $ids = array_values($this->modx->getParentIds($id, $maxDepth));
191 191
         $ids[] = $id;
192 192
         $ids[] = 0;
@@ -199,35 +199,35 @@  discard block
 block discarded – undo
199 199
     /**
200 200
      * Подсчет количества непосредственных дочерних документов
201 201
      */
202
-    public function countChildren()
203
-    {
204
-        if (!$this->getCFGDef('countChildren', 0)) {
202
+    public function countChildren()
203
+    {
204
+        if (!$this->getCFGDef('countChildren', 0)) {
205 205
             return;
206 206
         }
207 207
         $this->countChildren = $this->extCache->load('countChildren');
208
-        if ($this->countChildren === false) {
208
+        if ($this->countChildren === false) {
209 209
             $this->countChildren = array();
210 210
             $ids = array();
211 211
             $out = &$this->countChildren;
212
-            foreach ($this->levels as $level => $docs) {
212
+            foreach ($this->levels as $level => $docs) {
213 213
                 $ids = array_merge($ids, array_keys($docs));
214 214
             }
215 215
             $maxDepth = count($this->levels);
216 216
             $currentDepth = 1;
217
-            while ($currentDepth <= $maxDepth) {
217
+            while ($currentDepth <= $maxDepth) {
218 218
                 $_ids = implode(',', $ids);
219
-                if (empty($_ids)) {
219
+                if (empty($_ids)) {
220 220
                     break;
221 221
                 }
222 222
                 $q = $this->dbQuery("SELECT `parent`,COUNT(*) as `count` FROM {$this->getTable('site_content')} WHERE `parent` IN ({$_ids}) AND `published`=1 AND `deleted`=0 GROUP BY `parent`");
223 223
                 $_ids = array();
224
-                while ($row = $this->modx->db->getRow($q)) {
224
+                while ($row = $this->modx->db->getRow($q)) {
225 225
                     $_ids[] = $row['parent'];
226 226
                     $out[$row['parent']] = $row['count'];
227 227
                 }
228
-                if (!empty($_ids)) {
228
+                if (!empty($_ids)) {
229 229
                     $ids = $this->diff($ids, $_ids);
230
-                } else {
230
+                } else {
231 231
                     break;
232 232
                 }
233 233
                 $currentDepth++;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
      * @param $a
243 243
      * @return array
244 244
      */
245
-    private function diff($b, $a)
246
-    {
245
+    private function diff($b, $a)
246
+    {
247 247
         $at = array_flip($a);
248 248
         $d = array();
249
-        foreach ($b as $i) {
250
-            if (!isset($at[$i])) {
249
+        foreach ($b as $i) {
250
+            if (!isset($at[$i])) {
251 251
                 $d[] = $i;
252 252
             }
253 253
         }
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
     /**
259 259
      * @return string
260 260
      */
261
-    protected function getBranchCacheKey()
262
-    {
261
+    protected function getBranchCacheKey()
262
+    {
263 263
         $depth = count($this->levels);
264 264
         $out = array();
265
-        while ($depth > 0) {
265
+        while ($depth > 0) {
266 266
             $ids = array_keys($this->levels[$depth]);
267
-            foreach ($this->activeBranch as $id) {
268
-                if (in_array($id, $ids)) {
267
+            foreach ($this->activeBranch as $id) {
268
+                if (in_array($id, $ids)) {
269 269
                     $out[] = $id;
270 270
                     break;
271 271
                 }
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
      * @param string $tpl шаблон
285 285
      * @return string
286 286
      */
287
-    public function render($tpl = '')
288
-    {
287
+    public function render($tpl = '')
288
+    {
289 289
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
290
-        if (empty($this->levels)) {
290
+        if (empty($this->levels)) {
291 291
             $noneTpl = $this->getCFGDef('noneTpl');
292 292
             $out = $noneTpl ? $this->parseChunk($noneTpl, array()) : '';
293
-        } else {
293
+        } else {
294 294
             $out = $this->_render($tpl);
295 295
         }
296 296
 
297
-        if ($out) {
297
+        if ($out) {
298 298
             $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
299 299
         }
300 300
         $this->debug->debugEnd('render');
@@ -306,40 +306,40 @@  discard block
 block discarded – undo
306 306
      * @param string $tpl
307 307
      * @return string
308 308
      */
309
-    public function _render($tpl = '')
310
-    {
309
+    public function _render($tpl = '')
310
+    {
311 311
         $key = $this->getBranchCacheKey();
312 312
         $out = $this->extCache->load($key);
313
-        if ($out === false) {
313
+        if ($out === false) {
314 314
             $currentLevel = &$this->currentLevel;
315 315
             $currentLevel = count($this->levels);
316 316
             $docs = $this->levels;
317 317
             /** @var prepare_DL_Extender_ $extPrepare */
318 318
             $extPrepare = $this->getExtender('prepare');
319
-            while ($currentLevel > 0) {
320
-                foreach ($docs[$currentLevel] as $id => &$data) {
321
-                    if ($out = $this->prepareData($data)) {
322
-                        if (is_array($out)) {
319
+            while ($currentLevel > 0) {
320
+                foreach ($docs[$currentLevel] as $id => &$data) {
321
+                    if ($out = $this->prepareData($data)) {
322
+                        if (is_array($out)) {
323 323
                             $data = $out;
324 324
                         }
325 325
                     };
326
-                    if (!isset($data['maxLevel'])) {
326
+                    if (!isset($data['maxLevel'])) {
327 327
                         $data['maxLevel'] = 1;
328 328
                         $docs[$currentLevel - 1][$data['parent']]['maxLevel'] = 0;
329 329
                     }
330 330
 
331
-                    if ($extPrepare) {
331
+                    if ($extPrepare) {
332 332
                         $data = $extPrepare->init($this, array(
333 333
                             'data'      => $data,
334 334
                             'nameParam' => 'prepare'
335 335
                         ));
336
-                        if (is_bool($data) && $data === false) {
336
+                        if (is_bool($data) && $data === false) {
337 337
                             continue;
338 338
                         }
339 339
                     }
340 340
 
341
-                    if (isset($data['wrap'])) {
342
-                        if (is_array($data['wrap'])) {
341
+                    if (isset($data['wrap'])) {
342
+                        if (is_array($data['wrap'])) {
343 343
                             $data['wrap'] = $this->parseRow($data['wrap']);
344 344
                         }
345 345
                         $data['wrap'] = $this->parseOuter($data);
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                     $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
348 348
                     $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
349 349
                                 $this->activeBranch));
350
-                    if ($hideSubMenus) {
350
+                    if ($hideSubMenus) {
351 351
                         $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data;
352 352
                     }
353 353
                 }
@@ -357,17 +357,17 @@  discard block
 block discarded – undo
357 357
             unset($data);
358 358
             $out = '';
359 359
             $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParent', 0);
360
-            foreach ($docs[0] as $id => $data) {
361
-                if (isset($data['wrap'])) {
362
-                    if ($joinMenus) {
360
+            foreach ($docs[0] as $id => $data) {
361
+                if (isset($data['wrap'])) {
362
+                    if ($joinMenus) {
363 363
                         $out .= $this->parseRow($data['wrap']);
364
-                    } else {
364
+                    } else {
365 365
                         $data['wrap'] = $this->parseRow($data['wrap']);
366 366
                         $out .= $this->parseOuter($data);
367 367
                     }
368 368
                 }
369 369
             }
370
-            if ($joinMenus) {
370
+            if ($joinMenus) {
371 371
                 $out = $this->parseOuter(array('wrap' => $out));
372 372
             }
373 373
             $this->extCache->save($out, $key);
@@ -381,33 +381,33 @@  discard block
 block discarded – undo
381 381
      * @param $data
382 382
      * @return array
383 383
      */
384
-    public function prepareData($data)
385
-    {
384
+    public function prepareData($data)
385
+    {
386 386
         /**
387 387
          * @var e_DL_Extender $extE
388 388
          */
389 389
         $extE = $this->getExtender('e', true, true);
390 390
         $id = $data['id'];
391
-        if (isset($this->docTvs[$id])) {
391
+        if (isset($this->docTvs[$id])) {
392 392
             $data = array_merge($data, $this->docTvs[$id]);
393 393
         }
394
-        if ($id == $this->getHereId()) {
394
+        if ($id == $this->getHereId()) {
395 395
             $data['here'] = 1;
396 396
         }
397
-        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
397
+        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
398 398
             $data['active'] = 1;
399 399
         }
400
-        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
400
+        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
401 401
             $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed';
402 402
         }
403 403
 
404
-        if (!isset($data['_display'])) {
404
+        if (!isset($data['_display'])) {
405 405
             $data['_display'] = $this->display[$data['parent']] - 1;
406 406
         }
407
-        if ($data['iteration'] == 1) {
407
+        if ($data['iteration'] == 1) {
408 408
             $data['first'] = 1;
409 409
         }
410
-        if ($data['iteration'] == $data['_display']) {
410
+        if ($data['iteration'] == $data['_display']) {
411 411
             $data['last'] = 1;
412 412
         }
413 413
 
@@ -415,12 +415,12 @@  discard block
 block discarded – undo
415 415
         $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
416 416
         $data['level'] = $this->currentLevel;
417 417
         $data['url'] = $this->makeUrl($data);
418
-        if ($this->getCFGDef('countChildren', 0)) {
418
+        if ($this->getCFGDef('countChildren', 0)) {
419 419
             $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0;
420 420
         }
421 421
 
422
-        if ($out = $extE->init($this, compact('data'))) {
423
-            if (is_array($out)) {
422
+        if ($out = $extE->init($this, compact('data'))) {
423
+            if (is_array($out)) {
424 424
                 $data = $out;
425 425
             }
426 426
         }
@@ -433,16 +433,16 @@  discard block
 block discarded – undo
433 433
      * @param array $data
434 434
      * @return string
435 435
      */
436
-    public function parseOuter($data = array())
437
-    {
436
+    public function parseOuter($data = array())
437
+    {
438 438
         $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>');
439 439
         $classes = '';
440 440
         $classNames = $this->getCFGDef('outerClass');
441
-        if ($this->currentLevel >= 1) {
441
+        if ($this->currentLevel >= 1) {
442 442
             $tpl = $this->getCFGDef('innerTpl', $tpl);
443 443
             $classNames = $this->getCFGDef('innerClass');
444 444
         }
445
-        if ($classNames) {
445
+        if ($classNames) {
446 446
             $classes = " class=\"{$classNames}\"";
447 447
         }
448 448
         $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl;
@@ -459,10 +459,10 @@  discard block
 block discarded – undo
459 459
      * @param array $data
460 460
      * @return string
461 461
      */
462
-    public function parseRow($data = array())
463
-    {
462
+    public function parseRow($data = array())
463
+    {
464 464
         $out = '';
465
-        foreach ($data as $iteration => $item) {
465
+        foreach ($data as $iteration => $item) {
466 466
             $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item);
467 467
             $item = array_merge($item, $this->getClasses($item));
468 468
             $out .= $this->parseChunk($tpl, $item);
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
      * @param array $data
477 477
      * @return string
478 478
      */
479
-    protected function makeUrl($data = array())
480
-    {
479
+    protected function makeUrl($data = array())
480
+    {
481 481
         $out = '';
482
-        if ($this->getCFGDef('makeUrl', 1)) {
483
-            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
482
+        if ($this->getCFGDef('makeUrl', 1)) {
483
+            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
484 484
                 $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '',
485 485
                     $this->getCFGDef('urlScheme', '')) : $data['content'];
486
-            } else {
486
+            } else {
487 487
                 $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '',
488 488
                     $this->getCFGDef('urlScheme', '')) : '';
489 489
             }
@@ -496,9 +496,9 @@  discard block
 block discarded – undo
496 496
      * Вовзращает id текущего документа
497 497
      * @return int
498 498
      */
499
-    public function getHereId()
500
-    {
501
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
499
+    public function getHereId()
500
+    {
501
+        if (!$hereId = (int)$this->getCFGDef('hereId')) {
502 502
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
503 503
         }
504 504
 
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
      * @param array $data
511 511
      * @return array
512 512
      */
513
-    protected function getClasses($data = array())
514
-    {
513
+    protected function getClasses($data = array())
514
+    {
515 515
         $classes = isset($data['classes']) ? $data['classes'] : array(
516 516
             'rowClass'     => '',
517 517
             'firstClass'   => '',
@@ -524,34 +524,34 @@  discard block
 block discarded – undo
524 524
             'oddClass'     => '',
525 525
             'evenClass'    => ''
526 526
         );
527
-        if (isset($data['state'])) {
527
+        if (isset($data['state'])) {
528 528
             $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']);
529 529
         }
530
-        if (isset($data['here'])) {
530
+        if (isset($data['here'])) {
531 531
             $classes['hereClass'] = $this->getCFGDef('hereClass', 'current');
532 532
         }
533
-        if (isset($data['active'])) {
533
+        if (isset($data['active'])) {
534 534
             $classes['activeClass'] = $this->getCFGDef('activeClass', 'active');
535 535
         }
536 536
         $classes['rowClass'] = $this->getCFGDef('rowClass');
537
-        if ($data['iteration'] % 2 == 1) {
537
+        if ($data['iteration'] % 2 == 1) {
538 538
             $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd');
539
-        } else {
539
+        } else {
540 540
             $classes['evenClass'] = $this->getCFGDef('evenClass', 'even');
541 541
         }
542
-        if (isset($data['first'])) {
542
+        if (isset($data['first'])) {
543 543
             $classes['firstClass'] = $this->getCFGDef('firstClass', 'first');
544 544
         }
545
-        if (isset($data['last'])) {
545
+        if (isset($data['last'])) {
546 546
             $classes['lastClass'] = $this->getCFGDef('lastClass', 'last');
547 547
         }
548
-        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
548
+        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
549 549
             $classes['levelClass'] = $levelClass . $data['level'];
550 550
         }
551
-        if (isset($data['type']) && $data['type'] == 'reference') {
551
+        if (isset($data['type']) && $data['type'] == 'reference') {
552 552
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
553 553
         }
554
-        if (!empty($data['wrap'])) {
554
+        if (!empty($data['wrap'])) {
555 555
             $classes['parentClass'] = $this->getCFGDef('parentClass');
556 556
         }
557 557
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -566,28 +566,28 @@  discard block
 block discarded – undo
566 566
      * @param array $data
567 567
      * @return string
568 568
      */
569
-    protected function getRowTemplate($data = array())
570
-    {
569
+    protected function getRowTemplate($data = array())
570
+    {
571 571
         $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>');
572
-        if (!empty($data['wrap'])) {
572
+        if (!empty($data['wrap'])) {
573 573
             $tpl = $this->getCFGDef('parentRowTpl',
574 574
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
575 575
             if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
576 576
                         'category') !== false)
577
-            ) {
577
+            ) {
578 578
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
579
-            } elseif (isset($data['here'])) {
579
+            } elseif (isset($data['here'])) {
580 580
                 $tpl = $this->getCFGDef('parentRowHereTpl', $tpl);
581
-            } elseif (isset($data['active'])) {
581
+            } elseif (isset($data['active'])) {
582 582
                 $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl);
583 583
             }
584
-        } elseif ($data['level'] > 1) {
584
+        } elseif ($data['level'] > 1) {
585 585
             $tpl = $this->getCFGDef('innerRowTpl', $tpl);
586
-            if (isset($data['here'])) {
586
+            if (isset($data['here'])) {
587 587
                 $tpl = $this->getCFGDef('innerRowHereTpl', $tpl);
588 588
             }
589
-        } else {
590
-            if (isset($data['here'])) {
589
+        } else {
590
+            if (isset($data['here'])) {
591 591
                 $tpl = $this->getCFGDef('rowHereTpl', $tpl);
592 592
             }
593 593
         }
@@ -601,39 +601,39 @@  discard block
 block discarded – undo
601 601
      * @param array $array
602 602
      * @return string
603 603
      */
604
-    public function getJSON($data, $fields, $array = array())
605
-    {
604
+    public function getJSON($data, $fields, $array = array())
605
+    {
606 606
         $key = $this->getBranchCacheKey();
607 607
         $out = $this->extCache->load($key);
608
-        if ($out === false) {
608
+        if ($out === false) {
609 609
             $currentLevel = &$this->currentLevel;
610 610
             $currentLevel = count($this->levels);
611 611
             $docs = $this->levels;
612 612
 
613
-            if (empty($docs)) {
613
+            if (empty($docs)) {
614 614
                 $out = '[]';
615
-            } else {
615
+            } else {
616 616
                 /** @var prepare_DL_Extender_ $extPrepare */
617 617
                 $extPrepare = $this->getExtender('prepare');
618 618
 
619
-                while ($currentLevel > 0) {
620
-                    foreach ($docs[$currentLevel] as $id => &$data) {
621
-                        if ($out = $this->prepareData($data)) {
622
-                            if (is_array($out)) {
619
+                while ($currentLevel > 0) {
620
+                    foreach ($docs[$currentLevel] as $id => &$data) {
621
+                        if ($out = $this->prepareData($data)) {
622
+                            if (is_array($out)) {
623 623
                                 $data = $out;
624 624
                             }
625 625
                         };
626 626
 
627
-                        if (isset($data['here']) || isset($data['active'])) {
627
+                        if (isset($data['here']) || isset($data['active'])) {
628 628
                             $docs[$currentLevel - 1][$data['parent']]['active'] = 1;
629 629
                         }
630 630
 
631
-                        if ($extPrepare) {
631
+                        if ($extPrepare) {
632 632
                             $data = $extPrepare->init($this, array(
633 633
                                 'data'      => $data,
634 634
                                 'nameParam' => 'prepare'
635 635
                             ));
636
-                            if (is_bool($data) && $data === false) {
636
+                            if (is_bool($data) && $data === false) {
637 637
                                 continue;
638 638
                             }
639 639
                         }
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
                         $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
642 642
                         $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
643 643
                                     $this->activeBranch));
644
-                        if ($hideSubMenus) {
644
+                        if ($hideSubMenus) {
645 645
                             $docs[$currentLevel - 1][$data['parent']]['children'][] = $data;
646 646
                         }
647 647
                     }
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
                 unset($data);
652 652
                 $out = array();
653 653
                 $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParent', 0);
654
-                foreach ($docs[0] as $id => $data) {
655
-                    if (isset($data['children'])) {
656
-                        if ($joinMenus) {
654
+                foreach ($docs[0] as $id => $data) {
655
+                    if (isset($data['children'])) {
656
+                        if ($joinMenus) {
657 657
                             $out = array_merge($out, $data['children']);
658
-                        } else {
658
+                        } else {
659 659
                             $out[] = $data['children'];
660 660
                         }
661 661
                     }
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
677 677
      * @return mixed значение из конфига
678 678
      */
679
-    public function getCFGDef($name, $def = null)
680
-    {
679
+    public function getCFGDef($name, $def = null)
680
+    {
681 681
         return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def));
682 682
     }
683 683
 }
Please login to merge, or discard this patch.