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(array('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['imageConfig'] = $this->_getImageConfig(); $item['backUrl'] = $this->_getViewPage('url'); return parent::_prepareViewItem($item); } protected function _initDetailsPage(array $item) { $this->_addFeedLink(); Qs_Navigation::append(array('title' => $item['title'])); return parent::_initDetailsPage($item); } protected function _getImageConfig() { $config = array(); $config['hasImage'] = (bool) $this->getConfig('hasImage'); if ($config['hasImage']) { $config = array_merge($config, (array) $this->getConfig('image')->toArray()); if (empty($config['width'])) { $config['width'] = self::DEFAULT_IMAGE_WIDTH; } if (empty($config['height'])) { $config['height'] = self::DEFAULT_IMAGE_HEIGHT; } if (empty($config['resizeMethodAlias'])) { $config['resizeMethodAlias'] = self::DEFAULT_IMAGE_RESIZE_METHOD_ALIAS; } $config['resizeMethod'] = Qs_ImageFs::getResizeMethod($config['resizeMethodAlias']); } return $config; } 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; } $stmt = $this->_getDataObj()->getListStatement4XmlSitemap(); $pageUrl = ('y' == $this->_doc->getOption('isSecure')) ? BASE_URL_HTTPS : BASE_URL_HTTP; $pageUrl .= '/' . $this->_doc->getOption('fullAlias'); while ($item = $stmt->fetch()) { $xml->writeUrl($pageUrl . '/' . $item['id']); } return $this; } protected function _getViewPage($field = null, $default = null) { $page = Qs_SiteMap::findFirst(null, array('type' => 'News_'), array('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', array ( 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => SITE_NAME ) ); } public function getSideBlockItem(array $blockData = array()) { 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; } }