Completed
Push — master ( 23e8d4...aa686f )
by
unknown
02:03
created
assets/snippets/DocLister/core/controller/site_content_menu.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             }
94 94
             if ($ids) {
95 95
                 $tv = $this->extTV->getTVList($ids, $tvlist);
96
-                if (!is_array($tv)) {
96
+                if ( ! is_array($tv)) {
97 97
                     $tv = array();
98 98
                 }
99 99
                 $this->docTvs = $tv;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         $at = array_flip($a);
167 167
         $d = array();
168 168
         foreach ($b as $i) {
169
-            if (!isset($at[$i])) {
169
+            if ( ! isset($at[$i])) {
170 170
                 $d[] = $i;
171 171
             }
172 172
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                     }
215 215
                 };
216 216
 
217
-                if (!isset($data['maxLevel'])) {
217
+                if ( ! isset($data['maxLevel'])) {
218 218
                     $data['maxLevel'] = 1;
219 219
                     $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0;
220 220
                 }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                     $data['wrap'] = $this->parseOuter($data);
239 239
                 }
240 240
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
241
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
241
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
242 242
                             $this->activeBranch));
243 243
                 if ($hideSubMenus) {
244 244
                     $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         }
250 250
         unset($data);
251 251
         $out = '';
252
-        $joinMenus = $this->getCFGDef('joinMenus',0) && !$this->getCFGDef('showParents',0);
252
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
253 253
         foreach ($docs[0] as $id => $data) {
254 254
             if (isset($data['wrap'])) {
255 255
                 if ($joinMenus) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         if ($id == $this->getHereId()) {
284 284
             $data['here'] = 1;
285 285
         }
286
-        if (in_array($id,$this->activeBranch)) {
286
+        if (in_array($id, $this->activeBranch)) {
287 287
             $data['active'] = 1;
288 288
         }
289 289
         if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         }
292 292
 
293 293
         $titleField = $this->getCFGDef('titleField', 'title');
294
-        $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
294
+        $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
295 295
         $data['level'] = $this->currentLevel;
296 296
         $data['url'] = $this->makeUrl($data);
297 297
         if ($this->getCFGDef('countChildren', 1)) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function getHereId()
386 386
     {
387
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
387
+        if ( ! $hereId = (int)$this->getCFGDef('hereId')) {
388 388
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
389 389
         }
390 390
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         if (isset($data['type']) && $data['type'] == 'reference') {
438 438
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
439 439
         }
440
-        if (!empty($data['wrap'])) {
440
+        if ( ! empty($data['wrap'])) {
441 441
             $classes['parentClass'] = $this->getCFGDef('parentClass');
442 442
         }
443 443
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         if ($data['wrap']) {
459 459
             $tpl = $this->getCFGDef('parentRowTpl',
460 460
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
461
-            if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
461
+            if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
462 462
                         'category') !== false)
463 463
             ) {
464 464
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
                 }
519 519
 
520 520
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
521
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
521
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
522 522
                             $this->activeBranch));
523 523
                 if ($hideSubMenus) {
524 524
                     $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data;
Please login to merge, or discard this patch.
Braces   +117 added lines, -115 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();
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
      * @param mixed $IDs список id документов по которым необходима выборка
25 25
      * @return array очищенный массив
26 26
      */
27
-    public function setIDs($IDs)
28
-    {
27
+    public function setIDs($IDs)
28
+    {
29 29
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
30 30
         $IDs = $this->cleanIDs($IDs);
31 31
         $this->debug->debugEnd("setIDs");
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
      * @param string $tvlist
38 38
      * @return array
39 39
      */
40
-    public function getDocs($tvlist = '')
41
-    {
40
+    public function getDocs($tvlist = '')
41
+    {
42 42
         $maxDepth = $this->getCFGDef('maxDepth', 10);
43 43
         //TODO кэширование
44
-        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
44
+        if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) {
45 45
             $maxDepth = $this->setActiveBranch($this->getHereId());
46
-        } else {
46
+        } else {
47 47
             $this->setActiveBranch($this->getHereId());
48 48
         }
49
-        if ($oIds = $this->getCFGDef('openIds')) {
49
+        if ($oIds = $this->getCFGDef('openIds')) {
50 50
             $maxDepth = 1;
51 51
             $oIds = $this->cleanIDs($oIds);
52 52
             $oIds[] = $this->getHereId();
53
-            foreach ($oIds as $id) {
54
-                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
53
+            foreach ($oIds as $id) {
54
+                if (($c = $this->setActiveBranch($id)) > $maxDepth) {
55 55
                     $maxDepth = $c;
56 56
                 }
57 57
             }
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         }
60 60
         $currentLevel = &$this->currentLevel;
61 61
         $currentLevel = 1;
62
-        if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
62
+        if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
63 63
             $this->config->setConfig(array('showParent' => 0));
64 64
         }
65
-        if ($this->getCFGDef('showParent', 0)) {
65
+        if ($this->getCFGDef('showParent', 0)) {
66 66
             $orderBy = $this->getCFGDef('orderBy');
67 67
             $docs = $this->getDocList();
68 68
             $this->config->setConfig(array('orderBy' => $orderBy));
@@ -70,37 +70,37 @@  discard block
 block discarded – undo
70 70
             $this->IDs = $ids = array_keys($docs);
71 71
             $this->config->setConfig(array('showParent' => 0));
72 72
         }
73
-        while ($currentLevel <= $maxDepth) {
73
+        while ($currentLevel <= $maxDepth) {
74 74
             $orderBy = $this->getCFGDef('orderBy');
75 75
             $docs = $this->getChildrenList();
76 76
             $this->config->setConfig(array('orderBy' => $orderBy));
77
-            if (empty($docs)) {
77
+            if (empty($docs)) {
78 78
                 break;
79 79
             }
80 80
             $this->levels[$currentLevel++] = $docs;
81 81
             $this->IDs = array_keys($docs);
82 82
         }
83 83
 
84
-        if ($tvlist == '') {
84
+        if ($tvlist == '') {
85 85
             $tvlist = $this->getCFGDef('tvList', '');
86 86
         }
87 87
 
88
-        if ($tvlist != '') {
88
+        if ($tvlist != '') {
89 89
             $this->extTV->getAllTV_Name();
90 90
             $ids = array();
91
-            foreach ($this->levels as $level => $docs) {
91
+            foreach ($this->levels as $level => $docs) {
92 92
                 $ids = array_merge($ids, array_keys($docs));
93 93
             }
94
-            if ($ids) {
94
+            if ($ids) {
95 95
                 $tv = $this->extTV->getTVList($ids, $tvlist);
96
-                if (!is_array($tv)) {
96
+                if (!is_array($tv)) {
97 97
                     $tv = array();
98 98
                 }
99 99
                 $this->docTvs = $tv;
100 100
             }
101 101
 
102 102
         }
103
-        if ($this->getCFGDef('countChildren', 0)) {
103
+        if ($this->getCFGDef('countChildren', 0)) {
104 104
             $this->countChildren();
105 105
         }
106 106
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      * @param $id
113 113
      * @param int $maxDepth
114 114
      */
115
-    public function setActiveBranch($id, $maxDepth = 10)
116
-    {
115
+    public function setActiveBranch($id, $maxDepth = 10)
116
+    {
117 117
         $ids = array_values($this->modx->getParentIds($id, $maxDepth));
118 118
         $ids[] = $id;
119 119
         $ids[] = 0;
@@ -126,29 +126,29 @@  discard block
 block discarded – undo
126 126
     /**
127 127
      * Подсчет количества непосредственных дочерних документов
128 128
      */
129
-    public function countChildren()
130
-    {
129
+    public function countChildren()
130
+    {
131 131
         $ids = array();
132 132
         $out = &$this->countChildren;
133
-        foreach ($this->levels as $level => $docs) {
133
+        foreach ($this->levels as $level => $docs) {
134 134
             $ids = array_merge($ids, array_keys($docs));
135 135
         }
136 136
         $maxDepth = count($this->levels);
137 137
         $currentDepth = 1;
138
-        while ($currentDepth <= $maxDepth) {
138
+        while ($currentDepth <= $maxDepth) {
139 139
             $_ids = implode(',', $ids);
140
-            if (empty($_ids)) {
140
+            if (empty($_ids)) {
141 141
                 break;
142 142
             }
143 143
             $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`");
144 144
             $_ids = array();
145
-            while ($row = $this->modx->db->getRow($q)) {
145
+            while ($row = $this->modx->db->getRow($q)) {
146 146
                 $_ids[] = $row['parent'];
147 147
                 $out[$row['parent']] = $row['count'];
148 148
             }
149
-            if ($_ids) {
149
+            if ($_ids) {
150 150
                 $ids = $this->diff($ids, $_ids);
151
-            } else {
151
+            } else {
152 152
                 break;
153 153
             }
154 154
             $currentDepth++;
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
      * @param $a
162 162
      * @return array
163 163
      */
164
-    private function diff($b, $a)
165
-    {
164
+    private function diff($b, $a)
165
+    {
166 166
         $at = array_flip($a);
167 167
         $d = array();
168
-        foreach ($b as $i) {
169
-            if (!isset($at[$i])) {
168
+        foreach ($b as $i) {
169
+            if (!isset($at[$i])) {
170 170
                 $d[] = $i;
171 171
             }
172 172
         }
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
      * @param string $tpl шаблон
182 182
      * @return string
183 183
      */
184
-    public function render($tpl = '')
185
-    {
184
+    public function render($tpl = '')
185
+    {
186 186
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
187 187
         $out = $this->_render($tpl);
188 188
 
189
-        if ($out) {
189
+        if ($out) {
190 190
             $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
191 191
         }
192 192
         $this->debug->debugEnd('render');
@@ -198,49 +198,49 @@  discard block
 block discarded – undo
198 198
      * @param string $tpl
199 199
      * @return string
200 200
      */
201
-    public function _render($tpl = '')
202
-    {
201
+    public function _render($tpl = '')
202
+    {
203 203
         $currentLevel = &$this->currentLevel;
204 204
         $currentLevel = count($this->levels);
205 205
         $docs = $this->levels;
206 206
         /** @var prepare_DL_Extender_ $extPrepare */
207 207
         $extPrepare = $this->getExtender('prepare');
208 208
 
209
-        while ($currentLevel > 0) {
210
-            foreach ($docs[$currentLevel] as $id => &$data) {
211
-                if ($out = $this->prepareData($data)) {
212
-                    if (is_array($out)) {
209
+        while ($currentLevel > 0) {
210
+            foreach ($docs[$currentLevel] as $id => &$data) {
211
+                if ($out = $this->prepareData($data)) {
212
+                    if (is_array($out)) {
213 213
                         $data = $out;
214 214
                     }
215 215
                 };
216 216
 
217
-                if (!isset($data['maxLevel'])) {
217
+                if (!isset($data['maxLevel'])) {
218 218
                     $data['maxLevel'] = 1;
219 219
                     $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0;
220 220
                 }
221 221
 
222
-                if (isset($data['here']) || isset($data['active'])) {
222
+                if (isset($data['here']) || isset($data['active'])) {
223 223
                     $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1;
224 224
                 }
225 225
 
226
-                if ($extPrepare) {
226
+                if ($extPrepare) {
227 227
                     $data = $extPrepare->init($this, array(
228 228
                         'data'      => $data,
229 229
                         'nameParam' => 'prepare'
230 230
                     ));
231
-                    if (is_bool($data) && $data === false) {
231
+                    if (is_bool($data) && $data === false) {
232 232
                         continue;
233 233
                     }
234 234
                 }
235 235
 
236
-                if (isset($data['wrap'])) {
236
+                if (isset($data['wrap'])) {
237 237
                     $data['wrap'] = is_array($data['wrap']) ? $this->parseRow($data['wrap']) : $data['wrap'];
238 238
                     $data['wrap'] = $this->parseOuter($data);
239 239
                 }
240 240
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
241 241
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
242 242
                             $this->activeBranch));
243
-                if ($hideSubMenus) {
243
+                if ($hideSubMenus) {
244 244
                     $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data;
245 245
                 }
246 246
             }
@@ -250,17 +250,19 @@  discard block
 block discarded – undo
250 250
         unset($data);
251 251
         $out = '';
252 252
         $joinMenus = $this->getCFGDef('joinMenus',0) && !$this->getCFGDef('showParents',0);
253
-        foreach ($docs[0] as $id => $data) {
254
-            if (isset($data['wrap'])) {
255
-                if ($joinMenus) {
253
+        foreach ($docs[0] as $id => $data) {
254
+            if (isset($data['wrap'])) {
255
+                if ($joinMenus) {
256 256
                     $out .= $this->parseRow($data['wrap']);
257
-                } else {
257
+                } else {
258 258
                     $data['wrap'] = $this->parseRow($data['wrap']);
259 259
                     $out .= $this->parseOuter($data);
260 260
                 }
261 261
             }
262 262
         }
263
-        if ($joinMenus) $out = $this->parseOuter(array('wrap'=>$out));
263
+        if ($joinMenus) {
264
+            $out = $this->parseOuter(array('wrap'=>$out));
265
+        }
264 266
 
265 267
         return $out;
266 268
     }
@@ -270,23 +272,23 @@  discard block
 block discarded – undo
270 272
      * @param $data
271 273
      * @return array
272 274
      */
273
-    public function prepareData($data)
274
-    {
275
+    public function prepareData($data)
276
+    {
275 277
         /**
276 278
          * @var e_DL_Extender $extE
277 279
          */
278 280
         $extE = $this->getExtender('e', true, true);
279 281
         $id = $data['id'];
280
-        if (isset($this->docTvs[$id])) {
282
+        if (isset($this->docTvs[$id])) {
281 283
             $data = array_merge($data, $this->docTvs[$id]);
282 284
         }
283
-        if ($id == $this->getHereId()) {
285
+        if ($id == $this->getHereId()) {
284 286
             $data['here'] = 1;
285 287
         }
286
-        if (in_array($id,$this->activeBranch)) {
288
+        if (in_array($id,$this->activeBranch)) {
287 289
             $data['active'] = 1;
288 290
         }
289
-        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
291
+        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
290 292
             $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed';
291 293
         }
292 294
 
@@ -294,12 +296,12 @@  discard block
 block discarded – undo
294 296
         $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
295 297
         $data['level'] = $this->currentLevel;
296 298
         $data['url'] = $this->makeUrl($data);
297
-        if ($this->getCFGDef('countChildren', 1)) {
299
+        if ($this->getCFGDef('countChildren', 1)) {
298 300
             $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0;
299 301
         }
300 302
 
301
-        if ($out = $extE->init($this, compact('data'))) {
302
-            if (is_array($out)) {
303
+        if ($out = $extE->init($this, compact('data'))) {
304
+            if (is_array($out)) {
303 305
                 $data = $out;
304 306
             }
305 307
         }
@@ -312,16 +314,16 @@  discard block
 block discarded – undo
312 314
      * @param array $data
313 315
      * @return string
314 316
      */
315
-    public function parseOuter($data = array())
316
-    {
317
+    public function parseOuter($data = array())
318
+    {
317 319
         $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>');
318 320
         $classes = '';
319 321
         $classNames = $this->getCFGDef('outerClass');
320
-        if ($this->currentLevel >= 1) {
322
+        if ($this->currentLevel >= 1) {
321 323
             $tpl = $this->getCFGDef('innerTpl', $tpl);
322 324
             $classNames = $this->getCFGDef('innerClass');
323 325
         }
324
-        if ($classNames) {
326
+        if ($classNames) {
325 327
             $classes = " class=\"{$classNames}\"";
326 328
         }
327 329
         $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl;
@@ -337,16 +339,16 @@  discard block
 block discarded – undo
337 339
      * @param array $data
338 340
      * @return string
339 341
      */
340
-    public function parseRow($data = array())
341
-    {
342
+    public function parseRow($data = array())
343
+    {
342 344
         $out = '';
343 345
         $maxIteration = count($data) - 1;
344
-        foreach ($data as $iteration => $item) {
346
+        foreach ($data as $iteration => $item) {
345 347
             $item['iteration'] = $iteration + 1;
346
-            if ($iteration == 0) {
348
+            if ($iteration == 0) {
347 349
                 $item['first'] = 1;
348 350
             }
349
-            if ($iteration == $maxIteration) {
351
+            if ($iteration == $maxIteration) {
350 352
                 $item['last'] = 1;
351 353
             }
352 354
             $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item);
@@ -362,14 +364,14 @@  discard block
 block discarded – undo
362 364
      * @param array $data
363 365
      * @return string
364 366
      */
365
-    protected function makeUrl($data = array())
366
-    {
367
+    protected function makeUrl($data = array())
368
+    {
367 369
         $out = '';
368
-        if ($this->getCFGDef('makeUrl', 1)) {
369
-            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
370
+        if ($this->getCFGDef('makeUrl', 1)) {
371
+            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
370 372
                 $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '',
371 373
                     $this->getCFGDef('urlScheme', '')) : $data['content'];
372
-            } else {
374
+            } else {
373 375
                 $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '',
374 376
                     $this->getCFGDef('urlScheme', '')) : '';
375 377
             }
@@ -382,9 +384,9 @@  discard block
 block discarded – undo
382 384
      * Вовзращает id текущего документа
383 385
      * @return int
384 386
      */
385
-    public function getHereId()
386
-    {
387
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
387
+    public function getHereId()
388
+    {
389
+        if (!$hereId = (int)$this->getCFGDef('hereId')) {
388 390
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
389 391
         }
390 392
 
@@ -396,8 +398,8 @@  discard block
 block discarded – undo
396 398
      * @param array $data
397 399
      * @return array
398 400
      */
399
-    protected function getClasses($data = array())
400
-    {
401
+    protected function getClasses($data = array())
402
+    {
401 403
         $classes = isset($data['classes']) ? $data['classes'] : array(
402 404
             'rowClass'     => '',
403 405
             'firstClass'   => '',
@@ -410,34 +412,34 @@  discard block
 block discarded – undo
410 412
             'oddClass'     => '',
411 413
             'evenClass'    => ''
412 414
         );
413
-        if (isset($data['state'])) {
415
+        if (isset($data['state'])) {
414 416
             $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']);
415 417
         }
416
-        if (isset($data['here'])) {
418
+        if (isset($data['here'])) {
417 419
             $classes['hereClass'] = $this->getCFGDef('hereClass', 'current');
418 420
         }
419
-        if (isset($data['active'])) {
421
+        if (isset($data['active'])) {
420 422
             $classes['activeClass'] = $this->getCFGDef('activeClass', 'active');
421 423
         }
422 424
         $classes['rowClass'] = $this->getCFGDef('rowClass');
423
-        if ($data['iteration'] % 2 == 1) {
425
+        if ($data['iteration'] % 2 == 1) {
424 426
             $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd');
425
-        } else {
427
+        } else {
426 428
             $classes['evenClass'] = $this->getCFGDef('evenClass', 'even');
427 429
         }
428
-        if (isset($data['first'])) {
430
+        if (isset($data['first'])) {
429 431
             $classes['firstClass'] = $this->getCFGDef('firstClass', 'first');
430 432
         }
431
-        if (isset($data['last'])) {
433
+        if (isset($data['last'])) {
432 434
             $classes['lastClass'] = $this->getCFGDef('lastClass', 'last');
433 435
         }
434
-        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
436
+        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
435 437
             $classes['levelClass'] = $levelClass . $data['level'];
436 438
         }
437
-        if (isset($data['type']) && $data['type'] == 'reference') {
439
+        if (isset($data['type']) && $data['type'] == 'reference') {
438 440
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
439 441
         }
440
-        if (!empty($data['wrap'])) {
442
+        if (!empty($data['wrap'])) {
441 443
             $classes['parentClass'] = $this->getCFGDef('parentClass');
442 444
         }
443 445
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -452,28 +454,28 @@  discard block
 block discarded – undo
452 454
      * @param array $data
453 455
      * @return string
454 456
      */
455
-    protected function getRowTemplate($data = array())
456
-    {
457
+    protected function getRowTemplate($data = array())
458
+    {
457 459
         $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>');
458
-        if ($data['wrap']) {
460
+        if ($data['wrap']) {
459 461
             $tpl = $this->getCFGDef('parentRowTpl',
460 462
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
461 463
             if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
462 464
                         'category') !== false)
463
-            ) {
465
+            ) {
464 466
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
465
-            } elseif ($data['here']) {
467
+            } elseif ($data['here']) {
466 468
                 $tpl = $this->getCFGDef('parentRowHereTpl', $tpl);
467
-            } elseif ($data['active']) {
469
+            } elseif ($data['active']) {
468 470
                 $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl);
469 471
             }
470
-        } elseif ($data['level'] > 1) {
472
+        } elseif ($data['level'] > 1) {
471 473
             $tpl = $this->getCFGDef('innerRowTpl', $tpl);
472
-            if ($data['here']) {
474
+            if ($data['here']) {
473 475
                 $tpl = $this->getCFGDef('innerRowHereTpl', $tpl);
474 476
             }
475
-        } else {
476
-            if ($data['here']) {
477
+        } else {
478
+            if ($data['here']) {
477 479
                 $tpl = $this->getCFGDef('rowHereTpl', $tpl);
478 480
             }
479 481
         }
@@ -487,32 +489,32 @@  discard block
 block discarded – undo
487 489
      * @param array $array
488 490
      * @return string
489 491
      */
490
-    public function getJSON($data, $fields, $array = array())
491
-    {
492
+    public function getJSON($data, $fields, $array = array())
493
+    {
492 494
         $currentLevel = &$this->currentLevel;
493 495
         $currentLevel = count($this->levels);
494 496
         $docs = $this->levels;
495 497
         /** @var prepare_DL_Extender_ $extPrepare */
496 498
         $extPrepare = $this->getExtender('prepare');
497 499
 
498
-        while ($currentLevel > 0) {
499
-            foreach ($docs[$currentLevel] as $id => &$data) {
500
-                if ($out = $this->prepareData($data)) {
501
-                    if (is_array($out)) {
500
+        while ($currentLevel > 0) {
501
+            foreach ($docs[$currentLevel] as $id => &$data) {
502
+                if ($out = $this->prepareData($data)) {
503
+                    if (is_array($out)) {
502 504
                         $data = $out;
503 505
                     }
504 506
                 };
505 507
 
506
-                if (isset($data['here']) || isset($data['active'])) {
508
+                if (isset($data['here']) || isset($data['active'])) {
507 509
                     $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1;
508 510
                 }
509 511
 
510
-                if ($extPrepare) {
512
+                if ($extPrepare) {
511 513
                     $data = $extPrepare->init($this, array(
512 514
                         'data'      => $data,
513 515
                         'nameParam' => 'prepare'
514 516
                     ));
515
-                    if (is_bool($data) && $data === false) {
517
+                    if (is_bool($data) && $data === false) {
516 518
                         continue;
517 519
                     }
518 520
                 }
@@ -520,7 +522,7 @@  discard block
 block discarded – undo
520 522
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
521 523
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
522 524
                             $this->activeBranch));
523
-                if ($hideSubMenus) {
525
+                if ($hideSubMenus) {
524 526
                     $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data;
525 527
                 }
526 528
             }
@@ -542,8 +544,8 @@  discard block
 block discarded – undo
542 544
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
543 545
      * @return mixed значение из конфига
544 546
      */
545
-    public function getCFGDef($name, $def = null)
546
-    {
547
+    public function getCFGDef($name, $def = null)
548
+    {
547 549
         return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def));
548 550
     }
549 551
 }
Please login to merge, or discard this patch.