'published DESC'); protected $_listTemplate = 'list.tpl'; protected $_query; protected $_viewAlias; protected function _initAction() { return parent::_initAction(); } public function exec() { switch ($this->getConfig('type')) { case 'small': $this->_listTemplate = 'small-list.tpl'; $this->_listOptions['defaultIpp'] = 3; $this->dataObj->disableFilter(); break; default: $params = $this->getRestParams(); $years = $this->dataObj->getYearsList(true, true); $this->_addYearFilterItem(); if (!empty($params)) { if (ctype_digit($params[0]) && (int) $params[0] > 0 && in_array($params[0], $years)) { $this->dataObj->setCurrentYear(trim($params[0])); } else { $this->doc->display404(); } } else { $year = array_pop($years); if (!empty($year)) { Qs_Http::redirect(BASE_URL_LANGUAGE . '/' . CURRENT_PAGE_FINAL . '/' . $year); } } break; } parent::exec(); } protected function _getViewAlias() { if (null == $this->_viewAlias) { $this->_viewAlias = Qs_SiteMap::find(null, array('type' => 'ChimesNewsletter_'), array('type' => 'default'), 'fullAlias'); } return $this->_viewAlias; } public function fillConfigForm(Qs_Form $form) { $form->addElement( 'select', 'type', array( 'label' => 'Block Type', 'multiOptions' => array('default' => 'Default', 'small' => 'Small') ) ); return $this; } protected function _bindListColumns(Qs_ViewController_List $list) { $list->addColumn( 'date', 'published', array( 'format' => '%B %Y', 'attribs' => array('width' => 100), 'title' => 'Published' ) ) ->addColumn( 'text', 'headline', array( 'attribs' => array('width' => 300, 'class' => 'headline'), 'title' => 'Headline' ) ) ->addColumn( 'download_link', 'file', array( 'title' => 'Download', 'text' => 'Download (.PDF)' ) ); return $this; } protected function _doList() { $this->_saveBackUrl(); $this->_addFilterItem(); $this->_addLinksItem(); $this->_addListItem(null, $this->_listTemplate); return $this; } protected function _addYearFilterItem() { $yeas = $this->dataObj->getYearsList(true, true); if (!empty($yeas)) { $item = array( 'years' => $yeas, 'current' => $this->dataObj->getCurrentYear(), 'tpl' => $this->getTemplate('yearsFilter.tpl') ); $this->_addItem($item); } return $this; } protected function _addListItem(Qs_ViewController_List $list = null, $template = 'list.tpl') { if (null == $list) { $list = $this->list; } $list->viewAlias = $this->_getViewAlias(); $this->_bindListColumns($list); $item = $list->toArray(); if (empty($this->_query)) { $this->_query = Qs_Sys_Request::getRequestValue('query'); } $item['header'] = $this->dataObj->getCurrentYear() . ' Newsletter Headlines'; if (array_key_exists('paginator', $item)) { if ($item['paginator']['last'] < $list->getPageNumber() && ($item['paginator']['pageCount'] != 0 || $list->getPageNumber() > 1)) { $redirectUrl = str_replace($list->getPaginatorPagePlaceholder(), 1, $list->getPaginatorUrl()); $this->redirect($redirectUrl, 307); } } $item['tpl'] = $this->getTemplate($template); $this->_addItem($item); return $this; } protected function _bindFilterFields($form) { parent::_bindFilterFields($form); $form->query->setDescription(''); $form->query->setLabel('Search by newsletter headline'); return $this; } }