getConfig('type') && null != $this->_restAlias) { $htmlBlockIndex = null; foreach ($items as $index => $item) { if ($item['type'] == 'HtmlBlock_') { $htmlBlockIndex = $index; break; } } if (null !== $htmlBlockIndex) { unset($items[$htmlBlockIndex]); } } return $this; } public function exec() { if (App_News_Form_Config::TYPE_FEATURED == $this->getConfig('type') && true !== $this->getConfig('hasFeatured') ) { return $this; } $this->_initApplication(); return parent::exec(); } protected function _initApplication() { switch ($this->getConfig('type')) { case App_News_Form_Config::TYPE_FEATURED: $this->_getDataObj()->setFilter(['featured' => 'y']); $this->_listTitle = 'Last News & Events'; $this->_listTemplate = 'featured-list.tpl'; $this->_getList()->setIsDisabledLimit(true); break; case App_News_Form_Config::TYPE_SMALL: $this->_listTemplate = 'small-list.tpl'; $this->_listTitle = 'Last News & Events'; $this->_listIpp = self::SMALL_LIST_IPP; $this->_getDataObj()->getListSelect()->limit(self::SMALL_LIST_IPP); $this->_getList()->setIsDisabledLimit(true); break; default: $params = $this->getRestParams(); $paramsCount = count($params); if (0 === $paramsCount) { $this->_defaultAction = reset($this->_actions); } elseif (1 === $paramsCount) { if ('feed' == $params[0]) { $this->_defaultAction = 'feed'; } else { $this->_getDataObj()->setPrimaryKeyByAlias($params[0]); $this->_defaultAction = 'view'; } } else { $this->_doc->display404(); } break; } return $this; } protected function _getListOptions() { $options = parent::_getListOptions(); if (!empty($this->_listIpp)) { $options['ipp'] = $this->_listIpp; $options['viewAlias'] = $this->_getViewAlias(); $options['title'] = $this->_listTitle; $options['listTemplate'] = $this->_listTemplate; } return $options; } protected function _addListItem() { $this->_addFeedLink(); return parent::_addListItem(); } protected function _prepareViewItem(array &$item) { $item['backUrl'] = $this->_getViewPage('url'); return parent::_prepareViewItem($item); } protected function _initDetailsPage(array $item) { $this->_addFeedLink(); Qs_Navigation::append(['title' => $item['title']]); return parent::_initDetailsPage($item); } protected function _doFeed() { $feed = Zend_Feed::importArray($this->_getDataObj()->getFeedData(), 'rss'); $feed->send(); exit(); } public function writeXmlSitemap(App_Sitemap_Xml_Writer $xml) { if (App_News_Form_Config::TYPE_DEFAULT != $this->getConfig('type', App_News_Form_Config::TYPE_DEFAULT)) { return $this; } return parent::writeDefaultXmlSitemap($xml); } protected function _getViewPage($field = null, $default = null) { $page = Qs_SiteMap::findFirst(null, ['type' => 'News_'], ['type' => 'default']); return Qs_Array::get($page, $field, $default); } protected function _getViewAlias() { if (null == $this->_viewAlias) { $this->_viewAlias = $this->_getViewPage('fullAlias'); } return $this->_viewAlias; } protected function _addFeedLink() { $this->_doc->addStyleSheet( BASE_URL_LANGUAGE . '/' . $this->_getViewAlias() . '/feed', [ 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => SITE_NAME, ] ); } public function getSideBlockItem(array $blockData = []) { if (App_News_Form_Config::TYPE_FEATURED == $this->getConfig('type') && true !== $this->getConfig('hasFeatured') ) { return null; } $this->_initApplication(); $item = $this->_getListItem(); $item['viewAlias'] = $this->_getViewAlias(); if (!empty($item['list'])) { $item['tpl'] = $this->getTemplate($this->_listTemplate); $this->_addFeedLink(); return $item; } return null; } }