'header-image.tpl' ); protected $_footer; protected $_hasLog = true; protected $_virtualMenu = array(); protected function _init() { parent::_init(); return $this; } protected function _beforeDisplay() { \App\BrowserCheck\View::initAlert(); $list = Qs_Db_Language::getList(); if (count($list) > 1) { $this->assign('LANGUAGES', $list); } $this->_initHeaderImage(); $this->_initSideBlockContent(); $this->_initSocialLinks(); $this->_initContactPopup(); return parent::_beforeDisplay(); } protected function _log() { $logOptions = array( 'role' => $this->getAuth()->getRole(), 'roleId' => $this->getAuthData('id'), 'sessionId' => Zend_Session::getId(), 'ip' => $_SERVER['REMOTE_ADDR'], 'controller' => 'App_Cms_View', 'config' => Qs_Application::getConfig('Doc'), ); if ($this->_options['id']) { $logOptions['objectId'] = $this->_options['id']; } $log = new Qs_ViewController_Log($logOptions); $log->write('view', array('itemTitle' => strip_tags($this->getHeader()))); return $this; } public function getCacheObj($frontend = null, $backend = null) { if (null === $frontend) { $frontend = array('lifetime' => 7200, 'automatic_serialization' => true); } if (null === $backend) { $backend = array('cache_dir' => BASE_PATH . '/tmp/cache'); } return Zend_Cache::factory('Core', 'File', $frontend, $backend); } protected function _initContactPopup() { $contactForm = new App_Form_Contact_View(); $contactForm->setDoc($this); $contactForm->setConfig(array('type' => 'popup')); $contactForm->exec(); return $this; } protected function _initFooter() { $footerMenu = false; if (Qs_Application::getConfig('Doc')->hasFooterMenu) { $siteMap = $this->getFooter(); if (!empty($siteMap)) { $footerMenu = array(); $footerMenu['tpl'] = $this->getTemplate('footer-menu.tpl'); $footerMenu['simpleFooterMenu'] = Qs_Application::getConfig('Doc')->simpleFooterMenu; $footerMenu['siteMap'] = $siteMap; $footerMenu = new Qs_Doc_Item($footerMenu); } } $this->assign('FOOTER_MENU', $footerMenu); return parent::_initFooter(); } public function getMenu() { if (null === $this->_content['menu']) { $menu = Qs_SiteMap::getMenu(); if ($this->_virtualMenu) { $menu = Qs_Array::mergeRecursive($menu, $this->_virtualMenu); } Qs_SiteMap::prepareMobileMenu($menu); $this->_content['menu'] = $menu; } return $this->_content['menu']; } /** * Return footer menu items * * @return array */ public function getFooter() { if (null === $this->_footer) { $this->_footer = Qs_SiteMap::getFooter(); } return $this->_footer; } protected function _initSideBlockContent() { if (class_exists('App_SideBlock_View') && 'y' === $this->getOption('showSideBlock')) { $view = new App_SideBlock_View(); $view->setDoc($this); $view->exec(); } return $this; } protected function _initSocialLinks() { if (Qs_Application::getConfig('SocialLink')->get('enabled')) { $linksView = new App_SocialLink_View(); $this->assign('SOCIAL_LINKS', $linksView->getItem()); } return $this; } protected function _initHeaderImage() { if ($this->getCmsConfig()->get('hasHeaderImage')) { $excludePages = App_Cms_Obj::getImageHeaderExcludePageIds(); if (!in_array($this->getOption('idPage'), $excludePages)) { $item = $this->_getHeaderImageItem(); $this->addItem($item, 'TOP_ITEMS'); $this->addScript('js/app/doc/header-image.js'); $scriptOptions = [ 'images' => $item['images'] ]; $this->addReadyFunction('new app.HeaderImage', [$scriptOptions]); } } return $this; } public function getCmsConfig() { return Qs_Application::getConfig('cms'); } protected function _getHeaderImageItem() { $item = $this->_headerImageItem; if (!is_array($item)) { $item = array(); } if (!isset($item['tpl'])) { $item['tpl'] = $this->getTemplate($item['templateName']); } $image = $this->_getHeaderImage(); if (!$image) { $image = App_Settings_Obj::get('headerImage');; } $config = $this->getCmsConfig(); $item['config'] = $config->toArray(); $screenWidth = 0; $screenWidthList = array(320, 560, 767, 960, 1920); foreach ($screenWidthList as $width) { $height= round($width * $config->headerImageHeight / $config->headerImageWidth); $screenImage = Qs_ImageFs::get($image, $width, $height, $config->headerImageResizeMethod); $item['images'][$screenWidth] = BASE_URL . '/' . $screenImage; $screenWidth = $width; } return $this->_headerImageItem = $item; } public function addHeaderImageItemOptions(array $options) { $this->_headerImageItem = array_merge($this->_headerImageItem, $options); return $this; } public function setHeaderImageItem($field = null, $value = null) { if (is_array($field)) { $this->_headerImageItem = $field; } else { Qs_Array::set($this->_headerImageItem, $field, $value); } return $this; } protected function _getHeaderImage($idPage = null) { if (null == $idPage) { $image = $this->getOption('headerImage'); $idParent = $this->getOption('idParent'); } else { $meta = App_Cms_Obj::getInstance()->getMeta($idPage); $image = $meta['headerImage']; $idParent = $meta['idParent']; } if (empty($image) && !empty($idParent)) { $image = $this->_getHeaderImage($idParent); } return $image; } /** * Set virtual items for main menu * * @param array $items * @return App_Doc_SIte */ public function setVirtualMenu($items) { if (!empty($items)) { foreach ($items as $key => $instanceName) { $virtualConfig = null; if (is_array($instanceName)) { $virtualConfig = $instanceName; $instanceName = $key; } $viewInstanceName = 'App_' . $instanceName . 'View'; if (class_exists($viewInstanceName)) { /** @var $view Qs_ViewController */ $view = new $viewInstanceName(); $view->setDoc($this); if (method_exists($view, 'getMenu')) { $mainAlias = Qs_SiteMap::find( array('enabled' => 'y'), array('type' => $instanceName), $virtualConfig, 'alias' ); if ($mainAlias) { $virtualItems = $view->getMenu(); if (!empty($virtualItems)) { $virtual = array($mainAlias => array('sub' => $virtualItems)); $this->_virtualMenu = Qs_Array::mergeRecursive($this->_virtualMenu, $virtual); } } } else { Qs_Debug::log('Method getMenu not exist in ' . $viewInstanceName . ' class for virtual menu'); } } else { Qs_Debug::log('Class ' . $viewInstanceName . ' not exist for virtual menu'); } } $this->_content['menu'] = null; } return $this; } }