protected function loadData() { if ($tags = $this->getParam('tags')) { if (!($tagFilter = TagManager::getFilter(TagManager::getID($tags), $this->getTableName()))) { return false; } $this->addFilterCondition([$this->getTableName() . '.' . $this->getPK() => $tagFilter]); } $result = parent::loadData(); return $result; }
protected function loadData() { $result = []; $filteredIDs = true; if ($this->getParam('tags')) { $filteredIDs = TagManager::getFilter($this->getParam('tags'), 'share_sites'); } if (!empty($filteredIDs)) { foreach (E()->getSiteManager() as $siteID => $site) { if ($filteredIDs !== true && in_array($siteID, $filteredIDs) || $filteredIDs === true) { $result[] = ['site_id' => $site->id, 'site_name' => $site->name, 'site_host' => $site->protocol . '://' . $site->host . ($site->port != 80 ? ':' . $site->port : '') . $site->root]; } } } return $result; }
/** * @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; }
/** * Create calendar. * Calendar helps to navigate over the news. */ protected function createCalendar() { $calendarParams = array(); $ap = $this->getStateParams(true); if ($this->getState() == 'main') { if (isset($ap['year']) && isset($ap['month']) && isset($ap['day'])) { if ($this->getParam('hasCalendar')) { $calendarParams['month'] = $ap['month']; $calendarParams['year'] = $ap['year']; $calendarParams['date'] = \DateTime::createFromFormat('Y-m-d', $ap['year'] . '-' . $ap['month'] . '-' . $ap['day']); } $additionalFilter = 'DAY(news_date) = "' . $ap['day'] . '" AND MONTH(news_date) = "' . $ap['month'] . '" AND YEAR(news_date) = "' . $ap['year'] . '"'; } elseif (isset($ap['year']) && isset($ap['month'])) { if ($this->getParam('hasCalendar')) { $calendarParams['month'] = $ap['month']; $calendarParams['year'] = $ap['year']; } $additionalFilter = 'MONTH(news_date) = "' . $ap['month'] . '" AND YEAR(news_date) = "' . $ap['year'] . '"'; } elseif (isset($ap['year'])) { if ($this->getParam('hasCalendar')) { $calendarParams['year'] = $ap['year']; } $additionalFilter = 'YEAR(news_date) = "' . $ap['year'] . '"'; } if ($this->getParam('tags')) { $filteredIDs = TagManager::getFilter($this->getParam('tags'), $this->getTableName()); if (!empty($filteredIDs)) { $this->addFilterCondition(array($this->getTableName() . '.news_id' => $filteredIDs)); } else { $this->addFilterCondition(array($this->getTableName() . '.news_id' => 0)); } } } elseif ($this->getState() == 'view' && $this->getParam('hasCalendar')) { $calendarParams['month'] = $ap['month']; $calendarParams['year'] = $ap['year']; $calendarParams['date'] = \DateTime::createFromFormat('Y-m-d', $ap['year'] . '-' . $ap['month'] . '-' . $ap['day']); } if ($this->getParam('hasCalendar')) { $calendarParams['filter'] = $this->getFilter(); $calendarParams['tableName'] = $this->getTableName(); //Создаем компонент календаря новостей $this->document->componentManager->addComponent($this->calendar = $this->document->componentManager->createComponent('calendar', 'Energine\\apps\\components\\NewsCalendar', $calendarParams)); } if (isset($additionalFilter)) { $this->addFilterCondition($additionalFilter); } }