getConfig('type') == App_Newsletter_Form_Config::TYPE_DEFAULT) { $paramsCount = count($this->_restParams); $years = $this->_getDataObj()->getYears4Select(); if ($paramsCount == 0) { if (!empty($years)) { if ($this->_doc->isPagePreviewMode()) { $url = BASE_URL_LANGUAGE . '/' . Zend_Registry::get('config')->cms->previewAlias . '/' . CMS_PREVIEW_PAGE_ID . '/' . CURRENT_PAGE_FINAL . '/' . reset($years); } else { $url = BASE_URL_LANGUAGE . '/' . CURRENT_PAGE_FINAL . '/' . reset($years); } $this->redirect($url); } } else if ($paramsCount == 1 && in_array($this->_restParams[0], $years)) { $this->_getDataObj()->setFilter('year', $this->_restParams[0]); } else { $this->_doc->display404(); } } return parent::exec(); } protected function _doList() { if ($this->getConfig('type') == App_Newsletter_Form_Config::TYPE_DEFAULT) { $this->_addTabsItem(); $this->_addFilterItem(); } $this->_addListItem(); $this->_postList(); return $this; } protected function _addTabsItem() { $item = []; $item['tpl'] = $this->getTemplate('years-tabs.tpl'); $item['years'] = $this->_getDataObj()->getYears4Select(); $item['url'] = BASE_URL_LANGUAGE . '/' . CURRENT_PAGE_FINAL; $item['current'] = $this->_getDataObj()->getFilter('year'); $this->_addItem($item); return $this; } /** * @return mixed */ protected function _getListItem() { $list = $this->_getList(); if ($this->getConfig('type') == App_Newsletter_Form_Config::TYPE_SMALL) { $list->setIpp($this->getConfig('smallListIpp')); $list->setListTemplate('small-list.tpl'); } $item = parent::_getListItem(); $item['currentYear'] = $this->_getDataObj()->getFilter('year'); if (!$item['currentYear']) { $item['currentYear'] = date('Y'); } $item['downloadLogUrl'] = $this->_getDataObj()->getLogUrl($item['currentYear']); if (($year = $this->getRestParam(0))) { $this->_doc->appendTitle($year); } return $item; } public function getSideBlockItem(array $blockData = []) { $item = $this->_getListItem(); if (!empty($item['list'])) { return $item; } return null; } protected function _getLog() { if (null === $this->_log) { parent::_getLog(); $this->_log->setAction('list', 'Viewed ' . $this->_getDataObj()->getFilter('year') . ' Newsletters list'); $this->_log->setAction('download', 'Downloaded %itemTitle%'); } return $this->_log; } protected function _doDownloadAjax() { $this->_log(); $this->_displayJson(['success' => true]); } protected function _doDownload() { $this->_do404(); } }