protected function __construct($controller) { parent::__construct($controller); if (Router::getDefaultModule() == 'Page') { if (Page_Handler::getPageID()) { $this->show->merge(Page_Handler::getPage(), true); $this->show->breadcrumbs = Page_Handler::getPage()->getParents(); } $oPage = new Page(); list($full, $current) = $oPage->getMenuList(); if (is_array($full) && count($full)) { foreach ($full as $menu) { if (isset($menu["Children0"])) { $this->show->{'MENU_' . $menu["StaticPath"]} = $menu["Children0"]; } } } } // i.kiz для интернет магазина // $trash = NULL; // $this->show->basketList = NULL; if ($this->show->itemID) { $this->show->staticPath = $this->show->itemID; } else { if (!empty($this->data[0])) { $this->show->staticPath = $this->data[0]; } else { $this->show->staticPath = 0; } } $this->oCatalogCategory = new Catalog_Category(); $this->oCatalogBrand = new Catalog_Brand(); $this->show->catalogBrand = $this->oCatalogBrand->getList(); // menu $i = 0; $this->show->catalogMenu = array(); foreach ($this->show->catalogBrand as $br) { $this->show->catalogMenu['Brand'][$i] = $br['Title']; $cats = $this->oCatalogCategory->getList($br['BrandID']); $j = 0; foreach ($cats as $cat) { $this->show->catalogMenu['Category'][$i][$j] = $cat['Title']; $this->show->catalogMenu['CategoryID'][$i][$j] = $cat['CategoryID']; $j++; } $i++; } // корзина $this->session = MySession::getInstance(); $trash = $this->session->get('trash'); if (isset($trash)) { $this->show->trash = $trash; } else { $this->show->trash = array(); } }
/** * Производит анализ и выполнение действий, переданных в URI */ public function run() { if (Router::isAdmin() && !Auth::getInstance()->hasAccess(1)) { throw new Exception(lang('access_denied', __CLASS__)); } MySQL::setOnPage(Config::get('OnPage')); $this->route = Router::getPath(); if (count($this->route) == 0) { $this->index = true; } $this->folder = Router::isAdmin() ? '/admin/' : '/public/'; if (!Router::isAdmin() && Router::getDefaultModule() == 'Page') { Page_Handler::findPage($this); } foreach ($this->route as $key => $path) { $path = ucfirst(mb_strtolower($path)); if (is_dir(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $path) && $path != '') { $this->pathToController .= $path . '/'; } if (is_file(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $path . '.php')) { $this->controller = $path; $this->pathToView .= $path . '/'; unset($this->route[$key]); } if (is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . '_footer.phtml') && is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . '_header.phtml')) { $this->pathToTemplate = $this->pathToView; } if (is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . mb_strtolower($path) . '.phtml')) { $this->action = mb_strtolower($path); unset($this->route[$key]); } } if ($this->controller == '') { $this->controller = Router::isAdmin() ? 'Page' : Router::getDefaultModule(); $this->pathToView = $this->controller . '/'; } if ($this->action == '') { if ($this->controller == 'Page' && !$this->index && !Router::isAdmin() && Page_Handler::getPageID() == 0) { $this->action = 'page404'; } else { $this->action = 'index'; } } $this->route = array_values($this->route); if (!is_file(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $this->controller . '.php')) { throw new Exception(lang('error_controller_not_found', __CLASS__)); } include CORE_ROOT . 'class/Controller/AbstractController.php'; if (Router::isAdmin()) { include CORE_ROOT . 'class/Controller/AdminController.php'; } else { include CORE_ROOT . 'class/Controller/PublicController.php'; } include CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $this->controller . '.php'; $this->controller .= 'Controller'; $oController = new $this->controller($this); $oController->{$this->action}(); if (!is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . $this->action . '.phtml')) { throw new Exception(lang('error_view_not_found', __CLASS__) . ':<br />' . 'view' . $this->folder . $this->pathToView . $this->action . '.phtml'); } $oTemplate = new Template($this); $oTemplate->load($oController); $oTemplate->show(); }