_getDataObj()->setFilter($this->_doc->getOption('xFilter')); return parent::exec(); } protected function _getListItem() { $item = parent::_getListItem(); if (count($item['list']) == 1) { $item['backUrl'] = $this->getRootPage('url'); } $this->prepareCategories($item['list']); $item['companyDetailPageUrl'] = DetailPage\View::getPage('url') . '/{id}'; return $item; } protected function _postList() { $this->_doc->addScript('js/tooltipster.bundle.js'); $this->_doc->addStylesheet('css/thirdpart/tooltipster.bundle.css'); $this->_doc->addInitFunction("$('.city').tooltipster", [[ 'trigger' => 'click', 'interactive' => true, ]]); return parent::_postList(); } private function prepareCategories(array &$categories) { foreach ($categories as &$category) { $page = $this->getCategoryPage($category['id']); $category['title'] = $page['title']; $category['url'] = $page['url']; } return $this; } private function getCategoryPage($id, $field = null) { foreach (self::getPages() as $page) { if (empty($page['xFilter']) || empty($page['xFilter']['utilityCategoryId']) || !is_scalar($page['xFilter']['utilityCategoryId']) ) { continue; } if ($page['xFilter']['utilityCategoryId'] == $id) { return Qs_Array::get($page, $field); } } return false; } private static function getPages() { static $pages; if (null === $pages) { $pages = Qs_SiteMap::find(null, ['type' => 'MunicipalUtilities\\']); } return $pages; } public static function getRootPage($field = null) { foreach (self::getPages() as $page) { if (!empty($page['xFilter']) && is_array($page['xFilter']['utilityCategoryId'])) { return Qs_Array::get($page, $field); } } return false; } }