protected function addCatOptions() { if ($this->add_homepage) { $this->addOption('Homepage', 0); } if ($this->rootId !== null) { if (is_array($this->rootId)) { foreach ($this->rootId as $rootId) { if ($rootCat = rex_category::get($rootId, $this->clang)) { $this->addCatOption($rootCat, 0); } } } else { if ($rootCat = rex_category::get($this->rootId, $this->clang)) { $this->addCatOption($rootCat, 0); } } } else { if (!$this->check_perms || rex::getUser()->getComplexPerm('structure')->hasCategoryPerm(0)) { if ($rootCats = rex_category::getRootCategories($this->ignore_offlines, $this->clang)) { foreach ($rootCats as $rootCat) { $this->addCatOption($rootCat); } } } elseif (rex::getUser()->getComplexPerm('structure')->hasMountpoints()) { $mountpoints = rex::getUser()->getComplexPerm('structure')->getMountpoints(); foreach ($mountpoints as $id) { $cat = rex_category::get($id, $this->clang); if ($cat && !rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($cat->getParentId())) { $this->addCatOption($cat, 0); } } } } }
public function getTree($category_id) { $category = rex_category::get($category_id); $mountpoints = rex::getUser()->getComplexPerm('structure')->getMountpoints(); if (count($mountpoints) > 0) { $roots = []; foreach ($mountpoints as $mp) { if (rex_category::get($mp)) { $roots[] = rex_category::get($mp); } } if (!$category && 1 === count($roots)) { $category = $roots[0]; } } else { $roots = rex_category::getRootCategories(); } $tree = []; if ($category) { foreach ($category->getParentTree() as $cat) { $tree[] = $cat->getId(); } } $rendered = $this->renderTree($roots, $tree); // add css class to root node return '<ul class="list-group rex-linkmap-list-group"' . substr($rendered, 3); }
protected function _getNavigation($category_id, $depth = 1) { if ($category_id < 1) { $nav_obj = rex_category::getRootCategories(); } else { $nav_obj = rex_category::get($category_id)->getChildren(); } $return = ''; if (count($nav_obj) > 0) { $return .= '<ul class="rex-navi' . ($depth + 1) . '">'; } $lis = []; foreach ($nav_obj as $nav) { $li = []; $a = []; $li['class'] = []; $a['class'] = []; $a['href'] = [$nav->getUrl()]; if ($this->checkFilter($nav, $depth) && $this->checkCallbacks($nav, $depth, $li, $a)) { $li['class'][] = 'rex-article-' . $nav->getId(); // classes abhaengig vom pfad if ($nav->getId() == $this->current_category_id) { $li['class'][] = 'rex-current'; $a['class'][] = 'rex-current'; } elseif (in_array($nav->getId(), $this->path)) { $li['class'][] = 'rex-active'; $a['class'][] = 'rex-active'; } else { $li['class'][] = 'rex-normal'; } if (isset($this->linkclasses[$depth - 1])) { $a['class'][] = $this->linkclasses[$depth - 1]; } if (isset($this->classes[$depth - 1])) { $li['class'][] = $this->classes[$depth - 1]; } $li_attr = []; foreach ($li as $attr => $v) { $li_attr[] = $attr . '="' . implode(' ', $v) . '"'; } $a_attr = []; foreach ($a as $attr => $v) { $a_attr[] = $attr . '="' . implode(' ', $v) . '"'; } $l = '<li ' . implode(' ', $li_attr) . '>'; $l .= '<a ' . implode(' ', $a_attr) . '>' . htmlspecialchars($nav->getName()) . '</a>'; ++$depth; if (($this->open || $nav->getId() == $this->current_category_id || in_array($nav->getId(), $this->path)) && ($this->depth >= $depth || $this->depth < 0)) { $l .= $this->_getNavigation($nav->getId(), $depth); } --$depth; $l .= '</li>'; $lis[] = $l; } } if (count($lis) > 0) { return '<ul class="rex-navi' . $depth . ' rex-navi-depth-' . $depth . ' rex-navi-has-' . count($lis) . '-elements">' . implode('', $lis) . '</ul>'; } return ''; }
function enterObject() { $multiple = $this->getElement('multiple') == 1; $options = array(); if ($this->getElement('homepage')) { $options[0] = 'Homepage'; } $ignoreOfflines = $this->getElement('ignore_offlines'); $checkPerms = $this->getElement('check_perms'); $clang = (int) $this->getElement('clang'); $add = function (rex_category $cat, $level = 0) use(&$add, &$options, $ignoreOfflines, $checkPerms, $clang) { if (!$checkPerms || rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($cat->getId())) { $cid = $cat->getId(); $cname = $cat->getName(); if (rex::getUser()->hasPerm('advancedMode[]')) { $cname .= ' [' . $cid . ']'; } $options[$cid] = str_repeat(' ', $level) . $cname; $childs = $cat->getChildren($ignoreOfflines, $clang); if (is_array($childs)) { foreach ($childs as $child) { $add($child, $level + 1); } } } }; if ($rootId = $this->getElement('category')) { if ($rootCat = rex_category::getCategoryById($rootId, $clang)) { $add($rootCat); } } else { if (!$checkPerms || rex::getUser()->isAdmin() || rex::getUser()->hasPerm('csw[0]')) { if ($rootCats = rex_category::getRootCategories($ignoreOfflines, $clang)) { foreach ($rootCats as $rootCat) { $add($rootCat); } } } elseif (rex::getUser()->getComplexPerm('structure')->hasMountpoints()) { $mountpoints = rex::getUser()->getComplexPerm('structure')->getMountpoints(); foreach ($mountpoints as $id) { $cat = rex_category::getCategoryById($id, $clang); if ($cat && !rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($cat->getParentId())) { $add($cat); } } } } if ($multiple) { $size = (int) $this->getElement('size'); if ($size < 2) { $size = count($options); } } else { $size = 1; } if (!is_array($this->getValue())) { $this->setValue(explode(',', $this->getValue())); } $this->params['form_output'][$this->getId()] = $this->parse('value.select.tpl.php', compact('options', 'multiple', 'size')); $this->setValue(implode(',', $this->getValue())); $this->params['value_pool']['email'][$this->getName()] = $this->getValue(); if ($this->getElement(4) != 'no_db') { $this->params['value_pool']['sql'][$this->getName()] = $this->getValue(); } }
public static function generatePathFile($params) { $setDomain = function (rex_yrewrite_domain &$domain, &$path, rex_structure_element $element) { $id = $element->getId(); $clang = $element->getClang(); if (isset(rex_yrewrite::$domainsByMountId[$id][$clang])) { $domain = rex_yrewrite::$domainsByMountId[$id][$clang]; $path = rex_yrewrite::$scheme->getClang($clang, $domain); } }; $setPath = function (rex_yrewrite_domain $domain, $path, rex_article $art) use($setDomain) { $setDomain($domain, $path, $art); if (($redirection = rex_yrewrite::$scheme->getRedirection($art, $domain)) instanceof rex_structure_element) { rex_yrewrite::$paths['redirections'][$art->getId()][$art->getClang()] = ['id' => $redirection->getId(), 'clang' => $redirection->getClang()]; unset(rex_yrewrite::$paths['paths'][$domain->getName()][$art->getId()][$art->getClang()]); return; } unset(rex_yrewrite::$paths['redirections'][$art->getId()][$art->getClang()]); $url = rex_yrewrite::$scheme->getCustomUrl($art, $domain); if (!is_string($url)) { $url = rex_yrewrite::$scheme->appendArticle($path, $art, $domain); } rex_yrewrite::$paths['paths'][$domain->getName()][$art->getId()][$art->getClang()] = ltrim($url, '/'); }; $generatePaths = function (rex_yrewrite_domain $domain, $path, rex_category $cat) use(&$generatePaths, $setDomain, $setPath) { $path = rex_yrewrite::$scheme->appendCategory($path, $cat, $domain); $setDomain($domain, $path, $cat); foreach ($cat->getChildren() as $child) { $generatePaths($domain, $path, $child); } foreach ($cat->getArticles() as $art) { $setPath($domain, $path, $art); } }; $ep = isset($params['extension_point']) ? $params['extension_point'] : ''; switch ($ep) { // clang and id specific update case 'CAT_DELETED': case 'ART_DELETED': foreach (self::$paths['paths'] as $domain => $c) { unset(self::$paths['paths'][$domain][$params['id']]); } unset(self::$paths['redirections'][$params['id']]); if (0 == $params['re_id']) { break; } $params['id'] = $params['re_id']; // no break // no break case 'CAT_ADDED': case 'CAT_UPDATED': case 'CAT_STATUS': case 'ART_ADDED': case 'ART_UPDATED': case 'ART_STATUS': rex_article_cache::delete($params['id']); $domain = self::$domainsByMountId[0][$params['clang']]; $path = self::$scheme->getClang($params['clang'], $domain); $art = rex_article::get($params['id'], $params['clang']); $tree = $art->getParentTree(); if ($art->isStartArticle()) { $cat = array_pop($tree); } foreach ($tree as $parent) { $path = self::$scheme->appendCategory($path, $parent, $domain); $setDomain($domain, $path, $parent); $setPath($domain, $path, rex_article::get($parent->getId(), $parent->getClang())); } if ($art->isStartArticle()) { $generatePaths($domain, $path, $cat); } else { $setPath($domain, $path, $art); } break; // update all // update all case 'CLANG_DELETED': case 'CLANG_ADDED': case 'CLANG_UPDATED': //case 'ALL_GENERATED': //case 'ALL_GENERATED': default: self::$paths = ['paths' => [], 'redirections' => []]; foreach (rex_clang::getAllIds() as $clangId) { $domain = self::$domainsByMountId[0][$clangId]; $path = self::$scheme->getClang($clangId, $domain); foreach (rex_category::getRootCategories(false, $clangId) as $cat) { $generatePaths($domain, $path, $cat); } foreach (rex_article::getRootArticles(false, $clangId) as $art) { $setPath($domain, $path, $art); } } break; } rex_file::putCache(self::$pathfile, self::$paths); }