@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | if ($ids) { |
| 99 | 99 | $tv = $this->extTV->getTVList($ids, $tvlist); |
| 100 | - if (!is_array($tv)) { |
|
| 100 | + if ( ! is_array($tv)) { |
|
| 101 | 101 | $tv = array(); |
| 102 | 102 | } |
| 103 | 103 | $this->docTvs = $tv; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $at = array_flip($a); |
| 171 | 171 | $d = array(); |
| 172 | 172 | foreach ($b as $i) { |
| 173 | - if (!isset($at[$i])) { |
|
| 173 | + if ( ! isset($at[$i])) { |
|
| 174 | 174 | $d[] = $i; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | }; |
| 220 | 220 | |
| 221 | - if (!isset($data['maxLevel'])) { |
|
| 221 | + if ( ! isset($data['maxLevel'])) { |
|
| 222 | 222 | $data['maxLevel'] = 1; |
| 223 | 223 | $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0; |
| 224 | 224 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 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; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | unset($data); |
| 252 | 252 | $out = ''; |
| 253 | - $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); |
|
| 253 | + $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0); |
|
| 254 | 254 | foreach ($docs[0] as $id => $data) { |
| 255 | 255 | if (isset($data['wrap'])) { |
| 256 | 256 | if ($joinMenus) { |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | if ($id == $this->getHereId()) { |
| 287 | 287 | $data['here'] = 1; |
| 288 | 288 | } |
| 289 | - if (!isset($data['here']) && in_array($id, $this->activeBranch)) { |
|
| 289 | + if ( ! isset($data['here']) && in_array($id, $this->activeBranch)) { |
|
| 290 | 290 | $data['active'] = 1; |
| 291 | 291 | } |
| 292 | 292 | if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $titleField = $this->getCFGDef('titleField', 'title'); |
| 297 | - $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
| 297 | + $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
| 298 | 298 | $data['level'] = $this->currentLevel; |
| 299 | 299 | $data['url'] = $this->makeUrl($data); |
| 300 | 300 | if ($this->getCFGDef('countChildren', 0)) { |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | public function getHereId() |
| 389 | 389 | { |
| 390 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
| 390 | + if ( ! $hereId = (int)$this->getCFGDef('hereId')) { |
|
| 391 | 391 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | if (isset($data['type']) && $data['type'] == 'reference') { |
| 441 | 441 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
| 442 | 442 | } |
| 443 | - if (!empty($data['wrap'])) { |
|
| 443 | + if ( ! empty($data['wrap'])) { |
|
| 444 | 444 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
| 445 | 445 | } |
| 446 | 446 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | if ($data['wrap']) { |
| 462 | 462 | $tpl = $this->getCFGDef('parentRowTpl', |
| 463 | 463 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
| 464 | - if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
| 464 | + if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
| 465 | 465 | 'category') !== false) |
| 466 | 466 | ) { |
| 467 | 467 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
| 524 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
| 524 | + $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
| 525 | 525 | $this->activeBranch)); |
| 526 | 526 | if ($hideSubMenus) { |
| 527 | 527 | $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | } |
| 533 | 533 | unset($data); |
| 534 | 534 | $out = array(); |
| 535 | - $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); |
|
| 535 | + $joinMenus = $this->getCFGDef('joinMenus', 0) && ! $this->getCFGDef('showParents', 0); |
|
| 536 | 536 | foreach ($docs[0] as $id => $data) { |
| 537 | 537 | if (isset($data['children'])) { |
| 538 | 538 | if ($joinMenus) { |
@@ -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,25 +37,25 @@ 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 = min($maxDepth, $this->setActiveBranch($this->getHereId())); |
| 46 | - if (empty(array_intersect($this->IDs, $this->activeBranch))) { |
|
| 46 | + if (empty(array_intersect($this->IDs, $this->activeBranch))) {
|
|
| 47 | 47 | $maxDepth = 1; |
| 48 | 48 | $this->config->setConfig(array('hideSubMenus' => 0)); |
| 49 | 49 | }; |
| 50 | - } else { |
|
| 50 | + } else {
|
|
| 51 | 51 | $this->setActiveBranch($this->getHereId()); |
| 52 | 52 | } |
| 53 | - if ($oIds = $this->getCFGDef('openIds')) { |
|
| 53 | + if ($oIds = $this->getCFGDef('openIds')) {
|
|
| 54 | 54 | $maxDepth = 1; |
| 55 | 55 | $oIds = $this->cleanIDs($oIds); |
| 56 | 56 | $oIds[] = $this->getHereId(); |
| 57 | - foreach ($oIds as $id) { |
|
| 58 | - if (($c = $this->setActiveBranch($id)) > $maxDepth) { |
|
| 57 | + foreach ($oIds as $id) {
|
|
| 58 | + if (($c = $this->setActiveBranch($id)) > $maxDepth) {
|
|
| 59 | 59 | $maxDepth = $c; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | $currentLevel = &$this->currentLevel; |
| 65 | 65 | $currentLevel = 1; |
| 66 | - if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) { |
|
| 66 | + if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) {
|
|
| 67 | 67 | $this->config->setConfig(array('showParent' => 0)); |
| 68 | 68 | } |
| 69 | - if ($this->getCFGDef('showParent', 0)) { |
|
| 69 | + if ($this->getCFGDef('showParent', 0)) {
|
|
| 70 | 70 | $orderBy = $this->getCFGDef('orderBy'); |
| 71 | 71 | $docs = $this->getDocList(); |
| 72 | 72 | $this->config->setConfig(array('orderBy' => $orderBy)); |
@@ -74,37 +74,37 @@ discard block |
||
| 74 | 74 | $this->IDs = $ids = array_keys($docs); |
| 75 | 75 | $this->config->setConfig(array('showParent' => 0)); |
| 76 | 76 | } |
| 77 | - while ($currentLevel <= $maxDepth) { |
|
| 77 | + while ($currentLevel <= $maxDepth) {
|
|
| 78 | 78 | $orderBy = $this->getCFGDef('orderBy'); |
| 79 | 79 | $docs = $this->getChildrenList(); |
| 80 | 80 | $this->config->setConfig(array('orderBy' => $orderBy)); |
| 81 | - if (empty($docs)) { |
|
| 81 | + if (empty($docs)) {
|
|
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | $this->levels[$currentLevel++] = $docs; |
| 85 | 85 | $this->IDs = array_keys($docs); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($tvlist == '') { |
|
| 88 | + if ($tvlist == '') {
|
|
| 89 | 89 | $tvlist = $this->getCFGDef('tvList', ''); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ($tvlist != '') { |
|
| 92 | + if ($tvlist != '') {
|
|
| 93 | 93 | $this->extTV->getAllTV_Name(); |
| 94 | 94 | $ids = array(); |
| 95 | - foreach ($this->levels as $level => $docs) { |
|
| 95 | + foreach ($this->levels as $level => $docs) {
|
|
| 96 | 96 | $ids = array_merge($ids, array_keys($docs)); |
| 97 | 97 | } |
| 98 | - if ($ids) { |
|
| 98 | + if ($ids) {
|
|
| 99 | 99 | $tv = $this->extTV->getTVList($ids, $tvlist); |
| 100 | - if (!is_array($tv)) { |
|
| 100 | + if (!is_array($tv)) {
|
|
| 101 | 101 | $tv = array(); |
| 102 | 102 | } |
| 103 | 103 | $this->docTvs = $tv; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | } |
| 107 | - if ($this->getCFGDef('countChildren', 0)) { |
|
| 107 | + if ($this->getCFGDef('countChildren', 0)) {
|
|
| 108 | 108 | $this->countChildren(); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | * @param $id |
| 117 | 117 | * @param int $maxDepth |
| 118 | 118 | */ |
| 119 | - public function setActiveBranch($id, $maxDepth = 10) |
|
| 120 | - { |
|
| 119 | + public function setActiveBranch($id, $maxDepth = 10) |
|
| 120 | + {
|
|
| 121 | 121 | $ids = array_values($this->modx->getParentIds($id, $maxDepth)); |
| 122 | 122 | $ids[] = $id; |
| 123 | 123 | $ids[] = 0; |
@@ -130,29 +130,29 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * Подсчет количества непосредственных дочерних документов |
| 132 | 132 | */ |
| 133 | - public function countChildren() |
|
| 134 | - { |
|
| 133 | + public function countChildren() |
|
| 134 | + {
|
|
| 135 | 135 | $ids = array(); |
| 136 | 136 | $out = &$this->countChildren; |
| 137 | - foreach ($this->levels as $level => $docs) { |
|
| 137 | + foreach ($this->levels as $level => $docs) {
|
|
| 138 | 138 | $ids = array_merge($ids, array_keys($docs)); |
| 139 | 139 | } |
| 140 | 140 | $maxDepth = count($this->levels); |
| 141 | 141 | $currentDepth = 1; |
| 142 | - while ($currentDepth <= $maxDepth) { |
|
| 142 | + while ($currentDepth <= $maxDepth) {
|
|
| 143 | 143 | $_ids = implode(',', $ids); |
| 144 | - if (empty($_ids)) { |
|
| 144 | + if (empty($_ids)) {
|
|
| 145 | 145 | break; |
| 146 | 146 | } |
| 147 | 147 | $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`"); |
| 148 | 148 | $_ids = array(); |
| 149 | - while ($row = $this->modx->db->getRow($q)) { |
|
| 149 | + while ($row = $this->modx->db->getRow($q)) {
|
|
| 150 | 150 | $_ids[] = $row['parent']; |
| 151 | 151 | $out[$row['parent']] = $row['count']; |
| 152 | 152 | } |
| 153 | - if ($_ids) { |
|
| 153 | + if ($_ids) {
|
|
| 154 | 154 | $ids = $this->diff($ids, $_ids); |
| 155 | - } else { |
|
| 155 | + } else {
|
|
| 156 | 156 | break; |
| 157 | 157 | } |
| 158 | 158 | $currentDepth++; |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | * @param $a |
| 166 | 166 | * @return array |
| 167 | 167 | */ |
| 168 | - private function diff($b, $a) |
|
| 169 | - { |
|
| 168 | + private function diff($b, $a) |
|
| 169 | + {
|
|
| 170 | 170 | $at = array_flip($a); |
| 171 | 171 | $d = array(); |
| 172 | - foreach ($b as $i) { |
|
| 173 | - if (!isset($at[$i])) { |
|
| 172 | + foreach ($b as $i) {
|
|
| 173 | + if (!isset($at[$i])) {
|
|
| 174 | 174 | $d[] = $i; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | * @param string $tpl шаблон |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function render($tpl = '') |
|
| 189 | - { |
|
| 188 | + public function render($tpl = '') |
|
| 189 | + {
|
|
| 190 | 190 | $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html')); |
| 191 | 191 | $out = $this->_render($tpl); |
| 192 | 192 | |
| 193 | - if ($out) { |
|
| 193 | + if ($out) {
|
|
| 194 | 194 | $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out); |
| 195 | 195 | } |
| 196 | 196 | $this->debug->debugEnd('render'); |
@@ -202,45 +202,45 @@ discard block |
||
| 202 | 202 | * @param string $tpl |
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | - public function _render($tpl = '') |
|
| 206 | - { |
|
| 205 | + public function _render($tpl = '') |
|
| 206 | + {
|
|
| 207 | 207 | $currentLevel = &$this->currentLevel; |
| 208 | 208 | $currentLevel = count($this->levels); |
| 209 | 209 | $docs = $this->levels; |
| 210 | 210 | /** @var prepare_DL_Extender_ $extPrepare */ |
| 211 | 211 | $extPrepare = $this->getExtender('prepare'); |
| 212 | 212 | |
| 213 | - while ($currentLevel > 0) { |
|
| 214 | - foreach ($docs[$currentLevel] as $id => &$data) { |
|
| 215 | - if ($out = $this->prepareData($data)) { |
|
| 216 | - if (is_array($out)) { |
|
| 213 | + while ($currentLevel > 0) {
|
|
| 214 | + foreach ($docs[$currentLevel] as $id => &$data) {
|
|
| 215 | + if ($out = $this->prepareData($data)) {
|
|
| 216 | + if (is_array($out)) {
|
|
| 217 | 217 | $data = $out; |
| 218 | 218 | } |
| 219 | 219 | }; |
| 220 | 220 | |
| 221 | - if (!isset($data['maxLevel'])) { |
|
| 221 | + if (!isset($data['maxLevel'])) {
|
|
| 222 | 222 | $data['maxLevel'] = 1; |
| 223 | 223 | $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0; |
| 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 | } |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | unset($data); |
| 252 | 252 | $out = ''; |
| 253 | 253 | $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); |
| 254 | - foreach ($docs[0] as $id => $data) { |
|
| 255 | - if (isset($data['wrap'])) { |
|
| 256 | - if ($joinMenus) { |
|
| 254 | + foreach ($docs[0] as $id => $data) {
|
|
| 255 | + if (isset($data['wrap'])) {
|
|
| 256 | + if ($joinMenus) {
|
|
| 257 | 257 | $out .= $this->parseRow($data['wrap']); |
| 258 | - } else { |
|
| 258 | + } else {
|
|
| 259 | 259 | $data['wrap'] = $this->parseRow($data['wrap']); |
| 260 | 260 | $out .= $this->parseOuter($data); |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | - if ($joinMenus) { |
|
| 264 | + if ($joinMenus) {
|
|
| 265 | 265 | $out = $this->parseOuter(array('wrap' => $out)); |
| 266 | 266 | } |
| 267 | 267 | |
@@ -273,23 +273,23 @@ discard block |
||
| 273 | 273 | * @param $data |
| 274 | 274 | * @return array |
| 275 | 275 | */ |
| 276 | - public function prepareData($data) |
|
| 277 | - { |
|
| 276 | + public function prepareData($data) |
|
| 277 | + {
|
|
| 278 | 278 | /** |
| 279 | 279 | * @var e_DL_Extender $extE |
| 280 | 280 | */ |
| 281 | 281 | $extE = $this->getExtender('e', true, true); |
| 282 | 282 | $id = $data['id']; |
| 283 | - if (isset($this->docTvs[$id])) { |
|
| 283 | + if (isset($this->docTvs[$id])) {
|
|
| 284 | 284 | $data = array_merge($data, $this->docTvs[$id]); |
| 285 | 285 | } |
| 286 | - if ($id == $this->getHereId()) { |
|
| 286 | + if ($id == $this->getHereId()) {
|
|
| 287 | 287 | $data['here'] = 1; |
| 288 | 288 | } |
| 289 | - if (!isset($data['here']) && in_array($id, $this->activeBranch)) { |
|
| 289 | + if (!isset($data['here']) && in_array($id, $this->activeBranch)) {
|
|
| 290 | 290 | $data['active'] = 1; |
| 291 | 291 | } |
| 292 | - if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { |
|
| 292 | + if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
|
|
| 293 | 293 | $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed'; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
| 298 | 298 | $data['level'] = $this->currentLevel; |
| 299 | 299 | $data['url'] = $this->makeUrl($data); |
| 300 | - if ($this->getCFGDef('countChildren', 0)) { |
|
| 300 | + if ($this->getCFGDef('countChildren', 0)) {
|
|
| 301 | 301 | $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ($out = $extE->init($this, compact('data'))) { |
|
| 305 | - if (is_array($out)) { |
|
| 304 | + if ($out = $extE->init($this, compact('data'))) {
|
|
| 305 | + if (is_array($out)) {
|
|
| 306 | 306 | $data = $out; |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -315,16 +315,16 @@ discard block |
||
| 315 | 315 | * @param array $data |
| 316 | 316 | * @return string |
| 317 | 317 | */ |
| 318 | - public function parseOuter($data = array()) |
|
| 319 | - { |
|
| 318 | + public function parseOuter($data = array()) |
|
| 319 | + {
|
|
| 320 | 320 | $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>'); |
| 321 | 321 | $classes = ''; |
| 322 | 322 | $classNames = $this->getCFGDef('outerClass'); |
| 323 | - if ($this->currentLevel >= 1) { |
|
| 323 | + if ($this->currentLevel >= 1) {
|
|
| 324 | 324 | $tpl = $this->getCFGDef('innerTpl', $tpl); |
| 325 | 325 | $classNames = $this->getCFGDef('innerClass'); |
| 326 | 326 | } |
| 327 | - if ($classNames) { |
|
| 327 | + if ($classNames) {
|
|
| 328 | 328 | $classes = " class=\"{$classNames}\""; |
| 329 | 329 | } |
| 330 | 330 | $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl; |
@@ -340,16 +340,16 @@ discard block |
||
| 340 | 340 | * @param array $data |
| 341 | 341 | * @return string |
| 342 | 342 | */ |
| 343 | - public function parseRow($data = array()) |
|
| 344 | - { |
|
| 343 | + public function parseRow($data = array()) |
|
| 344 | + {
|
|
| 345 | 345 | $out = ''; |
| 346 | 346 | $maxIteration = count($data) - 1; |
| 347 | - foreach ($data as $iteration => $item) { |
|
| 347 | + foreach ($data as $iteration => $item) {
|
|
| 348 | 348 | $item['iteration'] = $iteration + 1; |
| 349 | - if ($iteration == 0) { |
|
| 349 | + if ($iteration == 0) {
|
|
| 350 | 350 | $item['first'] = 1; |
| 351 | 351 | } |
| 352 | - if ($iteration == $maxIteration) { |
|
| 352 | + if ($iteration == $maxIteration) {
|
|
| 353 | 353 | $item['last'] = 1; |
| 354 | 354 | } |
| 355 | 355 | $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item); |
@@ -365,14 +365,14 @@ discard block |
||
| 365 | 365 | * @param array $data |
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | - protected function makeUrl($data = array()) |
|
| 369 | - { |
|
| 368 | + protected function makeUrl($data = array()) |
|
| 369 | + {
|
|
| 370 | 370 | $out = ''; |
| 371 | - if ($this->getCFGDef('makeUrl', 1)) { |
|
| 372 | - if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) { |
|
| 371 | + if ($this->getCFGDef('makeUrl', 1)) {
|
|
| 372 | + if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
|
|
| 373 | 373 | $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '', |
| 374 | 374 | $this->getCFGDef('urlScheme', '')) : $data['content']; |
| 375 | - } else { |
|
| 375 | + } else {
|
|
| 376 | 376 | $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '', |
| 377 | 377 | $this->getCFGDef('urlScheme', '')) : ''; |
| 378 | 378 | } |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | * Вовзращает id текущего документа |
| 386 | 386 | * @return int |
| 387 | 387 | */ |
| 388 | - public function getHereId() |
|
| 389 | - { |
|
| 390 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
| 388 | + public function getHereId() |
|
| 389 | + {
|
|
| 390 | + if (!$hereId = (int)$this->getCFGDef('hereId')) {
|
|
| 391 | 391 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * @param array $data |
| 400 | 400 | * @return array |
| 401 | 401 | */ |
| 402 | - protected function getClasses($data = array()) |
|
| 403 | - { |
|
| 402 | + protected function getClasses($data = array()) |
|
| 403 | + {
|
|
| 404 | 404 | $classes = isset($data['classes']) ? $data['classes'] : array( |
| 405 | 405 | 'rowClass' => '', |
| 406 | 406 | 'firstClass' => '', |
@@ -413,34 +413,34 @@ discard block |
||
| 413 | 413 | 'oddClass' => '', |
| 414 | 414 | 'evenClass' => '' |
| 415 | 415 | ); |
| 416 | - if (isset($data['state'])) { |
|
| 416 | + if (isset($data['state'])) {
|
|
| 417 | 417 | $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']); |
| 418 | 418 | } |
| 419 | - if (isset($data['here'])) { |
|
| 419 | + if (isset($data['here'])) {
|
|
| 420 | 420 | $classes['hereClass'] = $this->getCFGDef('hereClass', 'current'); |
| 421 | 421 | } |
| 422 | - if (isset($data['active'])) { |
|
| 422 | + if (isset($data['active'])) {
|
|
| 423 | 423 | $classes['activeClass'] = $this->getCFGDef('activeClass', 'active'); |
| 424 | 424 | } |
| 425 | 425 | $classes['rowClass'] = $this->getCFGDef('rowClass'); |
| 426 | - if ($data['iteration'] % 2 == 1) { |
|
| 426 | + if ($data['iteration'] % 2 == 1) {
|
|
| 427 | 427 | $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd'); |
| 428 | - } else { |
|
| 428 | + } else {
|
|
| 429 | 429 | $classes['evenClass'] = $this->getCFGDef('evenClass', 'even'); |
| 430 | 430 | } |
| 431 | - if (isset($data['first'])) { |
|
| 431 | + if (isset($data['first'])) {
|
|
| 432 | 432 | $classes['firstClass'] = $this->getCFGDef('firstClass', 'first'); |
| 433 | 433 | } |
| 434 | - if (isset($data['last'])) { |
|
| 434 | + if (isset($data['last'])) {
|
|
| 435 | 435 | $classes['lastClass'] = $this->getCFGDef('lastClass', 'last'); |
| 436 | 436 | } |
| 437 | - if ($levelClass = $this->getCFGDef('levelClass', 'level')) { |
|
| 437 | + if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
|
|
| 438 | 438 | $classes['levelClass'] = $levelClass . $data['level']; |
| 439 | 439 | } |
| 440 | - if (isset($data['type']) && $data['type'] == 'reference') { |
|
| 440 | + if (isset($data['type']) && $data['type'] == 'reference') {
|
|
| 441 | 441 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
| 442 | 442 | } |
| 443 | - if (!empty($data['wrap'])) { |
|
| 443 | + if (!empty($data['wrap'])) {
|
|
| 444 | 444 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
| 445 | 445 | } |
| 446 | 446 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -455,28 +455,28 @@ discard block |
||
| 455 | 455 | * @param array $data |
| 456 | 456 | * @return string |
| 457 | 457 | */ |
| 458 | - protected function getRowTemplate($data = array()) |
|
| 459 | - { |
|
| 458 | + protected function getRowTemplate($data = array()) |
|
| 459 | + {
|
|
| 460 | 460 | $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>'); |
| 461 | - if ($data['wrap']) { |
|
| 461 | + if ($data['wrap']) {
|
|
| 462 | 462 | $tpl = $this->getCFGDef('parentRowTpl', |
| 463 | 463 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
| 464 | 464 | if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
| 465 | 465 | 'category') !== false) |
| 466 | - ) { |
|
| 466 | + ) {
|
|
| 467 | 467 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
| 468 | - } elseif ($data['here']) { |
|
| 468 | + } elseif ($data['here']) {
|
|
| 469 | 469 | $tpl = $this->getCFGDef('parentRowHereTpl', $tpl); |
| 470 | - } elseif ($data['active']) { |
|
| 470 | + } elseif ($data['active']) {
|
|
| 471 | 471 | $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl); |
| 472 | 472 | } |
| 473 | - } elseif ($data['level'] > 1) { |
|
| 473 | + } elseif ($data['level'] > 1) {
|
|
| 474 | 474 | $tpl = $this->getCFGDef('innerRowTpl', $tpl); |
| 475 | - if ($data['here']) { |
|
| 475 | + if ($data['here']) {
|
|
| 476 | 476 | $tpl = $this->getCFGDef('innerRowHereTpl', $tpl); |
| 477 | 477 | } |
| 478 | - } else { |
|
| 479 | - if ($data['here']) { |
|
| 478 | + } else {
|
|
| 479 | + if ($data['here']) {
|
|
| 480 | 480 | $tpl = $this->getCFGDef('rowHereTpl', $tpl); |
| 481 | 481 | } |
| 482 | 482 | } |
@@ -490,32 +490,32 @@ discard block |
||
| 490 | 490 | * @param array $array |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - public function getJSON($data, $fields, $array = array()) |
|
| 494 | - { |
|
| 493 | + public function getJSON($data, $fields, $array = array()) |
|
| 494 | + {
|
|
| 495 | 495 | $currentLevel = &$this->currentLevel; |
| 496 | 496 | $currentLevel = count($this->levels); |
| 497 | 497 | $docs = $this->levels; |
| 498 | 498 | /** @var prepare_DL_Extender_ $extPrepare */ |
| 499 | 499 | $extPrepare = $this->getExtender('prepare'); |
| 500 | 500 | |
| 501 | - while ($currentLevel > 0) { |
|
| 502 | - foreach ($docs[$currentLevel] as $id => &$data) { |
|
| 503 | - if ($out = $this->prepareData($data)) { |
|
| 504 | - if (is_array($out)) { |
|
| 501 | + while ($currentLevel > 0) {
|
|
| 502 | + foreach ($docs[$currentLevel] as $id => &$data) {
|
|
| 503 | + if ($out = $this->prepareData($data)) {
|
|
| 504 | + if (is_array($out)) {
|
|
| 505 | 505 | $data = $out; |
| 506 | 506 | } |
| 507 | 507 | }; |
| 508 | 508 | |
| 509 | - if (isset($data['here']) || isset($data['active'])) { |
|
| 509 | + if (isset($data['here']) || isset($data['active'])) {
|
|
| 510 | 510 | $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if ($extPrepare) { |
|
| 513 | + if ($extPrepare) {
|
|
| 514 | 514 | $data = $extPrepare->init($this, array( |
| 515 | 515 | 'data' => $data, |
| 516 | 516 | 'nameParam' => 'prepare' |
| 517 | 517 | )); |
| 518 | - if (is_bool($data) && $data === false) { |
|
| 518 | + if (is_bool($data) && $data === false) {
|
|
| 519 | 519 | continue; |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
| 524 | 524 | $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
| 525 | 525 | $this->activeBranch)); |
| 526 | - if ($hideSubMenus) { |
|
| 526 | + if ($hideSubMenus) {
|
|
| 527 | 527 | $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; |
| 528 | 528 | } |
| 529 | 529 | } |
@@ -533,11 +533,11 @@ discard block |
||
| 533 | 533 | unset($data); |
| 534 | 534 | $out = array(); |
| 535 | 535 | $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); |
| 536 | - foreach ($docs[0] as $id => $data) { |
|
| 537 | - if (isset($data['children'])) { |
|
| 538 | - if ($joinMenus) { |
|
| 536 | + foreach ($docs[0] as $id => $data) {
|
|
| 537 | + if (isset($data['children'])) {
|
|
| 538 | + if ($joinMenus) {
|
|
| 539 | 539 | $out = array_merge($out, $data['children']); |
| 540 | - } else { |
|
| 540 | + } else {
|
|
| 541 | 541 | $out[] = $data['children']; |
| 542 | 542 | } |
| 543 | 543 | } |
@@ -554,8 +554,8 @@ discard block |
||
| 554 | 554 | * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра |
| 555 | 555 | * @return mixed значение из конфига |
| 556 | 556 | */ |
| 557 | - public function getCFGDef($name, $def = null) |
|
| 558 | - { |
|
| 557 | + public function getCFGDef($name, $def = null) |
|
| 558 | + {
|
|
| 559 | 559 | return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def)); |
| 560 | 560 | } |
| 561 | 561 | } |