@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | if ($ids) { |
93 | 93 | $tv = $this->extTV->getTVList($ids, $tvlist); |
94 | - if (!is_array($tv)) { |
|
94 | + if ( ! is_array($tv)) { |
|
95 | 95 | $tv = array(); |
96 | 96 | } |
97 | 97 | $this->docTvs = $tv; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $at = array_flip($a); |
165 | 165 | $d = array(); |
166 | 166 | foreach ($b as $i) { |
167 | - if (!isset($at[$i])) { |
|
167 | + if ( ! isset($at[$i])) { |
|
168 | 168 | $d[] = $i; |
169 | 169 | } |
170 | 170 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | }; |
214 | 214 | |
215 | - if (!isset($data['maxLevel'])) { |
|
215 | + if ( ! isset($data['maxLevel'])) { |
|
216 | 216 | $data['maxLevel'] = 1; |
217 | 217 | $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0; |
218 | 218 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $data['wrap'] = $this->parseOuter($data); |
237 | 237 | } |
238 | 238 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
239 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
239 | + $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
240 | 240 | $this->activeBranch)); |
241 | 241 | if ($hideSubMenus) { |
242 | 242 | $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | unset($data); |
249 | 249 | $out = ''; |
250 | - $joinMenus = $this->getCFGDef('joinMenus',0) && !$this->getCFGDef('showParents',0); |
|
250 | + $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0); |
|
251 | 251 | foreach ($docs[0] as $id => $data) { |
252 | 252 | if (isset($data['wrap'])) { |
253 | 253 | if ($joinMenus) { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | $titleField = $this->getCFGDef('titleField', 'title'); |
289 | - $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
289 | + $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
290 | 290 | $data['level'] = $this->currentLevel; |
291 | 291 | $data['url'] = $this->makeUrl($data); |
292 | 292 | if ($this->getCFGDef('countChildren', 1)) { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function getHereId() |
381 | 381 | { |
382 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
382 | + if ( ! $hereId = (int)$this->getCFGDef('hereId')) { |
|
383 | 383 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
384 | 384 | } |
385 | 385 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | if (isset($data['type']) && $data['type'] == 'reference') { |
433 | 433 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
434 | 434 | } |
435 | - if (!empty($data['wrap'])) { |
|
435 | + if ( ! empty($data['wrap'])) { |
|
436 | 436 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
437 | 437 | } |
438 | 438 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | if ($data['wrap']) { |
454 | 454 | $tpl = $this->getCFGDef('parentRowTpl', |
455 | 455 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
456 | - if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
456 | + if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
457 | 457 | 'category') !== false) |
458 | 458 | ) { |
459 | 459 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
516 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
516 | + $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
517 | 517 | $this->activeBranch)); |
518 | 518 | if ($hideSubMenus) { |
519 | 519 | $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; |
@@ -9,8 +9,8 @@ discard block |
||
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 |
||
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,19 +37,19 @@ discard block |
||
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 | 46 | } |
47 | - if ($oIds = $this->getCFGDef('openIds')) { |
|
47 | + if ($oIds = $this->getCFGDef('openIds')) { |
|
48 | 48 | $maxDepth = 1; |
49 | 49 | $oIds = $this->cleanIDs($oIds); |
50 | 50 | $oIds[] = $this->getHereId(); |
51 | - foreach ($oIds as $id) { |
|
52 | - if (($c = $this->setActiveBranch($id)) > $maxDepth) { |
|
51 | + foreach ($oIds as $id) { |
|
52 | + if (($c = $this->setActiveBranch($id)) > $maxDepth) { |
|
53 | 53 | $maxDepth = $c; |
54 | 54 | } |
55 | 55 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | } |
58 | 58 | $currentLevel = &$this->currentLevel; |
59 | 59 | $currentLevel = 1; |
60 | - if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) { |
|
60 | + if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) { |
|
61 | 61 | $this->config->setConfig(array('showParent' => 0)); |
62 | 62 | } |
63 | - if ($this->getCFGDef('showParent', 0)) { |
|
63 | + if ($this->getCFGDef('showParent', 0)) { |
|
64 | 64 | $orderBy = $this->getCFGDef('orderBy'); |
65 | 65 | $docs = $this->getDocList(); |
66 | 66 | $this->config->setConfig(array('orderBy' => $orderBy)); |
@@ -68,37 +68,37 @@ discard block |
||
68 | 68 | $this->IDs = $ids = array_keys($docs); |
69 | 69 | $this->config->setConfig(array('showParent' => 0)); |
70 | 70 | } |
71 | - while ($currentLevel <= $maxDepth) { |
|
71 | + while ($currentLevel <= $maxDepth) { |
|
72 | 72 | $orderBy = $this->getCFGDef('orderBy'); |
73 | 73 | $docs = $this->getChildrenList(); |
74 | 74 | $this->config->setConfig(array('orderBy' => $orderBy)); |
75 | - if (empty($docs)) { |
|
75 | + if (empty($docs)) { |
|
76 | 76 | break; |
77 | 77 | } |
78 | 78 | $this->levels[$currentLevel++] = $docs; |
79 | 79 | $this->IDs = array_keys($docs); |
80 | 80 | } |
81 | 81 | |
82 | - if ($tvlist == '') { |
|
82 | + if ($tvlist == '') { |
|
83 | 83 | $tvlist = $this->getCFGDef('tvList', ''); |
84 | 84 | } |
85 | 85 | |
86 | - if ($tvlist != '') { |
|
86 | + if ($tvlist != '') { |
|
87 | 87 | $this->extTV->getAllTV_Name(); |
88 | 88 | $ids = array(); |
89 | - foreach ($this->levels as $level => $docs) { |
|
89 | + foreach ($this->levels as $level => $docs) { |
|
90 | 90 | $ids = array_merge($ids, array_keys($docs)); |
91 | 91 | } |
92 | - if ($ids) { |
|
92 | + if ($ids) { |
|
93 | 93 | $tv = $this->extTV->getTVList($ids, $tvlist); |
94 | - if (!is_array($tv)) { |
|
94 | + if (!is_array($tv)) { |
|
95 | 95 | $tv = array(); |
96 | 96 | } |
97 | 97 | $this->docTvs = $tv; |
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
101 | - if ($this->getCFGDef('countChildren', 0)) { |
|
101 | + if ($this->getCFGDef('countChildren', 0)) { |
|
102 | 102 | $this->countChildren(); |
103 | 103 | } |
104 | 104 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param $id |
111 | 111 | * @param int $maxDepth |
112 | 112 | */ |
113 | - public function setActiveBranch($id, $maxDepth = 10) |
|
114 | - { |
|
113 | + public function setActiveBranch($id, $maxDepth = 10) |
|
114 | + { |
|
115 | 115 | $ids = array_values($this->modx->getParentIds($id, $maxDepth)); |
116 | 116 | $ids[] = $id; |
117 | 117 | $ids[] = 0; |
@@ -124,29 +124,29 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Подсчет количества непосредственных дочерних документов |
126 | 126 | */ |
127 | - public function countChildren() |
|
128 | - { |
|
127 | + public function countChildren() |
|
128 | + { |
|
129 | 129 | $ids = array(); |
130 | 130 | $out = &$this->countChildren; |
131 | - foreach ($this->levels as $level => $docs) { |
|
131 | + foreach ($this->levels as $level => $docs) { |
|
132 | 132 | $ids = array_merge($ids, array_keys($docs)); |
133 | 133 | } |
134 | 134 | $maxDepth = count($this->levels); |
135 | 135 | $currentDepth = 1; |
136 | - while ($currentDepth <= $maxDepth) { |
|
136 | + while ($currentDepth <= $maxDepth) { |
|
137 | 137 | $_ids = implode(',', $ids); |
138 | - if (empty($_ids)) { |
|
138 | + if (empty($_ids)) { |
|
139 | 139 | break; |
140 | 140 | } |
141 | 141 | $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`"); |
142 | 142 | $_ids = array(); |
143 | - while ($row = $this->modx->db->getRow($q)) { |
|
143 | + while ($row = $this->modx->db->getRow($q)) { |
|
144 | 144 | $_ids[] = $row['parent']; |
145 | 145 | $out[$row['parent']] = $row['count']; |
146 | 146 | } |
147 | - if ($_ids) { |
|
147 | + if ($_ids) { |
|
148 | 148 | $ids = $this->diff($ids, $_ids); |
149 | - } else { |
|
149 | + } else { |
|
150 | 150 | break; |
151 | 151 | } |
152 | 152 | $currentDepth++; |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | * @param $a |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - private function diff($b, $a) |
|
163 | - { |
|
162 | + private function diff($b, $a) |
|
163 | + { |
|
164 | 164 | $at = array_flip($a); |
165 | 165 | $d = array(); |
166 | - foreach ($b as $i) { |
|
167 | - if (!isset($at[$i])) { |
|
166 | + foreach ($b as $i) { |
|
167 | + if (!isset($at[$i])) { |
|
168 | 168 | $d[] = $i; |
169 | 169 | } |
170 | 170 | } |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | * @param string $tpl шаблон |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function render($tpl = '') |
|
183 | - { |
|
182 | + public function render($tpl = '') |
|
183 | + { |
|
184 | 184 | $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html')); |
185 | 185 | $out = $this->_render($tpl); |
186 | 186 | |
187 | - if ($out) { |
|
187 | + if ($out) { |
|
188 | 188 | $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out); |
189 | 189 | } |
190 | 190 | $this->debug->debugEnd('render'); |
@@ -196,49 +196,49 @@ discard block |
||
196 | 196 | * @param string $tpl |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function _render($tpl = '') |
|
200 | - { |
|
199 | + public function _render($tpl = '') |
|
200 | + { |
|
201 | 201 | $currentLevel = &$this->currentLevel; |
202 | 202 | $currentLevel = count($this->levels); |
203 | 203 | $docs = $this->levels; |
204 | 204 | /** @var prepare_DL_Extender_ $extPrepare */ |
205 | 205 | $extPrepare = $this->getExtender('prepare'); |
206 | 206 | |
207 | - while ($currentLevel > 0) { |
|
208 | - foreach ($docs[$currentLevel] as $id => &$data) { |
|
209 | - if ($out = $this->prepareData($data)) { |
|
210 | - if (is_array($out)) { |
|
207 | + while ($currentLevel > 0) { |
|
208 | + foreach ($docs[$currentLevel] as $id => &$data) { |
|
209 | + if ($out = $this->prepareData($data)) { |
|
210 | + if (is_array($out)) { |
|
211 | 211 | $data = $out; |
212 | 212 | } |
213 | 213 | }; |
214 | 214 | |
215 | - if (!isset($data['maxLevel'])) { |
|
215 | + if (!isset($data['maxLevel'])) { |
|
216 | 216 | $data['maxLevel'] = 1; |
217 | 217 | $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0; |
218 | 218 | } |
219 | 219 | |
220 | - if (isset($data['here']) || isset($data['active'])) { |
|
220 | + if (isset($data['here']) || isset($data['active'])) { |
|
221 | 221 | $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; |
222 | 222 | } |
223 | 223 | |
224 | - if ($extPrepare) { |
|
224 | + if ($extPrepare) { |
|
225 | 225 | $data = $extPrepare->init($this, array( |
226 | 226 | 'data' => $data, |
227 | 227 | 'nameParam' => 'prepare' |
228 | 228 | )); |
229 | - if (is_bool($data) && $data === false) { |
|
229 | + if (is_bool($data) && $data === false) { |
|
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | - if (isset($data['wrap'])) { |
|
234 | + if (isset($data['wrap'])) { |
|
235 | 235 | $data['wrap'] = is_array($data['wrap']) ? $this->parseRow($data['wrap']) : $data['wrap']; |
236 | 236 | $data['wrap'] = $this->parseOuter($data); |
237 | 237 | } |
238 | 238 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
239 | 239 | $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
240 | 240 | $this->activeBranch)); |
241 | - if ($hideSubMenus) { |
|
241 | + if ($hideSubMenus) { |
|
242 | 242 | $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data; |
243 | 243 | } |
244 | 244 | } |
@@ -248,17 +248,19 @@ discard block |
||
248 | 248 | unset($data); |
249 | 249 | $out = ''; |
250 | 250 | $joinMenus = $this->getCFGDef('joinMenus',0) && !$this->getCFGDef('showParents',0); |
251 | - foreach ($docs[0] as $id => $data) { |
|
252 | - if (isset($data['wrap'])) { |
|
253 | - if ($joinMenus) { |
|
251 | + foreach ($docs[0] as $id => $data) { |
|
252 | + if (isset($data['wrap'])) { |
|
253 | + if ($joinMenus) { |
|
254 | 254 | $out .= $this->parseRow($data['wrap']); |
255 | - } else { |
|
255 | + } else { |
|
256 | 256 | $data['wrap'] = $this->parseRow($data['wrap']); |
257 | 257 | $out .= $this->parseOuter($data); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | - if ($joinMenus) $out = $this->parseOuter(array('wrap'=>$out)); |
|
261 | + if ($joinMenus) { |
|
262 | + $out = $this->parseOuter(array('wrap'=>$out)); |
|
263 | + } |
|
262 | 264 | |
263 | 265 | return $out; |
264 | 266 | } |
@@ -268,20 +270,20 @@ discard block |
||
268 | 270 | * @param $data |
269 | 271 | * @return array |
270 | 272 | */ |
271 | - public function prepareData($data) |
|
272 | - { |
|
273 | + public function prepareData($data) |
|
274 | + { |
|
273 | 275 | /** |
274 | 276 | * @var e_DL_Extender $extE |
275 | 277 | */ |
276 | 278 | $extE = $this->getExtender('e', true, true); |
277 | 279 | $id = $data['id']; |
278 | - if (isset($this->docTvs[$id])) { |
|
280 | + if (isset($this->docTvs[$id])) { |
|
279 | 281 | $data = array_merge($data, $this->docTvs[$id]); |
280 | 282 | } |
281 | - if ($id == $this->getHereId()) { |
|
283 | + if ($id == $this->getHereId()) { |
|
282 | 284 | $data['here'] = 1; |
283 | 285 | } |
284 | - if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { |
|
286 | + if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { |
|
285 | 287 | $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed'; |
286 | 288 | } |
287 | 289 | |
@@ -289,12 +291,12 @@ discard block |
||
289 | 291 | $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
290 | 292 | $data['level'] = $this->currentLevel; |
291 | 293 | $data['url'] = $this->makeUrl($data); |
292 | - if ($this->getCFGDef('countChildren', 1)) { |
|
294 | + if ($this->getCFGDef('countChildren', 1)) { |
|
293 | 295 | $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0; |
294 | 296 | } |
295 | 297 | |
296 | - if ($out = $extE->init($this, compact('data'))) { |
|
297 | - if (is_array($out)) { |
|
298 | + if ($out = $extE->init($this, compact('data'))) { |
|
299 | + if (is_array($out)) { |
|
298 | 300 | $data = $out; |
299 | 301 | } |
300 | 302 | } |
@@ -307,16 +309,16 @@ discard block |
||
307 | 309 | * @param array $data |
308 | 310 | * @return string |
309 | 311 | */ |
310 | - public function parseOuter($data = array()) |
|
311 | - { |
|
312 | + public function parseOuter($data = array()) |
|
313 | + { |
|
312 | 314 | $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>'); |
313 | 315 | $classes = ''; |
314 | 316 | $classNames = $this->getCFGDef('outerClass'); |
315 | - if ($this->currentLevel >= 1) { |
|
317 | + if ($this->currentLevel >= 1) { |
|
316 | 318 | $tpl = $this->getCFGDef('innerTpl', $tpl); |
317 | 319 | $classNames = $this->getCFGDef('innerClass'); |
318 | 320 | } |
319 | - if ($classNames) { |
|
321 | + if ($classNames) { |
|
320 | 322 | $classes = " class=\"{$classNames}\""; |
321 | 323 | } |
322 | 324 | $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl; |
@@ -332,16 +334,16 @@ discard block |
||
332 | 334 | * @param array $data |
333 | 335 | * @return string |
334 | 336 | */ |
335 | - public function parseRow($data = array()) |
|
336 | - { |
|
337 | + public function parseRow($data = array()) |
|
338 | + { |
|
337 | 339 | $out = ''; |
338 | 340 | $maxIteration = count($data) - 1; |
339 | - foreach ($data as $iteration => $item) { |
|
341 | + foreach ($data as $iteration => $item) { |
|
340 | 342 | $item['iteration'] = $iteration + 1; |
341 | - if ($iteration == 0) { |
|
343 | + if ($iteration == 0) { |
|
342 | 344 | $item['first'] = 1; |
343 | 345 | } |
344 | - if ($iteration == $maxIteration) { |
|
346 | + if ($iteration == $maxIteration) { |
|
345 | 347 | $item['last'] = 1; |
346 | 348 | } |
347 | 349 | $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item); |
@@ -357,14 +359,14 @@ discard block |
||
357 | 359 | * @param array $data |
358 | 360 | * @return string |
359 | 361 | */ |
360 | - protected function makeUrl($data = array()) |
|
361 | - { |
|
362 | + protected function makeUrl($data = array()) |
|
363 | + { |
|
362 | 364 | $out = ''; |
363 | - if ($this->getCFGDef('makeUrl', 1)) { |
|
364 | - if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) { |
|
365 | + if ($this->getCFGDef('makeUrl', 1)) { |
|
366 | + if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) { |
|
365 | 367 | $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '', |
366 | 368 | $this->getCFGDef('urlScheme', '')) : $data['content']; |
367 | - } else { |
|
369 | + } else { |
|
368 | 370 | $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '', |
369 | 371 | $this->getCFGDef('urlScheme', '')) : ''; |
370 | 372 | } |
@@ -377,9 +379,9 @@ discard block |
||
377 | 379 | * Вовзращает id текущего документа |
378 | 380 | * @return int |
379 | 381 | */ |
380 | - public function getHereId() |
|
381 | - { |
|
382 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
382 | + public function getHereId() |
|
383 | + { |
|
384 | + if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
383 | 385 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
384 | 386 | } |
385 | 387 | |
@@ -391,8 +393,8 @@ discard block |
||
391 | 393 | * @param array $data |
392 | 394 | * @return array |
393 | 395 | */ |
394 | - protected function getClasses($data = array()) |
|
395 | - { |
|
396 | + protected function getClasses($data = array()) |
|
397 | + { |
|
396 | 398 | $classes = isset($data['classes']) ? $data['classes'] : array( |
397 | 399 | 'rowClass' => '', |
398 | 400 | 'firstClass' => '', |
@@ -405,34 +407,34 @@ discard block |
||
405 | 407 | 'oddClass' => '', |
406 | 408 | 'evenClass' => '' |
407 | 409 | ); |
408 | - if (isset($data['state'])) { |
|
410 | + if (isset($data['state'])) { |
|
409 | 411 | $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']); |
410 | 412 | } |
411 | - if (isset($data['here'])) { |
|
413 | + if (isset($data['here'])) { |
|
412 | 414 | $classes['hereClass'] = $this->getCFGDef('hereClass', 'current'); |
413 | 415 | } |
414 | - if (isset($data['active'])) { |
|
416 | + if (isset($data['active'])) { |
|
415 | 417 | $classes['activeClass'] = $this->getCFGDef('activeClass', 'active'); |
416 | 418 | } |
417 | 419 | $classes['rowClass'] = $this->getCFGDef('rowClass'); |
418 | - if ($data['iteration'] % 2 == 1) { |
|
420 | + if ($data['iteration'] % 2 == 1) { |
|
419 | 421 | $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd'); |
420 | - } else { |
|
422 | + } else { |
|
421 | 423 | $classes['evenClass'] = $this->getCFGDef('evenClass', 'even'); |
422 | 424 | } |
423 | - if (isset($data['first'])) { |
|
425 | + if (isset($data['first'])) { |
|
424 | 426 | $classes['firstClass'] = $this->getCFGDef('firstClass', 'first'); |
425 | 427 | } |
426 | - if (isset($data['last'])) { |
|
428 | + if (isset($data['last'])) { |
|
427 | 429 | $classes['lastClass'] = $this->getCFGDef('lastClass', 'last'); |
428 | 430 | } |
429 | - if ($levelClass = $this->getCFGDef('levelClass', 'level')) { |
|
431 | + if ($levelClass = $this->getCFGDef('levelClass', 'level')) { |
|
430 | 432 | $classes['levelClass'] = $levelClass . $data['level']; |
431 | 433 | } |
432 | - if (isset($data['type']) && $data['type'] == 'reference') { |
|
434 | + if (isset($data['type']) && $data['type'] == 'reference') { |
|
433 | 435 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
434 | 436 | } |
435 | - if (!empty($data['wrap'])) { |
|
437 | + if (!empty($data['wrap'])) { |
|
436 | 438 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
437 | 439 | } |
438 | 440 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -447,28 +449,28 @@ discard block |
||
447 | 449 | * @param array $data |
448 | 450 | * @return string |
449 | 451 | */ |
450 | - protected function getRowTemplate($data = array()) |
|
451 | - { |
|
452 | + protected function getRowTemplate($data = array()) |
|
453 | + { |
|
452 | 454 | $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>'); |
453 | - if ($data['wrap']) { |
|
455 | + if ($data['wrap']) { |
|
454 | 456 | $tpl = $this->getCFGDef('parentRowTpl', |
455 | 457 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
456 | 458 | if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
457 | 459 | 'category') !== false) |
458 | - ) { |
|
460 | + ) { |
|
459 | 461 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
460 | - } elseif ($data['here']) { |
|
462 | + } elseif ($data['here']) { |
|
461 | 463 | $tpl = $this->getCFGDef('parentRowHereTpl', $tpl); |
462 | - } elseif ($data['active']) { |
|
464 | + } elseif ($data['active']) { |
|
463 | 465 | $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl); |
464 | 466 | } |
465 | - } elseif ($data['level'] > 1) { |
|
467 | + } elseif ($data['level'] > 1) { |
|
466 | 468 | $tpl = $this->getCFGDef('innerRowTpl', $tpl); |
467 | - if ($data['here']) { |
|
469 | + if ($data['here']) { |
|
468 | 470 | $tpl = $this->getCFGDef('innerRowHereTpl', $tpl); |
469 | 471 | } |
470 | - } else { |
|
471 | - if ($data['here']) { |
|
472 | + } else { |
|
473 | + if ($data['here']) { |
|
472 | 474 | $tpl = $this->getCFGDef('rowHereTpl', $tpl); |
473 | 475 | } |
474 | 476 | } |
@@ -482,32 +484,32 @@ discard block |
||
482 | 484 | * @param array $array |
483 | 485 | * @return string |
484 | 486 | */ |
485 | - public function getJSON($data, $fields, $array = array()) |
|
486 | - { |
|
487 | + public function getJSON($data, $fields, $array = array()) |
|
488 | + { |
|
487 | 489 | $currentLevel = &$this->currentLevel; |
488 | 490 | $currentLevel = count($this->levels); |
489 | 491 | $docs = $this->levels; |
490 | 492 | /** @var prepare_DL_Extender_ $extPrepare */ |
491 | 493 | $extPrepare = $this->getExtender('prepare'); |
492 | 494 | |
493 | - while ($currentLevel > 0) { |
|
494 | - foreach ($docs[$currentLevel] as $id => &$data) { |
|
495 | - if ($out = $this->prepareData($data)) { |
|
496 | - if (is_array($out)) { |
|
495 | + while ($currentLevel > 0) { |
|
496 | + foreach ($docs[$currentLevel] as $id => &$data) { |
|
497 | + if ($out = $this->prepareData($data)) { |
|
498 | + if (is_array($out)) { |
|
497 | 499 | $data = $out; |
498 | 500 | } |
499 | 501 | }; |
500 | 502 | |
501 | - if (isset($data['here']) || isset($data['active'])) { |
|
503 | + if (isset($data['here']) || isset($data['active'])) { |
|
502 | 504 | $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; |
503 | 505 | } |
504 | 506 | |
505 | - if ($extPrepare) { |
|
507 | + if ($extPrepare) { |
|
506 | 508 | $data = $extPrepare->init($this, array( |
507 | 509 | 'data' => $data, |
508 | 510 | 'nameParam' => 'prepare' |
509 | 511 | )); |
510 | - if (is_bool($data) && $data === false) { |
|
512 | + if (is_bool($data) && $data === false) { |
|
511 | 513 | continue; |
512 | 514 | } |
513 | 515 | } |
@@ -515,7 +517,7 @@ discard block |
||
515 | 517 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
516 | 518 | $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
517 | 519 | $this->activeBranch)); |
518 | - if ($hideSubMenus) { |
|
520 | + if ($hideSubMenus) { |
|
519 | 521 | $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; |
520 | 522 | } |
521 | 523 | } |
@@ -537,8 +539,8 @@ discard block |
||
537 | 539 | * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра |
538 | 540 | * @return mixed значение из конфига |
539 | 541 | */ |
540 | - public function getCFGDef($name, $def = null) |
|
541 | - { |
|
542 | + public function getCFGDef($name, $def = null) |
|
543 | + { |
|
542 | 544 | return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def)); |
543 | 545 | } |
544 | 546 | } |