/** * @copydoc DataSet::loadData */ protected function loadData() { $sitemap = E()->getMap(); $methodName = 'getChilds'; if ($this->getParam('recursive')) { $methodName = 'getDescendants'; } if (is_numeric($this->getParam('id'))) { $param = (int) $this->getParam('id'); $sitemap = E()->getMap(E()->getSiteManager()->getSiteByPage($param)->id); } elseif ($this->getParam('id') == self::PARENT_PAGE) { $param = $sitemap->getParent($this->document->getID()); } elseif ($this->getParam('id') == self::CURRENT_PAGE) { $param = $this->document->getID(); } elseif ($this->getParam('id') == self::ALL_PAGES) { $methodName = 'getInfo'; $param = NULL; if (!($siteId = $this->getParam('site'))) { $siteId = E()->getSiteManager()->getCurrentSite()->id; } $sitemap = E()->getMap($siteId); } elseif (!$this->getParam('id')) { if ($this->getParam('site')) { $sitemap = E()->getMap($this->getParam('site')); } $param = $sitemap->getDefault(); } else { if ($this->getParam('site')) { $sitemap = E()->getMap($this->getParam('site')); } $param = $sitemap->getPagesByTag($this->getParam('id')); if (!empty($param)) { list($param) = $param; } } $data = call_user_func([$sitemap, $methodName], $param); if (!empty($data)) { if ($this->getParam('recursive')) { $this->getBuilder()->setTree($sitemap->getChilds($param, true)); } $hasDescriptionRtf = (bool) $this->getDataDescription()->getFieldDescriptionByName('DescriptionRtf'); //По умолчанию - фильтрация отсутствует $filteredIDs = true; if ($this->getParam('tags')) { $filteredIDs = TagManager::getFilter($this->getParam('tags'), 'share_sitemap'); } reset($data); while (list($key, $value) = each($data)) { if ($filteredIDs !== true && is_array($filteredIDs) && !in_array($key, $filteredIDs)) { unset($data[$key]); continue; } if ($key == $sitemap->getDefault() && $this->getParam('id') != self::ALL_PAGES) { unset($data[$key]); } else { $data[$key]['Id'] = $key; $data[$key]['Segment'] = E()->getMap($data[$key]['Site'])->getURLByID($key); $data[$key]['Name'] = $value['Name']; $data[$key]['Redirect'] = Response::prepareRedirectURL($value['RedirectUrl']); $data[$key]['Site'] = E()->getSiteManager()->getSiteByID($data[$key]['Site'])->base; if ($hasDescriptionRtf) { $data[$key]['DescriptionRtf'] = $value['DescriptionRtf']; } } } //stop($data); } else { $this->setBuilder(new SimpleBuilder()); } return $data; }
protected function loadData() { $sitemap = E()->getMap(); $data = $sitemap->getInfo(); $this->filteredIDs = true; if (!empty($data)) { if ($this->getParam('tags')) { $this->filteredIDs = TagManager::getFilter($this->getParam('tags'), 'share_sitemap'); } if (!empty($this->filteredIDs)) { reset($data); while (list($key, $value) = each($data)) { if ($this->filteredIDs !== true && !in_array($key, $this->filteredIDs)) { unset($data[$key]); continue; } if ($key == $sitemap->getDefault()) { unset($data[$key]); } else { $data[$key]['Id'] = $key; $data[$key]['Segment'] = $sitemap->getURLByID($key); $data[$key]['Name'] = $value['Name']; $data[$key]['Redirect'] = Response::prepareRedirectURL($value['RedirectUrl']); } } } else { $data = array(); } } return $data; }