_initApplication(); $this->_initAction(); if ($this->_action == 'view') { $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_LegislativeUpdate_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_LegislativeUpdate_Form_Config::TYPE_FEATURED: $this->_getDataObj()->setFilter(array('featured' => 'y')); $this->_listTitle = 'Last Legislative Updates'; $this->_listTemplate = 'featured-list.tpl'; $this->_getList()->setIsDisabledLimit(true); break; case App_LegislativeUpdate_Form_Config::TYPE_SMALL: $this->_listTemplate = 'small-list.tpl'; $this->_listTitle = 'Last Legislative Updates'; $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'; } elseif (is_numeric($params[0])) { $this->_getDataObj()->setPrimaryKey($params[0]); $this->_defaultAction = 'view'; } else { $this->_doc->display404(); } } else { $this->_doc->display404(); } break; } return $this; } protected function _addListItem($list = null) { $this->_addFeedLink(); if (!empty($this->_listIpp)) { if (null == $list) { $list = $this->_getList(); } $list->setIpp($this->_listIpp); } $item = $this->_getListItem($list); $item['viewAlias'] = $this->_getViewAlias(); $item['title'] = $this->_listTitle; $this->_addLinksItem(); $item['tpl'] = $this->getTemplate($this->_listTemplate); $this->_addItem($item); return $this; } protected function _doView() { $item = $this->_getDataObj()->getData(); if (empty($item) || (array_key_exists('enabled', $item) && 'y' != $item['enabled'])) { $this->_doc->display404(); } $this->_addFeedLink(); $this->_doc->setKeywords($item['metaKeywords']); $this->_doc->setDescription($item['metaDescription']); $item['tpl'] = $this->getTemplate('view.tpl'); $item['backUrl'] = $this->_getBackUrl(CURRENT_PAGE_FINAL); if ($item['backUrl'] == '') { $item['backUrl'] = CURRENT_PAGE_FINAL; } $item['imageConfig'] = $this->_getImageConfig(); $this->_addItem($item); Qs_Navigation::append(array('title' => $item['title'], 'url' => $item['backUrl'] . '/' . $item['id'])); $this->_postView(); return $this; } 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 _getBackUrl($sessionName = null) { if (is_null($sessionName)){ $sessionName = CURRENT_PAGE; } $session = new Qs_Session_Namespace($sessionName); if (isset($session->backUrl)) { return $session->backUrl; } return ''; } protected function _doFeed() { $feed = Zend_Feed::importArray($this->_getDataObj()->getFeedData(), 'rss'); $feed->send(); exit(); } public function writeXmlSitemap(App_Sitemap_Xml_Writer $xml) { if (App_LegislativeUpdate_Form_Config::TYPE_DEFAULT != $this->getConfig( 'type', App_LegislativeUpdate_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 _getViewAlias() { if (null == $this->_viewAlias) { $this->_viewAlias = Qs_SiteMap::find( null, array('type' => 'LegislativeUpdate_'), array('type' => 'default'), '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 ) ); } }