'sorter ASC'); const FEATURED_LIMIT = 3; public function smallExec() { $this->_listTemplate = 'small-list.tpl'; $this->_defaultAction = 'ftsmall'; $this->_listOptions['defaultIpp'] = self::FEATURED_LIMIT; $this->dataObj->_isSmallList = true; parent::exec(); } 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->_listTemplate = 'featured-list.tpl'; $this->_defaultAction = 'ftlist'; break; case 'small': $this->_listTemplate = 'small-list.tpl'; $this->_defaultAction = 'ftsmall'; $this->_listOptions['defaultIpp'] = self::FEATURED_LIMIT; break; default: $this->_listOptions['defaultIpp'] = 10; break; } } } protected function _addListItem($list = null, $template = 'list.tpl') { $this->list->viewAlias = Qs_SiteMap::find(null, array('type' => 'Projects_'), array('type' => 'default'), 'fullAlias'); return parent::_addListItem($list, $this->_listTemplate); } protected function _doFtlist() { $item['list'] = $this->dataObj->getFeaturedList(self::FEATURED_LIMIT); $item['tpl'] = $this->getTemplate('featured-list.tpl'); $item['backUrl'] = $this->_getBackUrl(CURRENT_PAGE_FINAL); $item['viewAlias'] = Qs_SiteMap::find(null, array('type' => 'Projects_'), array('type' => 'default'), 'fullAlias'); if ($item['backUrl'] == '') { $item['backUrl'] = CURRENT_PAGE_FINAL; } $this->doc->addScript('js/app/featured-projects.js', array(), 'fetturedProjects'); $this->_addItem($item); return $this; } protected function _doFtsmall() { $item['list'] = $this->dataObj->getFeaturedList(self::FEATURED_LIMIT); $item['tpl'] = $this->getTemplate('small-list.tpl'); $item['backUrl'] = $this->_getBackUrl(CURRENT_PAGE_FINAL); $item['viewAlias'] = Qs_SiteMap::find(null, array('type' => 'Projects_'), array('type' => 'default'), 'fullAlias'); if ($item['backUrl'] == '') { $item['backUrl'] = CURRENT_PAGE_FINAL; } $this->_addItem($item); return $this; } 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) { $item['templatePath'] = $this->_getTemplatePath(); if ($this->dataObj->_isSmallList) { $this->doc->addItem($item, 'RIGHT_ITEMS'); } else { $this->doc->addItem($item); } return $this; } 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; } }