Completed
Push — master ( 655371...c9d81d )
by
unknown
02:53
created
assets/snippets/DocLister/core/controller/site_content_menu.php 2 patches
Spacing   +12 added lines, -12 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
                 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                     $data['wrap'] = $this->parseOuter($data);
235 235
                 }
236 236
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
237
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
237
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
238 238
                             $this->activeBranch));
239 239
                 if ($hideSubMenus) {
240 240
                     $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         }
246 246
         unset($data);
247 247
         $out = '';
248
-        $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
248
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
249 249
         foreach ($docs[0] as $id => $data) {
250 250
             if (isset($data['wrap'])) {
251 251
                 if ($joinMenus) {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         if ($id == $this->getHereId()) {
282 282
             $data['here'] = 1;
283 283
         }
284
-        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
284
+        if ( ! isset($data['here']) && in_array($id, $this->activeBranch)) {
285 285
             $data['active'] = 1;
286 286
         }
287 287
         if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         $titleField = $this->getCFGDef('titleField', 'title');
292
-        $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
292
+        $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
293 293
         $data['level'] = $this->currentLevel;
294 294
         $data['url'] = $this->makeUrl($data);
295 295
         if ($this->getCFGDef('countChildren', 0)) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function getHereId()
384 384
     {
385
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
385
+        if ( ! $hereId = (int)$this->getCFGDef('hereId')) {
386 386
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
387 387
         }
388 388
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         if (isset($data['type']) && $data['type'] == 'reference') {
436 436
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
437 437
         }
438
-        if (!empty($data['wrap'])) {
438
+        if ( ! empty($data['wrap'])) {
439 439
             $classes['parentClass'] = $this->getCFGDef('parentClass');
440 440
         }
441 441
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         if ($data['wrap']) {
457 457
             $tpl = $this->getCFGDef('parentRowTpl',
458 458
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
459
-            if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
459
+            if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
460 460
                         'category') !== false)
461 461
             ) {
462 462
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
                 }
517 517
 
518 518
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
519
-                $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
519
+                $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
520 520
                             $this->activeBranch));
521 521
                 if ($hideSubMenus) {
522 522
                     $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         }
528 528
         unset($data);
529 529
         $out = array();
530
-        $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
530
+        $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0);
531 531
         foreach ($docs[0] as $id => $data) {
532 532
             if (isset($data['children'])) {
533 533
                 if ($joinMenus) {
Please login to merge, or discard this patch.
Braces   +118 added lines, -118 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,45 +198,45 @@  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 ($extPrepare) {
222
+                if ($extPrepare) {
223 223
                     $data = $extPrepare->init($this, array(
224 224
                         'data'      => $data,
225 225
                         'nameParam' => 'prepare'
226 226
                     ));
227
-                    if (is_bool($data) && $data === false) {
227
+                    if (is_bool($data) && $data === false) {
228 228
                         continue;
229 229
                     }
230 230
                 }
231 231
 
232
-                if (isset($data['wrap'])) {
232
+                if (isset($data['wrap'])) {
233 233
                     $data['wrap'] = is_array($data['wrap']) ? $this->parseRow($data['wrap']) : $data['wrap'];
234 234
                     $data['wrap'] = $this->parseOuter($data);
235 235
                 }
236 236
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
237 237
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
238 238
                             $this->activeBranch));
239
-                if ($hideSubMenus) {
239
+                if ($hideSubMenus) {
240 240
                     $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data;
241 241
                 }
242 242
             }
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
         unset($data);
247 247
         $out = '';
248 248
         $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
249
-        foreach ($docs[0] as $id => $data) {
250
-            if (isset($data['wrap'])) {
251
-                if ($joinMenus) {
249
+        foreach ($docs[0] as $id => $data) {
250
+            if (isset($data['wrap'])) {
251
+                if ($joinMenus) {
252 252
                     $out .= $this->parseRow($data['wrap']);
253
-                } else {
253
+                } else {
254 254
                     $data['wrap'] = $this->parseRow($data['wrap']);
255 255
                     $out .= $this->parseOuter($data);
256 256
                 }
257 257
             }
258 258
         }
259
-        if ($joinMenus) {
259
+        if ($joinMenus) {
260 260
             $out = $this->parseOuter(array('wrap' => $out));
261 261
         }
262 262
 
@@ -268,23 +268,23 @@  discard block
 block discarded – undo
268 268
      * @param $data
269 269
      * @return array
270 270
      */
271
-    public function prepareData($data)
272
-    {
271
+    public function prepareData($data)
272
+    {
273 273
         /**
274 274
          * @var e_DL_Extender $extE
275 275
          */
276 276
         $extE = $this->getExtender('e', true, true);
277 277
         $id = $data['id'];
278
-        if (isset($this->docTvs[$id])) {
278
+        if (isset($this->docTvs[$id])) {
279 279
             $data = array_merge($data, $this->docTvs[$id]);
280 280
         }
281
-        if ($id == $this->getHereId()) {
281
+        if ($id == $this->getHereId()) {
282 282
             $data['here'] = 1;
283 283
         }
284
-        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
284
+        if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
285 285
             $data['active'] = 1;
286 286
         }
287
-        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
287
+        if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
288 288
             $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed';
289 289
         }
290 290
 
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
         $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle'];
293 293
         $data['level'] = $this->currentLevel;
294 294
         $data['url'] = $this->makeUrl($data);
295
-        if ($this->getCFGDef('countChildren', 0)) {
295
+        if ($this->getCFGDef('countChildren', 0)) {
296 296
             $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0;
297 297
         }
298 298
 
299
-        if ($out = $extE->init($this, compact('data'))) {
300
-            if (is_array($out)) {
299
+        if ($out = $extE->init($this, compact('data'))) {
300
+            if (is_array($out)) {
301 301
                 $data = $out;
302 302
             }
303 303
         }
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
      * @param array $data
311 311
      * @return string
312 312
      */
313
-    public function parseOuter($data = array())
314
-    {
313
+    public function parseOuter($data = array())
314
+    {
315 315
         $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>');
316 316
         $classes = '';
317 317
         $classNames = $this->getCFGDef('outerClass');
318
-        if ($this->currentLevel >= 1) {
318
+        if ($this->currentLevel >= 1) {
319 319
             $tpl = $this->getCFGDef('innerTpl', $tpl);
320 320
             $classNames = $this->getCFGDef('innerClass');
321 321
         }
322
-        if ($classNames) {
322
+        if ($classNames) {
323 323
             $classes = " class=\"{$classNames}\"";
324 324
         }
325 325
         $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl;
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
      * @param array $data
336 336
      * @return string
337 337
      */
338
-    public function parseRow($data = array())
339
-    {
338
+    public function parseRow($data = array())
339
+    {
340 340
         $out = '';
341 341
         $maxIteration = count($data) - 1;
342
-        foreach ($data as $iteration => $item) {
342
+        foreach ($data as $iteration => $item) {
343 343
             $item['iteration'] = $iteration + 1;
344
-            if ($iteration == 0) {
344
+            if ($iteration == 0) {
345 345
                 $item['first'] = 1;
346 346
             }
347
-            if ($iteration == $maxIteration) {
347
+            if ($iteration == $maxIteration) {
348 348
                 $item['last'] = 1;
349 349
             }
350 350
             $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item);
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
      * @param array $data
361 361
      * @return string
362 362
      */
363
-    protected function makeUrl($data = array())
364
-    {
363
+    protected function makeUrl($data = array())
364
+    {
365 365
         $out = '';
366
-        if ($this->getCFGDef('makeUrl', 1)) {
367
-            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
366
+        if ($this->getCFGDef('makeUrl', 1)) {
367
+            if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
368 368
                 $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '',
369 369
                     $this->getCFGDef('urlScheme', '')) : $data['content'];
370
-            } else {
370
+            } else {
371 371
                 $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '',
372 372
                     $this->getCFGDef('urlScheme', '')) : '';
373 373
             }
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
      * Вовзращает id текущего документа
381 381
      * @return int
382 382
      */
383
-    public function getHereId()
384
-    {
385
-        if (!$hereId = (int)$this->getCFGDef('hereId')) {
383
+    public function getHereId()
384
+    {
385
+        if (!$hereId = (int)$this->getCFGDef('hereId')) {
386 386
             $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
387 387
         }
388 388
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
      * @param array $data
395 395
      * @return array
396 396
      */
397
-    protected function getClasses($data = array())
398
-    {
397
+    protected function getClasses($data = array())
398
+    {
399 399
         $classes = isset($data['classes']) ? $data['classes'] : array(
400 400
             'rowClass'     => '',
401 401
             'firstClass'   => '',
@@ -408,34 +408,34 @@  discard block
 block discarded – undo
408 408
             'oddClass'     => '',
409 409
             'evenClass'    => ''
410 410
         );
411
-        if (isset($data['state'])) {
411
+        if (isset($data['state'])) {
412 412
             $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']);
413 413
         }
414
-        if (isset($data['here'])) {
414
+        if (isset($data['here'])) {
415 415
             $classes['hereClass'] = $this->getCFGDef('hereClass', 'current');
416 416
         }
417
-        if (isset($data['active'])) {
417
+        if (isset($data['active'])) {
418 418
             $classes['activeClass'] = $this->getCFGDef('activeClass', 'active');
419 419
         }
420 420
         $classes['rowClass'] = $this->getCFGDef('rowClass');
421
-        if ($data['iteration'] % 2 == 1) {
421
+        if ($data['iteration'] % 2 == 1) {
422 422
             $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd');
423
-        } else {
423
+        } else {
424 424
             $classes['evenClass'] = $this->getCFGDef('evenClass', 'even');
425 425
         }
426
-        if (isset($data['first'])) {
426
+        if (isset($data['first'])) {
427 427
             $classes['firstClass'] = $this->getCFGDef('firstClass', 'first');
428 428
         }
429
-        if (isset($data['last'])) {
429
+        if (isset($data['last'])) {
430 430
             $classes['lastClass'] = $this->getCFGDef('lastClass', 'last');
431 431
         }
432
-        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
432
+        if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
433 433
             $classes['levelClass'] = $levelClass . $data['level'];
434 434
         }
435
-        if (isset($data['type']) && $data['type'] == 'reference') {
435
+        if (isset($data['type']) && $data['type'] == 'reference') {
436 436
             $classes['webLinkClass'] = $this->getCFGDef('webLinkClass');
437 437
         }
438
-        if (!empty($data['wrap'])) {
438
+        if (!empty($data['wrap'])) {
439 439
             $classes['parentClass'] = $this->getCFGDef('parentClass');
440 440
         }
441 441
         $classNames = implode(' ', array_filter(array_values($classes)));
@@ -450,28 +450,28 @@  discard block
 block discarded – undo
450 450
      * @param array $data
451 451
      * @return string
452 452
      */
453
-    protected function getRowTemplate($data = array())
454
-    {
453
+    protected function getRowTemplate($data = array())
454
+    {
455 455
         $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>');
456
-        if ($data['wrap']) {
456
+        if ($data['wrap']) {
457 457
             $tpl = $this->getCFGDef('parentRowTpl',
458 458
                 '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>');
459 459
             if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'],
460 460
                         'category') !== false)
461
-            ) {
461
+            ) {
462 462
                 $tpl = $this->getCFGDef('categoryFolderTpl', $tpl);
463
-            } elseif ($data['here']) {
463
+            } elseif ($data['here']) {
464 464
                 $tpl = $this->getCFGDef('parentRowHereTpl', $tpl);
465
-            } elseif ($data['active']) {
465
+            } elseif ($data['active']) {
466 466
                 $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl);
467 467
             }
468
-        } elseif ($data['level'] > 1) {
468
+        } elseif ($data['level'] > 1) {
469 469
             $tpl = $this->getCFGDef('innerRowTpl', $tpl);
470
-            if ($data['here']) {
470
+            if ($data['here']) {
471 471
                 $tpl = $this->getCFGDef('innerRowHereTpl', $tpl);
472 472
             }
473
-        } else {
474
-            if ($data['here']) {
473
+        } else {
474
+            if ($data['here']) {
475 475
                 $tpl = $this->getCFGDef('rowHereTpl', $tpl);
476 476
             }
477 477
         }
@@ -485,32 +485,32 @@  discard block
 block discarded – undo
485 485
      * @param array $array
486 486
      * @return string
487 487
      */
488
-    public function getJSON($data, $fields, $array = array())
489
-    {
488
+    public function getJSON($data, $fields, $array = array())
489
+    {
490 490
         $currentLevel = &$this->currentLevel;
491 491
         $currentLevel = count($this->levels);
492 492
         $docs = $this->levels;
493 493
         /** @var prepare_DL_Extender_ $extPrepare */
494 494
         $extPrepare = $this->getExtender('prepare');
495 495
 
496
-        while ($currentLevel > 0) {
497
-            foreach ($docs[$currentLevel] as $id => &$data) {
498
-                if ($out = $this->prepareData($data)) {
499
-                    if (is_array($out)) {
496
+        while ($currentLevel > 0) {
497
+            foreach ($docs[$currentLevel] as $id => &$data) {
498
+                if ($out = $this->prepareData($data)) {
499
+                    if (is_array($out)) {
500 500
                         $data = $out;
501 501
                     }
502 502
                 };
503 503
 
504
-                if (isset($data['here']) || isset($data['active'])) {
504
+                if (isset($data['here']) || isset($data['active'])) {
505 505
                     $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1;
506 506
                 }
507 507
 
508
-                if ($extPrepare) {
508
+                if ($extPrepare) {
509 509
                     $data = $extPrepare->init($this, array(
510 510
                         'data'      => $data,
511 511
                         'nameParam' => 'prepare'
512 512
                     ));
513
-                    if (is_bool($data) && $data === false) {
513
+                    if (is_bool($data) && $data === false) {
514 514
                         continue;
515 515
                     }
516 516
                 }
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
                 $hideSubMenus = $this->getCFGDef('hideSubMenus', 0);
519 519
                 $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField],
520 520
                             $this->activeBranch));
521
-                if ($hideSubMenus) {
521
+                if ($hideSubMenus) {
522 522
                     $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data;
523 523
                 }
524 524
             }
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
         unset($data);
529 529
         $out = array();
530 530
         $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0);
531
-        foreach ($docs[0] as $id => $data) {
532
-            if (isset($data['children'])) {
533
-                if ($joinMenus) {
531
+        foreach ($docs[0] as $id => $data) {
532
+            if (isset($data['children'])) {
533
+                if ($joinMenus) {
534 534
                     $out = array_merge($out, $data['children']);
535
-                } else {
535
+                } else {
536 536
                     $out[] = $data['children'];
537 537
                 }
538 538
             }
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
550 550
      * @return mixed значение из конфига
551 551
      */
552
-    public function getCFGDef($name, $def = null)
553
-    {
552
+    public function getCFGDef($name, $def = null)
553
+    {
554 554
         return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def));
555 555
     }
556 556
 }
Please login to merge, or discard this patch.