_restAlias) { foreach (array_keys($list) as $idx) { if ('HtmlBlock_' == $list[$idx]['type']) { unset($list[$idx]); break; } } } return $this; } public function exec() { $this->_initAction(); if (null === $this->_action) { $this->_doc->display404(); } return parent::exec(); } protected function _initAction() { if (null === $this->_action) { $params = $this->getRestParams(); if (empty($params)) { $this->_action = reset($this->_actions); } else if (1 == count($params)) { $this->_action = 'view'; $this->_getDataObj()->setPrimaryKeyByAlias($params[0]); } } return $this; } protected function _getListItem($list = null) { $item = array(); $item['list'] = $this->_getDataObj()->getAlbums(); $item['tpl'] = $this->getTemplate('list.tpl'); $item['image'] = $this->getConfig('image')->toArray(); return $item; } protected function _doView() { $this->_addViewItem(); $this->_addImagesItem(); $this->_postView(); return $this; } protected function _prepareViewItem(array &$item) { $item['backUrl'] = $this->finalUrl(); return parent::_prepareViewItem($item); } protected function _initDetailsPage(array $item) { Qs_Navigation::append(array('title' => $item['title'])); return parent::_initDetailsPage($item); } protected function _addImagesItem() { $item = [ 'containerId' => 'gallery-items', 'list' => $this->_getDataObj()->getAlbumItems(), ]; if (empty($item['list'])) { $this->_do404(); exit; } $this->_prepareImages($item['list']); $item['config'] = $this->getPhotoConfig()->toArray(); $item['tpl'] = $this->getTemplate('view-slider.tpl'); $this->_addItem($item, 'BOTTOM_ITEMS'); $this->_doc->addStyleSheet('css/thirdpart/royalslider.css'); $this->_doc->addStyleSheet('css/thirdpart/royalslider-default.css'); $this->_doc->addScript('js/royalslider/jquery.royalslider.js'); $this->_doc->addScript('js/royalslider/jquery.rs.visible-nearby.js'); $this->_doc->addScript('js/royalslider/jquery.rs.global-caption.js'); $this->_doc->addScript('js/royalslider/jquery.rs.active-class.js'); $this->_doc->addScript('js/royalslider/jquery.rs.hashchange.js'); $this->_doc->addScript('js/app/gallery.js'); $this->_doc->addInitObject('app.Gallery', [['containerId' => $item['containerId']]]); return $this; } protected function _prepareImages(array &$images) { $imageConfig = $this->getPhotoConfig('image'); foreach ($images as &$image) { $source = Qs_ImageFs::WEB_PATH . '/' . $image['image']; $destination = Qs_ImageFs::getIconName( $source, $imageConfig->width, $imageConfig->height, $imageConfig->method ); $destination = Qs_ImageFs::THUMBNAIL_PATH . '/' . $destination; if (!file_exists($destination)) { $destination = Qs_ImageFs::resize( $source, array( 'width' => $imageConfig->width, 'height' => $imageConfig->height, 'force' => false, 'method' => $imageConfig->method, 'sizeCheck' => true ) ); } $realWidth = $realHeight = 0; if ($destination) { $fileInfo = Qs_ImageFs::getInfo($destination); $realWidth = $fileInfo['width']; $realHeight = $fileInfo['height'];; } $image['realWidth'] = $realWidth; $image['realHeight'] = $realHeight; } return $this; } public function getPhotoConfig($field = null, $default = null) { if (null === $this->_photoConfig) { $this->_photoConfig = Qs_Config::get($this->_photoConfigName, Qs_Config::APP_TYPE); } if (null === $field) { return $this->_photoConfig; } return $this->_photoConfig->get($field, $default); } public function writeXmlSitemap(App_Sitemap_Xml_Writer $xml) { return $this->writeDefaultXmlSitemap($xml); } }