@@ -107,7 +107,7 @@ |
||
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Список активных документов |
| 110 | - * @param $id |
|
| 110 | + * @param integer $id |
|
| 111 | 111 | * @param int $maxDepth |
| 112 | 112 | */ |
| 113 | 113 | public function setActiveBranch($id, $maxDepth = 10) |
@@ -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; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed'; |
| 280 | 280 | } |
| 281 | 281 | $titleField = $this->getCFGDef('titleField', 'title'); |
| 282 | - $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
| 282 | + $data[$titleField] = isset($data['menutitle']) && ! empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
|
| 283 | 283 | $data['level'] = $this->currentLevel; |
| 284 | 284 | $data['url'] = $this->makeUrl($data); |
| 285 | 285 | if ($this->getCFGDef('countChildren', 1)) { |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function getHereId() |
| 374 | 374 | { |
| 375 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
| 375 | + if ( ! $hereId = (int)$this->getCFGDef('hereId')) { |
|
| 376 | 376 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | if (isset($data['type']) && $data['type'] == 'reference') { |
| 426 | 426 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
| 427 | 427 | } |
| 428 | - if (!empty($data['wrap'])) { |
|
| 428 | + if ( ! empty($data['wrap'])) { |
|
| 429 | 429 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
| 430 | 430 | } |
| 431 | 431 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | if ($data['wrap']) { |
| 447 | 447 | $tpl = $this->getCFGDef('parentRowTpl', |
| 448 | 448 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
| 449 | - if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
| 449 | + if ((isset($data['template']) && ! $data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
|
| 450 | 450 | 'category') !== false) |
| 451 | 451 | ) { |
| 452 | 452 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
| 513 | - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
| 513 | + $hideSubMenus = ! $hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
|
| 514 | 514 | $this->activeBranch)); |
| 515 | 515 | if ($hideSubMenus) { |
| 516 | 516 | $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 | } |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | unset($data); |
| 249 | 249 | $out = ''; |
| 250 | - foreach ($docs[0] as $id => $data) { |
|
| 251 | - if (isset($data['wrap'])) { |
|
| 250 | + foreach ($docs[0] as $id => $data) {
|
|
| 251 | + if (isset($data['wrap'])) {
|
|
| 252 | 252 | $data['wrap'] = $this->parseRow($data['wrap']); |
| 253 | 253 | $out .= $this->parseOuter($data); |
| 254 | 254 | } |
@@ -262,32 +262,32 @@ discard block |
||
| 262 | 262 | * @param $data |
| 263 | 263 | * @return array |
| 264 | 264 | */ |
| 265 | - public function prepareData($data) |
|
| 266 | - { |
|
| 265 | + public function prepareData($data) |
|
| 266 | + {
|
|
| 267 | 267 | /** |
| 268 | 268 | * @var e_DL_Extender $extE |
| 269 | 269 | */ |
| 270 | 270 | $extE = $this->getExtender('e', true, true); |
| 271 | 271 | $id = $data['id']; |
| 272 | - if (isset($this->docTvs[$id])) { |
|
| 272 | + if (isset($this->docTvs[$id])) {
|
|
| 273 | 273 | $data = array_merge($data, $this->docTvs[$id]); |
| 274 | 274 | } |
| 275 | - if ($id == $this->getHereId()) { |
|
| 275 | + if ($id == $this->getHereId()) {
|
|
| 276 | 276 | $data['here'] = 1; |
| 277 | 277 | } |
| 278 | - if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { |
|
| 278 | + if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) {
|
|
| 279 | 279 | $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed'; |
| 280 | 280 | } |
| 281 | 281 | $titleField = $this->getCFGDef('titleField', 'title'); |
| 282 | 282 | $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; |
| 283 | 283 | $data['level'] = $this->currentLevel; |
| 284 | 284 | $data['url'] = $this->makeUrl($data); |
| 285 | - if ($this->getCFGDef('countChildren', 1)) { |
|
| 285 | + if ($this->getCFGDef('countChildren', 1)) {
|
|
| 286 | 286 | $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ($out = $extE->init($this, compact('data'))) { |
|
| 290 | - if (is_array($out)) { |
|
| 289 | + if ($out = $extE->init($this, compact('data'))) {
|
|
| 290 | + if (is_array($out)) {
|
|
| 291 | 291 | $data = $out; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -300,16 +300,16 @@ discard block |
||
| 300 | 300 | * @param array $data |
| 301 | 301 | * @return string |
| 302 | 302 | */ |
| 303 | - public function parseOuter($data = array()) |
|
| 304 | - { |
|
| 303 | + public function parseOuter($data = array()) |
|
| 304 | + {
|
|
| 305 | 305 | $tpl = $this->getCFGDef('outerTpl', '@CODE:<ul[+classes+]>[+wrap+]</ul>'); |
| 306 | 306 | $classes = ''; |
| 307 | 307 | $classNames = $this->getCFGDef('outerClass'); |
| 308 | - if ($this->currentLevel >= 1) { |
|
| 308 | + if ($this->currentLevel >= 1) {
|
|
| 309 | 309 | $tpl = $this->getCFGDef('innerTpl', $tpl); |
| 310 | 310 | $classNames = $this->getCFGDef('innerClass'); |
| 311 | 311 | } |
| 312 | - if ($classNames) { |
|
| 312 | + if ($classNames) {
|
|
| 313 | 313 | $classes = " class=\"{$classNames}\""; |
| 314 | 314 | } |
| 315 | 315 | $tpl = isset($data['_renderOuterTpl']) ? $data['_renderOuterTpl'] : $tpl; |
@@ -325,16 +325,16 @@ discard block |
||
| 325 | 325 | * @param array $data |
| 326 | 326 | * @return string |
| 327 | 327 | */ |
| 328 | - public function parseRow($data = array()) |
|
| 329 | - { |
|
| 328 | + public function parseRow($data = array()) |
|
| 329 | + {
|
|
| 330 | 330 | $out = ''; |
| 331 | 331 | $maxIteration = count($data) - 1; |
| 332 | - foreach ($data as $iteration => $item) { |
|
| 332 | + foreach ($data as $iteration => $item) {
|
|
| 333 | 333 | $item['iteration'] = $iteration + 1; |
| 334 | - if ($iteration == 0) { |
|
| 334 | + if ($iteration == 0) {
|
|
| 335 | 335 | $item['first'] = 1; |
| 336 | 336 | } |
| 337 | - if ($iteration == $maxIteration) { |
|
| 337 | + if ($iteration == $maxIteration) {
|
|
| 338 | 338 | $item['last'] = 1; |
| 339 | 339 | } |
| 340 | 340 | $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item); |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | * @param array $data |
| 351 | 351 | * @return string |
| 352 | 352 | */ |
| 353 | - protected function makeUrl($data = array()) |
|
| 354 | - { |
|
| 353 | + protected function makeUrl($data = array()) |
|
| 354 | + {
|
|
| 355 | 355 | $out = ''; |
| 356 | - if ($this->getCFGDef('makeUrl', 1)) { |
|
| 357 | - if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) { |
|
| 356 | + if ($this->getCFGDef('makeUrl', 1)) {
|
|
| 357 | + if (isset($data['type']) && $data['type'] == 'reference' && isset($data['content'])) {
|
|
| 358 | 358 | $out = is_numeric($data['content']) ? $this->modx->makeUrl($data['content'], '', '', |
| 359 | 359 | $this->getCFGDef('urlScheme', '')) : $data['content']; |
| 360 | - } else { |
|
| 360 | + } else {
|
|
| 361 | 361 | $out = isset($data['id']) && is_numeric($data['id']) ? $this->modx->makeUrl($data['id'], '', '', |
| 362 | 362 | $this->getCFGDef('urlScheme', '')) : ''; |
| 363 | 363 | } |
@@ -370,9 +370,9 @@ discard block |
||
| 370 | 370 | * Вовзращает id текущего документа |
| 371 | 371 | * @return int |
| 372 | 372 | */ |
| 373 | - public function getHereId() |
|
| 374 | - { |
|
| 375 | - if (!$hereId = (int)$this->getCFGDef('hereId')) { |
|
| 373 | + public function getHereId() |
|
| 374 | + {
|
|
| 375 | + if (!$hereId = (int)$this->getCFGDef('hereId')) {
|
|
| 376 | 376 | $hereId = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -384,8 +384,8 @@ discard block |
||
| 384 | 384 | * @param array $data |
| 385 | 385 | * @return array |
| 386 | 386 | */ |
| 387 | - protected function getClasses($data = array()) |
|
| 388 | - { |
|
| 387 | + protected function getClasses($data = array()) |
|
| 388 | + {
|
|
| 389 | 389 | $classes = isset($data['classes']) ? $data['classes'] : array( |
| 390 | 390 | 'rowClass' => '', |
| 391 | 391 | 'firstClass' => '', |
@@ -398,34 +398,34 @@ discard block |
||
| 398 | 398 | 'oddClass' => '', |
| 399 | 399 | 'evenClass' => '' |
| 400 | 400 | ); |
| 401 | - if (isset($data['state'])) { |
|
| 401 | + if (isset($data['state'])) {
|
|
| 402 | 402 | $classes['stateClass'] = $this->getCFGDef($data['state'] . 'Class', $data['state']); |
| 403 | 403 | } |
| 404 | - if (isset($data['here'])) { |
|
| 404 | + if (isset($data['here'])) {
|
|
| 405 | 405 | $classes['hereClass'] = $this->getCFGDef('hereClass', 'current'); |
| 406 | 406 | } |
| 407 | - if (isset($data['active'])) { |
|
| 407 | + if (isset($data['active'])) {
|
|
| 408 | 408 | $classes['activeClass'] = $this->getCFGDef('activeClass', 'active'); |
| 409 | 409 | } |
| 410 | 410 | $classes['rowClass'] = $this->getCFGDef('rowClass'); |
| 411 | - if ($data['iteration'] % 2 == 1) { |
|
| 411 | + if ($data['iteration'] % 2 == 1) {
|
|
| 412 | 412 | $classes['oddClass'] = $this->getCFGDef('oddClass', 'odd'); |
| 413 | - } else { |
|
| 413 | + } else {
|
|
| 414 | 414 | $classes['evenClass'] = $this->getCFGDef('evenClass', 'even'); |
| 415 | 415 | } |
| 416 | - if (isset($data['first'])) { |
|
| 416 | + if (isset($data['first'])) {
|
|
| 417 | 417 | $classes['firstClass'] = $this->getCFGDef('firstClass', 'first'); |
| 418 | 418 | } |
| 419 | - if (isset($data['last'])) { |
|
| 419 | + if (isset($data['last'])) {
|
|
| 420 | 420 | $classes['lastClass'] = $this->getCFGDef('lastClass', 'last'); |
| 421 | 421 | } |
| 422 | - if ($levelClass = $this->getCFGDef('levelClass', 'level')) { |
|
| 422 | + if ($levelClass = $this->getCFGDef('levelClass', 'level')) {
|
|
| 423 | 423 | $classes['levelClass'] = $levelClass . $data['level']; |
| 424 | 424 | } |
| 425 | - if (isset($data['type']) && $data['type'] == 'reference') { |
|
| 425 | + if (isset($data['type']) && $data['type'] == 'reference') {
|
|
| 426 | 426 | $classes['webLinkClass'] = $this->getCFGDef('webLinkClass'); |
| 427 | 427 | } |
| 428 | - if (!empty($data['wrap'])) { |
|
| 428 | + if (!empty($data['wrap'])) {
|
|
| 429 | 429 | $classes['parentClass'] = $this->getCFGDef('parentClass'); |
| 430 | 430 | } |
| 431 | 431 | $classNames = implode(' ', array_filter(array_values($classes))); |
@@ -440,32 +440,32 @@ discard block |
||
| 440 | 440 | * @param array $data |
| 441 | 441 | * @return string |
| 442 | 442 | */ |
| 443 | - protected function getRowTemplate($data = array()) |
|
| 444 | - { |
|
| 443 | + protected function getRowTemplate($data = array()) |
|
| 444 | + {
|
|
| 445 | 445 | $tpl = $this->getCFGDef('rowTpl', '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a></li>'); |
| 446 | - if ($data['wrap']) { |
|
| 446 | + if ($data['wrap']) {
|
|
| 447 | 447 | $tpl = $this->getCFGDef('parentRowTpl', |
| 448 | 448 | '@CODE:<li[+classes+]><a href="[+url+]">[+title+]</a>[+wrap+]</li>'); |
| 449 | 449 | if ((isset($data['template']) && !$data['template']) || (isset($data['link_attributes']) && strpos($data['link_attributes'], |
| 450 | 450 | 'category') !== false) |
| 451 | - ) { |
|
| 451 | + ) {
|
|
| 452 | 452 | $tpl = $this->getCFGDef('categoryFolderTpl', $tpl); |
| 453 | - } elseif ($data['here']) { |
|
| 453 | + } elseif ($data['here']) {
|
|
| 454 | 454 | $tpl = $this->getCFGDef('parentRowHereTpl', $tpl); |
| 455 | - } elseif ($data['active']) { |
|
| 455 | + } elseif ($data['active']) {
|
|
| 456 | 456 | $tpl = $this->getCFGDef('parentRowActiveTpl', $tpl); |
| 457 | 457 | } |
| 458 | - } elseif ($data['level'] > 1) { |
|
| 458 | + } elseif ($data['level'] > 1) {
|
|
| 459 | 459 | $tpl = $this->getCFGDef('innerRowTpl', $tpl); |
| 460 | - if ($data['here']) { |
|
| 460 | + if ($data['here']) {
|
|
| 461 | 461 | $tpl = $this->getCFGDef('innerRowHereTpl', $tpl); |
| 462 | - } elseif ($data['active']) { |
|
| 462 | + } elseif ($data['active']) {
|
|
| 463 | 463 | $tpl = $this->getCFGDef('innerRowActiveTpl', $tpl); |
| 464 | 464 | } |
| 465 | - } else { |
|
| 466 | - if ($data['here']) { |
|
| 465 | + } else {
|
|
| 466 | + if ($data['here']) {
|
|
| 467 | 467 | $tpl = $this->getCFGDef('rowHereTpl', $tpl); |
| 468 | - } elseif ($data['active']) { |
|
| 468 | + } elseif ($data['active']) {
|
|
| 469 | 469 | $tpl = $this->getCFGDef('rowActiveTpl', $tpl); |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -479,32 +479,32 @@ discard block |
||
| 479 | 479 | * @param array $array |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public function getJSON($data, $fields, $array = array()) |
|
| 483 | - { |
|
| 482 | + public function getJSON($data, $fields, $array = array()) |
|
| 483 | + {
|
|
| 484 | 484 | $currentLevel = &$this->currentLevel; |
| 485 | 485 | $currentLevel = count($this->levels); |
| 486 | 486 | $docs = $this->levels; |
| 487 | 487 | /** @var prepare_DL_Extender_ $extPrepare */ |
| 488 | 488 | $extPrepare = $this->getExtender('prepare'); |
| 489 | 489 | |
| 490 | - while ($currentLevel > 0) { |
|
| 491 | - foreach ($docs[$currentLevel] as $id => &$data) { |
|
| 492 | - if ($out = $this->prepareData($data)) { |
|
| 493 | - if (is_array($out)) { |
|
| 490 | + while ($currentLevel > 0) {
|
|
| 491 | + foreach ($docs[$currentLevel] as $id => &$data) {
|
|
| 492 | + if ($out = $this->prepareData($data)) {
|
|
| 493 | + if (is_array($out)) {
|
|
| 494 | 494 | $data = $out; |
| 495 | 495 | } |
| 496 | 496 | }; |
| 497 | 497 | |
| 498 | - if (isset($data['here']) || isset($data['active'])) { |
|
| 498 | + if (isset($data['here']) || isset($data['active'])) {
|
|
| 499 | 499 | $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ($extPrepare) { |
|
| 502 | + if ($extPrepare) {
|
|
| 503 | 503 | $data = $extPrepare->init($this, array( |
| 504 | 504 | 'data' => $data, |
| 505 | 505 | 'nameParam' => 'prepare' |
| 506 | 506 | )); |
| 507 | - if (is_bool($data) && $data === false) { |
|
| 507 | + if (is_bool($data) && $data === false) {
|
|
| 508 | 508 | continue; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); |
| 513 | 513 | $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], |
| 514 | 514 | $this->activeBranch)); |
| 515 | - if ($hideSubMenus) { |
|
| 515 | + if ($hideSubMenus) {
|
|
| 516 | 516 | $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; |
| 517 | 517 | } |
| 518 | 518 | } |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра |
| 535 | 535 | * @return mixed значение из конфига |
| 536 | 536 | */ |
| 537 | - public function getCFGDef($name, $def = null) |
|
| 538 | - { |
|
| 537 | + public function getCFGDef($name, $def = null) |
|
| 538 | + {
|
|
| 539 | 539 | return parent::getCFGDef($name . $this->currentLevel, parent::getCFGDef($name, $def)); |
| 540 | 540 | } |
| 541 | 541 | } |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (!isset($params['controller'])) $params['controller'] = 'site_content_menu'; |
|
| 3 | -if (!isset($params['addWhereList'])) $params['addWhereList'] = 'c.hidemenu = 0'; |
|
| 4 | -if (!isset($params['sortBy'])) $params['sortBy'] = 'c.menuindex'; |
|
| 5 | -if (!isset($params['sortDir'])) $params['sortDir'] = 'ASC'; |
|
| 2 | +if ( ! isset($params['controller'])) $params['controller'] = 'site_content_menu'; |
|
| 3 | +if ( ! isset($params['addWhereList'])) $params['addWhereList'] = 'c.hidemenu = 0'; |
|
| 4 | +if ( ! isset($params['sortBy'])) $params['sortBy'] = 'c.menuindex'; |
|
| 5 | +if ( ! isset($params['sortDir'])) $params['sortDir'] = 'ASC'; |
|
| 6 | 6 | $params['depth'] = 0; |
| 7 | -return $modx->runSnippet('DocLister',$params); |
|
| 7 | +return $modx->runSnippet('DocLister', $params); |
|
| 8 | 8 | |
@@ -1,8 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (!isset($params['controller'])) $params['controller'] = 'site_content_menu'; |
|
| 3 | -if (!isset($params['addWhereList'])) $params['addWhereList'] = 'c.hidemenu = 0'; |
|
| 4 | -if (!isset($params['sortBy'])) $params['sortBy'] = 'c.menuindex'; |
|
| 5 | -if (!isset($params['sortDir'])) $params['sortDir'] = 'ASC'; |
|
| 2 | +if (!isset($params['controller'])) {
|
|
| 3 | + $params['controller'] = 'site_content_menu'; |
|
| 4 | +} |
|
| 5 | +if (!isset($params['addWhereList'])) {
|
|
| 6 | + $params['addWhereList'] = 'c.hidemenu = 0'; |
|
| 7 | +} |
|
| 8 | +if (!isset($params['sortBy'])) {
|
|
| 9 | + $params['sortBy'] = 'c.menuindex'; |
|
| 10 | +} |
|
| 11 | +if (!isset($params['sortDir'])) {
|
|
| 12 | + $params['sortDir'] = 'ASC'; |
|
| 13 | +} |
|
| 6 | 14 | $params['depth'] = 0; |
| 7 | 15 | return $modx->runSnippet('DocLister',$params); |
| 8 | 16 | |