Completed
Push — master ( 81e0ef...347414 )
by
unknown
02:24
created
assets/snippets/DocLister/core/controller/site_content_menu.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
69 69
             $this->config->setConfig(array('showParent' => 0));
70 70
         }
71
-        $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
71
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
72 72
         while ($currentLevel <= $maxDepth) {
73 73
             $orderBy = $this->getCFGDef('orderBy');
74 74
             if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) {
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             } else {
96 96
                 foreach ($docs as $id => &$item) {
97 97
                     $parent = $item['parent'];
98
-                    if (!isset($this->display[$parent])) {
98
+                    if ( ! isset($this->display[$parent])) {
99 99
                         $this->display[$parent] = 1;
100 100
                     }
101 101
                     $item['iteration'] = $this->display[$parent]++;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             }
122 122
             if ($ids) {
123 123
                 $tv = $this->extTV->getTVList($ids, $tvlist);
124
-                if (!is_array($tv)) {
124
+                if ( ! is_array($tv)) {
125 125
                     $tv = array();
126 126
                 }
127 127
                 $this->docTvs = $tv;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         $at = array_flip($a);
195 195
         $d = array();
196 196
         foreach ($b as $i) {
197
-            if (!isset($at[$i])) {
197
+            if ( ! isset($at[$i])) {
198 198
                 $d[] = $i;
199 199
             }
200 200
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                         $data = $out;
241 241
                     }
242 242
                 };
243
-                if (!isset($data['maxLevel'])) {
243
+                if ( ! isset($data['maxLevel'])) {
244 244
                     $data['maxLevel'] = 1;
245 245
                     $docs[$currentLevel - 1][$data['parent']]['maxLevel'] = 0;
246 246
                 }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                     $data['wrap'] = $this->parseOuter($data);
261 261
                 }
262 262
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
263
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
263
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
264 264
                             $this->activeBranch));
265 265
                 if ($hideSubMenus) {
266 266
                     $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         unset($data);
273 273
 
274 274
         $out = '';
275
-        $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
275
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
276 276
         foreach ($docs[0] as $id => $data) {
277 277
             if (isset($data['wrap'])) {
278 278
                 if ($joinMenus) {
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
         if ($id == $this->getHereId()) {
309 309
             $data['here'] = 1;
310 310
         }
311
-        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
311
+        if ( ! isset($data['here']) && in_array($id, $this->activeBranch)) {
312 312
             $data['active'] = 1;
313 313
         }
314 314
         if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
315 315
             $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed';
316 316
         }
317 317
 
318
-        if (!isset($data['_display'])) {
318
+        if ( ! isset($data['_display'])) {
319 319
             $data['_display'] = $this->display[$data['parent']] - 1;
320 320
         }
321 321
         if ($data['iteration'] == 1) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         }
327 327
 
328 328
         $titleField = $this->getCFGDef('titleField', 'title');
329
-        $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
329
+        $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
330 330
         $data['level'] = $this->currentLevel;
331 331
         $data['url'] = $this->makeUrl($data);
332 332
         if ($this->getCFGDef('countChildren', 0)) {
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public function getHereId()
413 413
     {
414
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
414
+        if ( ! $hereId = (int)$this->getCFGDef('hereId')) {
415 415
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
416 416
         }
417 417
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
         if (isset($data['type']) && $data['type'] == 'reference') {
465 465
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
466 466
         }
467
-        if (!empty($data['wrap'])) {
467
+        if ( ! empty($data['wrap'])) {
468 468
             $classes['parentClass'] = $this->getCFGDef('parentClass');
469 469
         }
470 470
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
         if ($data['wrap']) {
486 486
             $tpl = $this->getCFGDef('parentRowTpl',
487 487
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
488
-            if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
488
+            if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
489 489
                         'category') !== false)
490 490
             ) {
491 491
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
                 }
546 546
 
547 547
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
548
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
548
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
549 549
                             $this->activeBranch));
550 550
                 if ($hideSubMenus) {
551 551
                     $docs[$currentLevel - 1][$data['parent']]['children'][] = $data;
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         }
557 557
         unset($data);
558 558
         $out = array();
559
-        $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
559
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
560 560
         foreach ($docs[0] as $id => $data) {
561 561
             if (isset($data['children'])) {
562 562
                 if ($joinMenus) {
Please login to merge, or discard this patch.
Braces   +128 added lines, -128 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,26 +38,26 @@  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
         $maxDepth = $this->getCFGDef('maxDepth', 10);
44 44
         $this->extTV->getAllTV_Name();
45 45
         //TODO кэширование
46
-        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
46
+        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
47 47
             $maxDepth = min($maxDepth, $this->setActiveBranch($this->getHereId()));
48
-            if (empty(array_intersect($this->IDs, $this->activeBranch))) {
48
+            if (empty(array_intersect($this->IDs, $this->activeBranch))) {
49 49
                 $maxDepth = 1;
50 50
                 $this->config->setConfig(array('hideSubMenus' => 0));
51 51
             };
52
-        } else {
52
+        } else {
53 53
             $this->setActiveBranch($this->getHereId());
54 54
         }
55
-        if ($oIds = $this->getCFGDef('openIds')) {
55
+        if ($oIds = $this->getCFGDef('openIds')) {
56 56
             $maxDepth = 1;
57 57
             $oIds = $this->cleanIDs($oIds);
58 58
             $oIds[] = $this->getHereId();
59
-            foreach ($oIds as $id) {
60
-                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
59
+            foreach ($oIds as $id) {
60
+                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
61 61
                     $maxDepth = $c;
62 62
                 }
63 63
             }
@@ -65,44 +65,44 @@  discard block
 block discarded – undo
65 65
         }
66 66
         $currentLevel = &$this->currentLevel;
67 67
         $currentLevel = 1;
68
-        if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
68
+        if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
69 69
             $this->config->setConfig(array('showParent' => 0));
70 70
         }
71 71
         $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
72
-        while ($currentLevel <= $maxDepth) {
72
+        while ($currentLevel <= $maxDepth) {
73 73
             $orderBy = $this->getCFGDef('orderBy');
74
-            if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) {
74
+            if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) {
75 75
                 $docs = $this->getDocList();
76 76
                 $this->config->setConfig(array('showParent' => 0));
77
-            } else {
77
+            } else {
78 78
                 $docs = $this->getChildrenList();
79 79
             }
80
-            if ($currentLevel == 1 && $joinMenus) {
80
+            if ($currentLevel == 1 && $joinMenus) {
81 81
                 $tmp = array();
82 82
                 $display = 0;
83 83
                 $iteration = 1;
84
-                foreach ($docs as $id => $item) {
84
+                foreach ($docs as $id => $item) {
85 85
                     $tmp[$item['parent']][] = $item['id'];
86 86
                     $display++;
87 87
                 }
88
-                foreach ($tmp as $id => $item) {
89
-                    foreach ($item as $_id) {
88
+                foreach ($tmp as $id => $item) {
89
+                    foreach ($item as $_id) {
90 90
                         $docs[$_id]['_display'] = $display;
91 91
                         $docs[$_id]['iteration'] = $iteration++;
92 92
                     }
93 93
                 }
94 94
                 unset($tmp);
95
-            } else {
96
-                foreach ($docs as $id => &$item) {
95
+            } else {
96
+                foreach ($docs as $id => &$item) {
97 97
                     $parent = $item['parent'];
98
-                    if (!isset($this->display[$parent])) {
98
+                    if (!isset($this->display[$parent])) {
99 99
                         $this->display[$parent] = 1;
100 100
                     }
101 101
                     $item['iteration'] = $this->display[$parent]++;
102 102
                 }
103 103
             }
104 104
             $this->config->setConfig(array('orderBy' => $orderBy));
105
-            if (empty($docs)) {
105
+            if (empty($docs)) {
106 106
                 break;
107 107
             }
108 108
             $this->levels[$currentLevel++] = $docs;
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
             $this->AddTable = array();
111 111
         }
112 112
 
113
-        if ($tvlist == '') {
113
+        if ($tvlist == '') {
114 114
             $tvlist = $this->getCFGDef('tvList', '');
115 115
         }
116 116
 
117
-        if ($tvlist != '') {
117
+        if ($tvlist != '') {
118 118
             $ids = array();
119
-            foreach ($this->levels as $level => $docs) {
119
+            foreach ($this->levels as $level => $docs) {
120 120
                 $ids = array_merge($ids, array_keys($docs));
121 121
             }
122
-            if ($ids) {
122
+            if ($ids) {
123 123
                 $tv = $this->extTV->getTVList($ids, $tvlist);
124
-                if (!is_array($tv)) {
124
+                if (!is_array($tv)) {
125 125
                     $tv = array();
126 126
                 }
127 127
                 $this->docTvs = $tv;
128 128
             }
129 129
 
130 130
         }
131
-        if ($this->getCFGDef('countChildren', 0)) {
131
+        if ($this->getCFGDef('countChildren', 0)) {
132 132
             $this->countChildren();
133 133
         }
134 134
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
      * @param $id
141 141
      * @param int $maxDepth
142 142
      */
143
-    public function setActiveBranch($id, $maxDepth = 10)
144
-    {
143
+    public function setActiveBranch($id, $maxDepth = 10)
144
+    {
145 145
         $ids = array_values($this->modx->getParentIds($id, $maxDepth));
146 146
         $ids[] = $id;
147 147
         $ids[] = 0;
@@ -154,29 +154,29 @@  discard block
 block discarded – undo
154 154
     /**
155 155
      * Подсчет количества непосредственных дочерних документов
156 156
      */
157
-    public function countChildren()
158
-    {
157
+    public function countChildren()
158
+    {
159 159
         $ids = array();
160 160
         $out = &$this->countChildren;
161
-        foreach ($this->levels as $level => $docs) {
161
+        foreach ($this->levels as $level => $docs) {
162 162
             $ids = array_merge($ids, array_keys($docs));
163 163
         }
164 164
         $maxDepth = count($this->levels);
165 165
         $currentDepth = 1;
166
-        while ($currentDepth <= $maxDepth) {
166
+        while ($currentDepth <= $maxDepth) {
167 167
             $_ids = implode(',', $ids);
168
-            if (empty($_ids)) {
168
+            if (empty($_ids)) {
169 169
                 break;
170 170
             }
171 171
             $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`");
172 172
             $_ids = array();
173
-            while ($row = $this->modx->db->getRow($q)) {
173
+            while ($row = $this->modx->db->getRow($q)) {
174 174
                 $_ids[] = $row['parent'];
175 175
                 $out[$row['parent']] = $row['count'];
176 176
             }
177
-            if ($_ids) {
177
+            if ($_ids) {
178 178
                 $ids = $this->diff($ids, $_ids);
179
-            } else {
179
+            } else {
180 180
                 break;
181 181
             }
182 182
             $currentDepth++;
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
      * @param $a
190 190
      * @return array
191 191
      */
192
-    private function diff($b, $a)
193
-    {
192
+    private function diff($b, $a)
193
+    {
194 194
         $at = array_flip($a);
195 195
         $d = array();
196
-        foreach ($b as $i) {
197
-            if (!isset($at[$i])) {
196
+        foreach ($b as $i) {
197
+            if (!isset($at[$i])) {
198 198
                 $d[] = $i;
199 199
             }
200 200
         }
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
      * @param string $tpl шаблон
210 210
      * @return string
211 211
      */
212
-    public function render($tpl = '')
213
-    {
212
+    public function render($tpl = '')
213
+    {
214 214
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
215 215
         $out = $this->_render($tpl);
216 216
 
217
-        if ($out) {
217
+        if ($out) {
218 218
             $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
219 219
         }
220 220
         $this->debug->debugEnd('render');
@@ -226,43 +226,43 @@  discard block
 block discarded – undo
226 226
      * @param string $tpl
227 227
      * @return string
228 228
      */
229
-    public function _render($tpl = '')
230
-    {
229
+    public function _render($tpl = '')
230
+    {
231 231
         $currentLevel = &$this->currentLevel;
232 232
         $currentLevel = count($this->levels);
233 233
         $docs = $this->levels;
234 234
         /** @var prepare_DL_Extender_ $extPrepare */
235 235
         $extPrepare = $this->getExtender('prepare');
236
-        while ($currentLevel > 0) {
237
-            foreach ($docs[$currentLevel] as $id => &$data) {
238
-                if ($out = $this->prepareData($data)) {
239
-                    if (is_array($out)) {
236
+        while ($currentLevel > 0) {
237
+            foreach ($docs[$currentLevel] as $id => &$data) {
238
+                if ($out = $this->prepareData($data)) {
239
+                    if (is_array($out)) {
240 240
                         $data = $out;
241 241
                     }
242 242
                 };
243
-                if (!isset($data['maxLevel'])) {
243
+                if (!isset($data['maxLevel'])) {
244 244
                     $data['maxLevel'] = 1;
245 245
                     $docs[$currentLevel - 1][$data['parent']]['maxLevel'] = 0;
246 246
                 }
247 247
 
248
-                if ($extPrepare) {
248
+                if ($extPrepare) {
249 249
                     $data = $extPrepare->init($this, array(
250 250
                         'data'      => $data,
251 251
                         'nameParam' => 'prepare'
252 252
                     ));
253
-                    if (is_bool($data) && $data === false) {
253
+                    if (is_bool($data) && $data === false) {
254 254
                         continue;
255 255
                     }
256 256
                 }
257 257
 
258
-                if (isset($data['wrap'])) {
258
+                if (isset($data['wrap'])) {
259 259
                     $data['wrap'] = is_array($data['wrap']) ? $this->parseRow($data['wrap']) : $data['wrap'];
260 260
                     $data['wrap'] = $this->parseOuter($data);
261 261
                 }
262 262
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
263 263
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
264 264
                             $this->activeBranch));
265
-                if ($hideSubMenus) {
265
+                if ($hideSubMenus) {
266 266
                     $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data;
267 267
                 }
268 268
             }
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 
274 274
         $out = '';
275 275
         $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
276
-        foreach ($docs[0] as $id => $data) {
277
-            if (isset($data['wrap'])) {
278
-                if ($joinMenus) {
276
+        foreach ($docs[0] as $id => $data) {
277
+            if (isset($data['wrap'])) {
278
+                if ($joinMenus) {
279 279
                     $out .= $this->parseRow($data['wrap']);
280
-                } else {
280
+                } else {
281 281
                     $data['wrap'] = $this->parseRow($data['wrap']);
282 282
                     $out .= $this->parseOuter($data);
283 283
                 }
284 284
             }
285 285
         }
286
-        if ($joinMenus) {
286
+        if ($joinMenus) {
287 287
             $out = $this->parseOuter(array('wrap' => $out));
288 288
         }
289 289
 
@@ -295,33 +295,33 @@  discard block
 block discarded – undo
295 295
      * @param $data
296 296
      * @return array
297 297
      */
298
-    public function prepareData($data)
299
-    {
298
+    public function prepareData($data)
299
+    {
300 300
         /**
301 301
          * @var e_DL_Extender $extE
302 302
          */
303 303
         $extE = $this->getExtender('e', true, true);
304 304
         $id = $data['id'];
305
-        if (isset($this->docTvs[$id])) {
305
+        if (isset($this->docTvs[$id])) {
306 306
             $data = array_merge($data, $this->docTvs[$id]);
307 307
         }
308
-        if ($id == $this->getHereId()) {
308
+        if ($id == $this->getHereId()) {
309 309
             $data['here'] = 1;
310 310
         }
311
-        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
311
+        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
312 312
             $data['active'] = 1;
313 313
         }
314
-        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
314
+        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
315 315
             $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed';
316 316
         }
317 317
 
318
-        if (!isset($data['_display'])) {
318
+        if (!isset($data['_display'])) {
319 319
             $data['_display'] = $this->display[$data['parent']] - 1;
320 320
         }
321
-        if ($data['iteration'] == 1) {
321
+        if ($data['iteration'] == 1) {
322 322
             $data['first'] = 1;
323 323
         }
324
-        if ($data['iteration'] == $data['_display']) {
324
+        if ($data['iteration'] == $data['_display']) {
325 325
             $data['last'] = 1;
326 326
         }
327 327
 
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
         $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
330 330
         $data['level'] = $this->currentLevel;
331 331
         $data['url'] = $this->makeUrl($data);
332
-        if ($this->getCFGDef('countChildren', 0)) {
332
+        if ($this->getCFGDef('countChildren', 0)) {
333 333
             $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0;
334 334
         }
335 335
 
336
-        if ($out = $extE->init($this, compact('data'))) {
337
-            if (is_array($out)) {
336
+        if ($out = $extE->init($this, compact('data'))) {
337
+            if (is_array($out)) {
338 338
                 $data = $out;
339 339
             }
340 340
         }
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
      * @param array $data
348 348
      * @return string
349 349
      */
350
-    public function parseOuter($data = array())
351
-    {
350
+    public function parseOuter($data = array())
351
+    {
352 352
         $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>');
353 353
         $classes = '';
354 354
         $classNames = $this->getCFGDef('outerClass');
355
-        if ($this->currentLevel >= 1) {
355
+        if ($this->currentLevel >= 1) {
356 356
             $tpl = $this->getCFGDef('innerTpl', $tpl);
357 357
             $classNames = $this->getCFGDef('innerClass');
358 358
         }
359
-        if ($classNames) {
359
+        if ($classNames) {
360 360
             $classes = " class=\"{$classNames}\"";
361 361
         }
362 362
         $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl;
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
      * @param array $data
373 373
      * @return string
374 374
      */
375
-    public function parseRow($data = array())
376
-    {
375
+    public function parseRow($data = array())
376
+    {
377 377
         $out = '';
378
-        foreach ($data as $iteration => $item) {
378
+        foreach ($data as $iteration => $item) {
379 379
             $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item);
380 380
             $item = array_merge($item, $this->getClasses($item));
381 381
             $out .= $this->parseChunk($tpl, $item);
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
      * @param array $data
390 390
      * @return string
391 391
      */
392
-    protected function makeUrl($data = array())
393
-    {
392
+    protected function makeUrl($data = array())
393
+    {
394 394
         $out = '';
395
-        if ($this->getCFGDef('makeUrl', 1)) {
396
-            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
395
+        if ($this->getCFGDef('makeUrl', 1)) {
396
+            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
397 397
                 $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '',
398 398
                     $this->getCFGDef('urlScheme', '')) : $data['content'];
399
-            } else {
399
+            } else {
400 400
                 $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '',
401 401
                     $this->getCFGDef('urlScheme', '')) : '';
402 402
             }
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
      * Вовзращает id текущего документа
410 410
      * @return int
411 411
      */
412
-    public function getHereId()
413
-    {
414
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
412
+    public function getHereId()
413
+    {
414
+        if (!$hereId = (int)$this->getCFGDef('hereId')) {
415 415
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
416 416
         }
417 417
 
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
      * @param array $data
424 424
      * @return array
425 425
      */
426
-    protected function getClasses($data = array())
427
-    {
426
+    protected function getClasses($data = array())
427
+    {
428 428
         $classes = isset($data['classes']) ? $data['classes'] : array(
429 429
             'rowClass'     => '',
430 430
             'firstClass'   => '',
@@ -437,34 +437,34 @@  discard block
 block discarded – undo
437 437
             'oddClass'     => '',
438 438
             'evenClass'    => ''
439 439
         );
440
-        if (isset($data['state'])) {
440
+        if (isset($data['state'])) {
441 441
             $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']);
442 442
         }
443
-        if (isset($data['here'])) {
443
+        if (isset($data['here'])) {
444 444
             $classes['hereClass'] = $this->getCFGDef('hereClass', 'current');
445 445
         }
446
-        if (isset($data['active'])) {
446
+        if (isset($data['active'])) {
447 447
             $classes['activeClass'] = $this->getCFGDef('activeClass', 'active');
448 448
         }
449 449
         $classes['rowClass'] = $this->getCFGDef('rowClass');
450
-        if ($data['iteration'] % 2 == 1) {
450
+        if ($data['iteration'] % 2 == 1) {
451 451
             $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd');
452
-        } else {
452
+        } else {
453 453
             $classes['evenClass'] = $this->getCFGDef('evenClass', 'even');
454 454
         }
455
-        if (isset($data['first'])) {
455
+        if (isset($data['first'])) {
456 456
             $classes['firstClass'] = $this->getCFGDef('firstClass', 'first');
457 457
         }
458
-        if (isset($data['last'])) {
458
+        if (isset($data['last'])) {
459 459
             $classes['lastClass'] = $this->getCFGDef('lastClass', 'last');
460 460
         }
461
-        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
461
+        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
462 462
             $classes['levelClass'] = $levelClass . $data['level'];
463 463
         }
464
-        if (isset($data['type']) && $data['type'] == 'reference') {
464
+        if (isset($data['type']) && $data['type'] == 'reference') {
465 465
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
466 466
         }
467
-        if (!empty($data['wrap'])) {
467
+        if (!empty($data['wrap'])) {
468 468
             $classes['parentClass'] = $this->getCFGDef('parentClass');
469 469
         }
470 470
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -479,28 +479,28 @@  discard block
 block discarded – undo
479 479
      * @param array $data
480 480
      * @return string
481 481
      */
482
-    protected function getRowTemplate($data = array())
483
-    {
482
+    protected function getRowTemplate($data = array())
483
+    {
484 484
         $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>');
485
-        if ($data['wrap']) {
485
+        if ($data['wrap']) {
486 486
             $tpl = $this->getCFGDef('parentRowTpl',
487 487
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
488 488
             if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
489 489
                         'category') !== false)
490
-            ) {
490
+            ) {
491 491
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
492
-            } elseif ($data['here']) {
492
+            } elseif ($data['here']) {
493 493
                 $tpl = $this->getCFGDef('parentRowHereTpl', $tpl);
494
-            } elseif ($data['active']) {
494
+            } elseif ($data['active']) {
495 495
                 $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl);
496 496
             }
497
-        } elseif ($data['level'] > 1) {
497
+        } elseif ($data['level'] > 1) {
498 498
             $tpl = $this->getCFGDef('innerRowTpl', $tpl);
499
-            if ($data['here']) {
499
+            if ($data['here']) {
500 500
                 $tpl = $this->getCFGDef('innerRowHereTpl', $tpl);
501 501
             }
502
-        } else {
503
-            if ($data['here']) {
502
+        } else {
503
+            if ($data['here']) {
504 504
                 $tpl = $this->getCFGDef('rowHereTpl', $tpl);
505 505
             }
506 506
         }
@@ -514,32 +514,32 @@  discard block
 block discarded – undo
514 514
      * @param array $array
515 515
      * @return string
516 516
      */
517
-    public function getJSON($data, $fields, $array = array())
518
-    {
517
+    public function getJSON($data, $fields, $array = array())
518
+    {
519 519
         $currentLevel = &$this->currentLevel;
520 520
         $currentLevel = count($this->levels);
521 521
         $docs = $this->levels;
522 522
         /** @var prepare_DL_Extender_ $extPrepare */
523 523
         $extPrepare = $this->getExtender('prepare');
524 524
 
525
-        while ($currentLevel > 0) {
526
-            foreach ($docs[$currentLevel] as $id => &$data) {
527
-                if ($out = $this->prepareData($data)) {
528
-                    if (is_array($out)) {
525
+        while ($currentLevel > 0) {
526
+            foreach ($docs[$currentLevel] as $id => &$data) {
527
+                if ($out = $this->prepareData($data)) {
528
+                    if (is_array($out)) {
529 529
                         $data = $out;
530 530
                     }
531 531
                 };
532 532
 
533
-                if (isset($data['here']) || isset($data['active'])) {
533
+                if (isset($data['here']) || isset($data['active'])) {
534 534
                     $docs[$currentLevel - 1][$data['parent']]['active'] = 1;
535 535
                 }
536 536
 
537
-                if ($extPrepare) {
537
+                if ($extPrepare) {
538 538
                     $data = $extPrepare->init($this, array(
539 539
                         'data'      => $data,
540 540
                         'nameParam' => 'prepare'
541 541
                     ));
542
-                    if (is_bool($data) && $data === false) {
542
+                    if (is_bool($data) && $data === false) {
543 543
                         continue;
544 544
                     }
545 545
                 }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
548 548
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'],
549 549
                             $this->activeBranch));
550
-                if ($hideSubMenus) {
550
+                if ($hideSubMenus) {
551 551
                     $docs[$currentLevel - 1][$data['parent']]['children'][] = $data;
552 552
                 }
553 553
             }
@@ -557,11 +557,11 @@  discard block
 block discarded – undo
557 557
         unset($data);
558 558
         $out = array();
559 559
         $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
560
-        foreach ($docs[0] as $id => $data) {
561
-            if (isset($data['children'])) {
562
-                if ($joinMenus) {
560
+        foreach ($docs[0] as $id => $data) {
561
+            if (isset($data['children'])) {
562
+                if ($joinMenus) {
563 563
                     $out = array_merge($out, $data['children']);
564
-                } else {
564
+                } else {
565 565
                     $out[] = $data['children'];
566 566
                 }
567 567
             }
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
579 579
      * @return mixed значение из конфига
580 580
      */
581
-    public function getCFGDef($name, $def = null)
582
-    {
581
+    public function getCFGDef($name, $def = null)
582
+    {
583 583
         return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def));
584 584
     }
585 585
 }
Please login to merge, or discard this patch.