function _makeChilds() { // ripassa l'array creando i link parente creando l'aray per mappare pageId con ID $menuIdToSort = array(); $IDs = array_keys($this->_siteMapArray); foreach ($IDs as $key) { $menuNode =& $this->_siteMapArray[$key]; $parentId = $menuNode['parentId']; if (!is_bool($menuNode['isVisible'])) { if (preg_match("/\\{php\\:.*\\}/i", $menuNode['isVisible'])) { $phpcode = org_glizy_helpers_PhpScript::parse($menuNode['isVisible']); $menuNode['isVisible'] = eval($phpcode) == 1 ? true : false; } else { $menuNode['isVisible'] = $menuNode['isVisible'] === 'false' ? false : true; } } if (!$this->isAdmin && $menuNode['isLocked'] && !$this->_user->isLogged() && $this->hidePrivatePage) { $menuNode['isVisible'] = false; } $this->_pageTypeMap[strtolower($menuNode['pageType'])] =& $menuNode; if ($this->_type == 'db' && $parentId == 0 || $this->_type == 'xml' && $parentId == '' || $this->_type == '' && $parentId === 0) { continue; } if (isset($this->_siteMapArray[$parentId])) { $menuNodeParent =& $this->_siteMapArray[$parentId]; // aggiunge il riferimento come childNode $menuNodeParent['childNodes'][] = $menuNode['id']; $menuNode['depth'] = $menuNodeParent['depth'] + 1; } else { // cancella il menu // perché è orfano unset($this->_siteMapArray[$key]); // TODO cancellare anche i figli in modo ricorsivo } if ($menuNode['sortChild']) { $menuIdToSort[] = $key; } } // order the menus foreach ($menuIdToSort as $key) { $menuNode =& $this->_siteMapArray[$key]; $tempNode = array(); foreach ($menuNode['childNodes'] as $childId) { $tempNode[$childId] =& $this->_siteMapArray[$childId]; } usort($tempNode, function ($a, $b) { if (!$a['title'] && !$b['title']) { return 0; } else { if (!$a['title']) { return 1; } else { if (!$b['title']) { return -1; } else { return strnatcasecmp($a['title'], $b['title']); } } } }); $menuNode['childNodes'] = array(); foreach ($tempNode as $node) { $menuNode['childNodes'][] = $node['id']; } } $this->_makeDepth($IDs[0], 0); }
function _makeNavigationMenu(&$node, $endDepth, &$menu, $skip = false) { $skip = !$skip ? $node->depth < $this->_startDepth : $skip; if ($node->type == 'BLOCK') { return true; } if ($node->depth > $endDepth) { return true; } if ($node->isVisible == 0) { return true; } if (is_string($node->isVisible) && preg_match("/\\{php\\:.*\\}/i", $node->isVisible)) { $phpcode = org_glizy_helpers_PhpScript::parse($node->isVisible); if (!eval($phpcode)) { return true; } } if ($node->type == 'SYSTEM' && !$skip) { return true; } if (!$this->_application->canViewPage($node->id)) { return true; } $nodeTitle = empty($node->titleLink) ? $node->title : $node->titleLink; $nodeDescription = empty($node->linkDescription) ? $nodeTitle : $node->linkDescription; $menuNode = array(); if (!$skip) { $menuNode['id'] = $node->id; $menuNode['title'] = $nodeTitle; $menuNode['label'] = $nodeDescription; $menuNode['depth'] = $node->depth; $menuNode['type'] = $node->pageType; $menuNode['cssClass'] = $node->cssClass; $menuNode['haveChild'] = $node->hasChildNodes(); if ($this->_currentMenuId == $node->id && !$this->getAttribute('forceLink')) { $menuNode['node'] = $nodeTitle; } else { $cssClass = $this->getAttribute('selectLink') && $this->_currentMenuId == $node->id ? $this->getAttribute('cssCurrent') : ''; if (empty($node->url)) { $linkParams = array('pageId' => $node->id, 'title' => $nodeDescription, 'label' => $nodeTitle, 'cssClass' => $cssClass, 'icon' => $node->icon); $menuNode['node'] = org_glizy_helpers_Link::makeLink('link', $linkParams); } else { $url = $node->url; if (strpos($url, 'route:') !== false) { $url = substr($url, 6); $url = __Routing::makeUrl($url, __Request::getAllAsArray()); } $menuNode['node'] = org_glizy_helpers_Link::makeSimpleLink($nodeTitle, $url, $nodeDescription, $cssClass); } } if (!$this->getAttribute('selectLink')) { if (!$this->getAttribute('selectParent')) { $menuNode['selected'] = $this->_currentMenuId == $node->id ? ' ' . $this->getAttribute('attributeToSelect') . '="' . $this->getAttribute('cssCurrent') . '"' : ''; } else { $parentNode =& $this->_currentMenu->parentNodeByDepth($node->depth); if (is_object($parentNode) && $node->depth > 1) { $menuNode['selected'] = $parentNode->id == $node->id || $this->_currentMenuId == $node->id ? ' ' . $this->getAttribute('attributeToSelect') . '="' . $this->getAttribute('cssCurrent') . '"' : ''; } } } } if (count($menuNode)) { $menu[] = $menuNode; } if ($node->hasChildNodes()) { $childNodes =& $node->childNodes(); $tempMenu = array(); for ($i = 0; $i < count($childNodes); $i++) { $newEndDepth = max($this->_endDepth + (in_array($node->id, $this->_menuToOpen) ? 1 : 0), $node->depth + (in_array($node->id, $this->_menuToOpen) ? 1 : 0)); if ($this->getAttribute('showOnlyChilds')) { if (in_array($node->id, $this->_menuToOpen) || $this->_startMenu->depth == $node->depth || $this->_currentMenuId == $node->id || $this->getAttribute('drawAllChilds')) { $this->_makeNavigationMenu($childNodes[$i], $newEndDepth, $tempMenu); } } else { $this->_makeNavigationMenu($childNodes[$i], $newEndDepth, $tempMenu); } } if (count($tempMenu)) { $menuNode['node'] = $tempMenu; $menuNode['selected'] = ''; if ($this->getAttribute('flat') && count($menu)) { $menu = array_merge($menu, $menuNode['node']); } else { $menu[] = $menuNode; } } } if ($skip && count($menu)) { $menu = $menu[0]['node']; } }
/** * @return string */ function getOriginalId() { $originalId = $this->_originalId; if (preg_match("/\\{php\\:.*\\}/i", $originalId)) { $phpcode = org_glizy_helpers_PhpScript::parse($originalId); $originalId = eval($phpcode); } return $originalId; }