'date DESC'); protected $_viewAlias = null; public function exec() { switch ($this->getConfig('type')) { case 'small': $this->_listTemplate = 'small-list.tpl'; $this->_listOptions['defaultIpp'] = 3; 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->dataObj->setPrimaryKey($params[0]); $this->_defaultAction = 'view'; } else { $this->doc->display404(); } } else { $this->doc->display404(); } break; } return parent::exec(); } protected function _addListItem($list = null, $template = 'list.tpl') { $this->list->viewAlias = $this->_getViewAlias(); $this->_addFeedLink(); return parent::_addListItem($list, $this->_listTemplate); } protected function _doView() { $item = $this->dataObj->getData(); if (empty($item)) { $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; } $this->_addItem($item); Qs_Navigation::append(array('title' => $item['title'], 'url' => $item['backUrl'] . '/' . $item['id'])); } 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->dataObj->getFeedData(), 'rss'); $feed->send(); exit(); } public function fillConfigForm($form) { $form->addElement( 'select', 'type', array( 'label' => 'Block Type', 'multiOptions' => array('default' => 'Default', 'small' => 'Small') ) ); return $this; } public function writeXmlSitemap($xml) { if ('default' != $this->getConfig('type', 'default')) { return $this; } $stmt = $this->dataObj->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' => 'Association_'), 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, 'media' => '' ) ); } public function getSideBlockItem() { $item = array(); $item['list'] = $this->dataObj->getList(array('limit'=>App_Association_View::SMALL_LIST_COUNT, 'order'=>'date DESC')); $item['viewAlias'] = Qs_SiteMap::find(null, array('type' => 'Association_'), array('type' => 'default'), 'fullAlias'); $item['tpl'] = 'Association/small-list.tpl'; return $item; } }