protected function _getNavigation($categoryId) { global $REX; static $depth = 0; if ($categoryId < 1) { $cats = OOCategory::getRootCategories($this->ignoreOfflines); } else { $cats = OOCategory::getChildrenById($categoryId, $this->ignoreOfflines); } $return = ''; $ulIdAttribute = ''; $ulClassAttribute = ''; if (count($cats) > 0) { if (isset($this->ulId[$depth])) { $ulIdAttribute = ' id="' . $this->ulId[$depth] . '"'; } if (isset($this->ulClass[$depth])) { $ulClassAttribute = ' class="' . $this->ulClass[$depth] . '"'; } $return .= '<ul' . $ulIdAttribute . $ulClassAttribute . '>'; } foreach ($cats as $cat) { if ($this->_checkCallbacks($cat, $depth)) { $cssClasses = ''; $idAttribute = ''; // default li class if ($this->liClass != '') { $cssClasses .= ' ' . $this->liClass; } // li class if (is_array($this->liClassFromCategoryId) && isset($this->liClassFromCategoryId[$cat->getId()])) { $cssClasses .= ' ' . $this->liClassFromCategoryId[$cat->getId()]; } if ($this->liClassFromMetaField != '' && $cat->getValue($this->liClassFromMetaField) != '') { $cssClasses .= ' ' . $cat->getValue($this->liClassFromMetaField); } // li id if (is_array($this->liIdFromCategoryId) && isset($this->liIdFromCategoryId[$cat->getId()])) { $idAttribute = ' id="' . $this->liIdFromCategoryId[$cat->getId()] . '"'; } elseif ($this->liIdFromMetaField != '' && $cat->getValue($this->liIdFromMetaField) != '') { $idAttribute = ' id="' . $cat->getValue($this->liIdFromMetaField) . '"'; } // selected class if ($cat->getId() == $this->current_category_id) { // active menuitem $cssClasses .= ' ' . $this->activeClass; } elseif (in_array($cat->getId(), $this->path)) { // current menuitem $cssClasses .= ' ' . $this->selectedClass; } else { // do nothing } $trimmedCssClasses = trim($cssClasses); // build class attribute if ($trimmedCssClasses != '') { $classAttribute = ' class="' . $trimmedCssClasses . '"'; } else { $classAttribute = ''; } if ($this->hideWebsiteStartArticle && $cat->getId() == $REX['START_ARTICLE_ID'] || in_array($cat->getId(), $this->hideIds)) { // do nothing } else { $depth++; $urlType = 0; // default $return .= '<li' . $idAttribute . $classAttribute . '>'; if ($this->linkFromUserFunc != '') { $defaultLink = call_user_func($this->linkFromUserFunc, $cat, $depth); } else { $defaultLink = '<a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a>'; } if (!class_exists('seo42')) { // normal behaviour $return .= $defaultLink; } else { // only with seo42 2.0.0+ $urlData = seo42::getCustomUrlData($cat); // check if default lang has url clone option (but only if current categoy has no url data set) if (count($REX['CLANG']) > 1 && !isset($urlData['url_type'])) { $defaultLangCat = OOCategory::getCategoryById($cat->getId(), $REX['START_CLANG_ID']); $urlDataDefaultLang = seo42::getCustomUrlData($defaultLangCat); if (isset($urlDataDefaultLang['url_clone']) && $urlDataDefaultLang['url_clone']) { // clone url data from default language to current language $urlData = $urlDataDefaultLang; } } if (isset($urlData['url_type'])) { switch ($urlData['url_type']) { case 5: // SEO42_URL_TYPE_NONE $return .= htmlspecialchars($cat->getName()); break; case 4: // SEO42_URL_TYPE_LANGSWITCH $newClangId = $urlData['clang_id']; $newArticleId = $REX['ARTICLE_ID']; $catNewLang = OOCategory::getCategoryById($newArticleId, $newClangId); // if category that should be switched is not online, switch to start article of website if (OOCategory::isValid($catNewLang) && !$catNewLang->isOnline()) { $newArticleId = $REX['START_ARTICLE_ID']; } // select li that is current language if ($REX['CUR_CLANG'] == $newClangId) { $return = substr($return, 0, strlen($return) - strlen('<li>')); $return .= '<li class="' . $this->selectedClass . '">'; } $return .= '<a href="' . rex_getUrl($newArticleId, $newClangId) . '">' . htmlspecialchars($cat->getName()) . '</a>'; break; case 8: // SEO42_URL_TYPE_CALL_FUNC $return .= call_user_func($urlData['func'], $cat); break; default: $return .= $defaultLink; break; } } else { $return .= $defaultLink; } } if (($this->showAll || $cat->getId() == $this->current_category_id || in_array($cat->getId(), $this->path)) && ($this->levelDepth > $depth || $this->levelDepth < 0)) { $return .= $this->_getNavigation($cat->getId()); } $depth--; $return .= '</li>'; } } } if (count($cats) > 0) { $return .= '</ul>'; } return $return; }
/** * Castet die Variable $var zum Typ $vartype * * Mögliche PHP-Typen sind: * - bool (auch boolean) * - int (auch integer) * - double * - string * - float * - real * - object * - array * - '' (nicht casten) * * Mögliche REDAXO-Typen sind: * - rex-article-id * - rex-category-id * - rex-clang-id * - rex-template-id * - rex-ctype-id * - rex-slice-id * - rex-module-id * - rex-action-id * - rex-media-id * - rex-mediacategory-id * - rex-user-id * * @access private */ function _rex_cast_var($var, $vartype, $default, $mode) { global $REX; if (!is_string($vartype)) { trigger_error('String expected for $vartype in _rex_cast_var()!', E_USER_ERROR); exit; } switch ($vartype) { // ---------------- REDAXO types case 'rex-article-id': $var = (int) $var; if ($mode == 'found') { if (!OOArticle::isValid(OOArticle::getArticleById($var))) { $var = (int) $default; } } break; case 'rex-category-id': $var = (int) $var; if ($mode == 'found') { if (!OOCategory::isValid(OOCategory::getCategoryById($var))) { $var = (int) $default; } } break; case 'rex-clang-id': $var = (int) $var; if ($mode == 'found') { if (empty($REX['CLANG'][$var])) { $var = (int) $default; } } break; case 'rex-template-id': case 'rex-ctype-id': case 'rex-slice-id': case 'rex-module-id': case 'rex-action-id': case 'rex-media-id': case 'rex-mediacategory-id': case 'rex-user-id': // erstmal keine weitere validierung $var = (int) $var; break; // ---------------- PHP types // ---------------- PHP types case 'bool': case 'boolean': $var = (bool) $var; break; case 'int': case 'integer': $var = (int) $var; break; case 'double': $var = (double) $var; break; case 'float': case 'real': $var = (double) $var; break; case 'string': $var = (string) $var; break; case 'object': $var = (object) $var; break; case 'array': if (empty($var)) { $var = array(); } else { $var = (array) $var; } break; // kein Cast, nichts tun // kein Cast, nichts tun case '': break; // Evtl Typo im vartype, deshalb hier fehlermeldung! // Evtl Typo im vartype, deshalb hier fehlermeldung! default: trigger_error('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!', E_USER_ERROR); exit; } return $var; }
function _formatNode(&$node) { if ($this->ignore_startarticles && OOArticle::isValid($node) && $node->isStartPage()) { return ''; } $name = $node->getName(); if ($name == '') { if ($this->ignore_empty) { return ''; } else { $name = $this->empty_value; } } if ($this->depth_limit > 0 && $this->_depth >= $this->depth_limit) { return ''; } $s = ''; $s_self = ''; $s_child = ''; // Kategorien ingorieren? if (OOCategory::isValid($node) && !$this->ignore_categories || OOArticle::isValid($node) && !($this->ignore_startarticles && $node->isStartPage())) { $s_self .= $this->_formatNodeValue($name, $node); if (OOCategory::isValid($node)) { $childs = $node->getChildren($this->ignore_offlines, $this->clang); $articles = $node->getArticles($this->ignore_offlines, $this->clang); if (is_array($childs) && count($childs) > 0 || is_array($articles) && count($articles) > 0 && !$this->ignore_articles) { $this->_depth++; if (is_array($childs)) { foreach ($childs as $child) { $s_child .= $this->_formatNode($child); } } // Artikel ingorieren? if (!$this->ignore_articles) { if (is_array($articles)) { foreach ($articles as $article) { // if ($article->isStartPage()) // { // continue; // } $s_child .= '<' . $this->child_tag . $this->child_attr . '>'; $s_child .= $this->_formatNodeValue($article->getName(), $article); $s_child .= '</' . $this->child_tag . '>'; } } } // Parent Tag nur erstellen, wenn auch Childs vorhanden sind if ($s_child != '') { $s_self .= '<' . $this->parent_tag . $this->parent_attr . '>'; $s_self .= $s_child; $s_self .= '</' . $this->parent_tag . '>'; } $this->_depth--; } } // Parent Tag nur erstellen, wenn auch Childs vorhanden sind if ($s_self != '') { $s .= '<' . $this->child_tag . $this->child_attr . '>'; $s .= $s_self; $s .= '</' . $this->child_tag . '>'; } } return $s; }
/** * Castet die Variable $var zum Typ $vartype * * Mögliche PHP-Typen sind: * - bool (auch boolean) * - int (auch integer) * - double * - string * - float * - real * - object * - array * - '' (nicht casten) * * Mögliche REDAXO-Typen sind: * - rex-article-id * - rex-category-id * - rex-clang-id * - rex-template-id * - rex-ctype-id * - rex-slice-id * - rex-module-id * - rex-action-id * - rex-media-id * - rex-mediacategory-id * - rex-user-id * * @access private */ function _rex_cast_var($var, $vartype, $default = null, $mode = 'default') { global $REX; if (is_string($vartype)) { $casted = true; switch ($vartype) { // ---------------- REDAXO types case 'rex-article-id': $var = (int) $var; if ($mode == 'found') { if (!OOArticle::isValid(OOArticle::getArticleById($var))) { $var = (int) $default; } } break; case 'rex-category-id': $var = (int) $var; if ($mode == 'found') { if (!OOCategory::isValid(OOCategory::getCategoryById($var))) { $var = (int) $default; } } break; case 'rex-clang-id': $var = (int) $var; if ($mode == 'found') { if (empty($REX['CLANG'][$var])) { $var = (int) $default; } } break; case 'rex-template-id': case 'rex-ctype-id': case 'rex-slice-id': case 'rex-module-id': case 'rex-action-id': case 'rex-media-id': case 'rex-mediacategory-id': case 'rex-user-id': // erstmal keine weitere validierung $var = (int) $var; break; // ---------------- PHP types // ---------------- PHP types case 'bool': case 'boolean': $var = (bool) $var; break; case 'int': case 'integer': $var = (int) $var; break; case 'double': $var = (double) $var; break; case 'float': case 'real': $var = (double) $var; break; case 'string': $var = (string) $var; break; case 'object': $var = (object) $var; break; case 'array': if ($var === '') { $var = array(); } else { $var = (array) $var; } break; // kein Cast, nichts tun // kein Cast, nichts tun case '': break; default: // check for array with generic type if (strpos($vartype, 'array[') === 0) { if (empty($var)) { $var = array(); } else { $var = (array) $var; } // check if every element in the array is from the generic type $matches = array(); if (preg_match('@array\\[([^\\]]*)\\]@', $vartype, $matches)) { foreach ($var as $key => $value) { try { $var[$key] = _rex_cast_var($value, $matches[1]); } catch (InvalidArgumentException $e) { // Evtl Typo im vartype, mit urspr. typ als fehler melden throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!'); } } } else { throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!'); } } else { $casted = false; } } if ($casted) { return $var; } } if (is_callable($vartype)) { $var = call_user_func($vartype, $var); } elseif (is_array($vartype)) { $var = _rex_cast_var($var, 'array'); $newVar = array(); foreach ($vartype as $cast) { if (!is_array($cast) || !isset($cast[0])) { throw new InvalidArgumentException('Unexpected vartype in _rex_cast_var()!'); } $key = $cast[0]; $innerVartype = isset($cast[1]) ? $cast[1] : ''; if (array_key_exists($key, $var)) { $newVar[$key] = _rex_cast_var($var[$key], $innerVartype); } elseif (!isset($cast[2])) { $newVar[$key] = _rex_cast_var('', $innerVartype); } else { $newVar[$key] = $cast[2]; } } $var = $newVar; } elseif (is_string($vartype)) { throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!'); } else { throw new InvalidArgumentException('Unexpected vartype in _rex_cast_var()!'); } return $var; }