'list'); protected $_categoryType = null; public function exec() { $alias = $this->getRestAlias(); if (!empty($alias)) { if ($this->getConfig('type') != 'detail') { $this->_getDataObj()->setCategoryIdByAlias($alias); if (!$this->_getDataObj()->getCategoryId()) { $this->_do404(); } } } return parent::exec(); } public function _log() { if ($this->_hasLog) { $options = $this->_getDataObj()->getObjectInfo(); if ('' != $this->getRestAlias()) { $this->_getLog()->write('view', $options); } else { $this->_getLog()->write($this->_action, $options); } } return $this; } protected function _doList() { $dataObj = $this->_getDataObj(); if ($industryTypeId = (int) $this->getConfig('industryType')) { $dataObj->addFilter(array('industryType' => $industryTypeId)); } if (($categoryId = $dataObj->getCategoryId())) { $this->_appendNavigation($dataObj->getCategoryTree($categoryId)); $dataObj->setPrimaryKey($categoryId); $data = $dataObj->getData(); FormMetaTrait::updateMetaKeywords($data); FormMetaTrait::updateMetaDescription($data); } static::saveCategoryId($dataObj->getCategoryId()); if ('y' !== $this->getConfig('hideTree') && !$this->_categoryType) { $this->_addMenu(); } return parent::_doList(); } protected function _appendNavigation($branch) { $crumb = array('title' => $branch['title'], 'url' => $branch['url']); Qs_Navigation::append($crumb); if (!empty($branch['sub'])) { $this->_appendNavigation(reset($branch['sub'])); } return $this; } protected function _addListItem($list = null) { $dataObj = $this->_getDataObj(); $item = array(); $item['tpl'] = $this->getTemplate('list.tpl'); $item['config'] = $this->getConfig()->toArray(); if ($this->getConfig('industryType') || $this->_categoryType) { $categories = $dataObj->getCategoryListForIndustryType(); } else { $categoryId = $dataObj->getCategoryId(); if ($categoryId) { $node = $dataObj->getNode($dataObj->getCategoryTree(), $categoryId); $node['title'] = htmlspecialchars($node['title']); $this->_doc->setHeader($node['title']); FormMetaTrait::updateMetaTitle($node, 'title'); $categories = (!empty($node['sub'])) ? $node['sub'] : array(); } else { $categories = $dataObj->getCategoryTree(); } } $item['list'] = $categories; $item['layoutStandard'] = App_ECommerce_Product_Category_Abstract_Obj::PRODUCT_STANDARD_TYPE_ID; $item['layoutCustom'] = App_ECommerce_Product_Category_Abstract_Obj::PRODUCT_CUSTOM_TYPE_ID; $item['typeId'] = $dataObj->getData('typeId'); $item['disclaimerContent'] = str_replace( '{currentYear}', date('Y'), App_Settings_Obj::get('productCategoryDisclaimer') ); $this->_addItem($item); return $this; } protected function _addMenu() { $categoryTree = $this->getMenu(); $productsAlias = Qs_SiteMap::getAliasByItem('ECommerce_Product_'); $item = array( 'list' => $categoryTree, 'link' => array('product' => $productsAlias), 'finalUrl' => BASE_URL_LANGUAGE . '/' . $productsAlias, 'currentCategoryId' => $this->_getDataObj()->getCategoryId() ? $this->_getDataObj()->getCategoryId() : static::getCategoryId(), 'categoryTypeId' => $this->_getDataObj()->getCategoryId() ? $this->_getDataObj()->getData('typeId') : 0, 'tpl' => $this->getTemplate('tree-list.tpl'), 'layoutCustom' => App_ECommerce_Product_Category_Abstract_Obj::PRODUCT_CUSTOM_TYPE_ID, 'layoutStandard' => App_ECommerce_Product_Category_Abstract_Obj::PRODUCT_STANDARD_TYPE_ID, ); $this->_addItem($item, 'LEFT_ITEMS'); $this->_doc->addScript('js/hoverIntent.js'); $this->_doc->addScript('js/superfish.js'); $this->_doc->addScript('js/app/ECommerce/product/menu.js'); $this->_doc->addStylesheet('css/thirdpart/superfish/superfish.css'); $this->_doc->addStylesheet('css/thirdpart/superfish/superfish-vertical.css'); return $this; } public function getMenu() { $menu = $this->_getDataObj()->getCategoryTree(); $this->_prepareMenu($menu); return $menu; } protected function _prepareMenu(array &$menu) { if (!empty($menu)) { foreach ($menu as &$subMenu) { $subMenu['items'] = array('type' => substr(get_class($this), 0, -4)); $subMenu['menuTitle'] = htmlspecialchars($subMenu['menuTitle']); if ($subMenu['productsCount'] == 0 && count($subMenu['sub'])) { $subMenu['url'] = null; } $this->_prepareMenu($subMenu['sub']); } } return $this; } public static function getSession() { return new Qs_Session_Namespace('ECommerce_Product_Category'); } public static function saveCategoryId($categoryId, $name = '') { static::getSession()->CategoryId = $categoryId; if (!empty($name)) { static::getSession()->{$name . 'CategoryId'} = $categoryId; } } public static function getCategoryId($name = '') { return static::getSession()->{$name . 'CategoryId'}; } }