'date DESC'); 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 'featured': $this->dataObj->setFilter(array('featured' => 'y')); $this->_listTemplate = 'featured-list.tpl'; break; case 'small': $this->_listTemplate = 'small-list.tpl'; $this->_listOptions['defaultIpp'] = 3; break; default: $this->_listOptions['defaultIpp'] = 10; 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(); $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', 'featured' => 'Featured', '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; } }