'date DESC'); public function preDispatch(&$items) { if ($this->_defaultAction == 'view' && isset($items[0]) && $items[0]['type'] == 'HtmlBlock_') { unset($items[0]); } } protected function _init() { parent::_init(); $params = $this->getRestParams(); if (count($params) == 1 && is_numeric($params[0])) { $this->dataObj->setPrimaryKey($params[0]); $this->_defaultAction = 'view'; } else { switch ($this->getConfig('type')) { case 'small': $this->_listTemplate = 'small-list.tpl'; $this->_listOptions['defaultIpp'] = 3; break; default: break; } } } protected function _addListItem($list = null, $template = 'list.tpl') { $this->list->viewAlias = Qs_SiteMap::find(null, array('type' => 'News_'), array('type' => 'default'), 'fullAlias'); return parent::_addListItem($list, $this->_listTemplate); } protected function _doView() { $item = $this->dataObj->getData(); $this->doc->addItemCrumb(array('title' => $item['title'])); $item['tpl'] = $this->getTemplate('view.tpl'); $item['backUrl'] = $this->_getBackUrl(CURRENT_PAGE_FINAL); if ($item['backUrl'] == '') { $item['backUrl'] = CURRENT_PAGE_FINAL; } $this->_addItem($item); } protected function _addItem($item) { parent::_addItem($item); } 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 ''; } 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; } }