Exemple #1
0
 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();
     }
 }
Exemple #2
0
 public function loadByStaticPath($staticPath = NULL)
 {
     $db = MySQL::getInstance();
     $db->query("SELECT *\n\t\t\tFROM gallery\n\t\t\tWHERE PageID = " . $db->escape(Page_Handler::getPageID()) . "\n\t\t\t\tAND StaticPath = " . $db->escape($staticPath));
     if ($db->numRows() > 0) {
         $item = $db->fetchRow();
         $oImageList = new Gallery_Image();
         $item['ImageList'] = $oImageList->getListForPublic((int) $item['GalleryID']);
         $this->get($item);
         return true;
     }
     return false;
 }
Exemple #3
0
 public function __construct($data)
 {
     parent::__construct($data);
     $this->show->Title = 'Каталог';
     $oPage = Page_Handler::getPage();
     $oPage->StaticPath = 'catalog/category/' . $this->show->itemID;
     $this->show->path2Category = $oPage->getPathToRoot() . $oPage->StaticPath;
     $this->show->isCatalog = true;
     $this->show->catalogIndex = false;
     $this->show->catalogCategory = $this->oCatalogCategory->getList(-1);
     $this->show->filterID = 0;
     $metas = $this->oCatalogCategory->getById($this->show->itemID);
     if ($metas['MetaKeywords']) {
         $this->show->MetaKeywords = $metas['MetaKeywords'];
     }
     if ($metas['MetaTitle']) {
         $this->show->MetaTitle = $metas['MetaTitle'];
     }
     if ($metas['MetaDescription']) {
         $this->show->MetaDescription = $metas['MetaDescription'];
     }
 }
Exemple #4
0
 /**
  * Производит анализ и выполнение действий, переданных в 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();
 }
Exemple #5
0
 public static function setPageID($pageID)
 {
     self::$currentPageID = $pageID;
 }
Exemple #6
0
 public function loadByStaticPath($staticPath = NULL)
 {
     $db = MySQL::getInstance();
     $db->query("SELECT n.*, IF (c.Count, c.Count, 0) AS CommentCount\n\t\t\tFROM newsletter AS n\n\t\t\t\tLEFT JOIN newsletter_comment_count AS c ON c.NewsletterID = n.NewsletterID\n\t\t\tWHERE n.PageID = " . $db->escape(Page_Handler::getPageID()) . "\n\t\t\t\tAND n.StaticPath = " . $db->escape($staticPath));
     if ($db->numRows() > 0) {
         $item = $db->fetchRow();
         $oCommentList = new Newsletter_Comment();
         $item['CommentList'] = $oCommentList->getList((int) $item['NewsletterID']);
         $oImageList = new Newsletter_Image();
         $item['ImageList'] = $oImageList->getList((int) $item['NewsletterID']);
         $this->get($item);
         return true;
     }
     return false;
 }
Exemple #7
0
 private function getPageTree()
 {
     $db = MySQL::getInstance();
     $oPage = Page_Handler::getPage();
     $parentIDs = array();
     if (!empty($oPage->PageID)) {
         $db->query("SELECT `PageID` FROM `page` WHERE `LeftKey` <= {$oPage->LeftKey} AND `RightKey` >= {$oPage->RightKey} AND `Level` > 1 ORDER BY `LeftKey`");
         while ($pageID = $db->fetchField()) {
             $parentIDs[] = (int) $pageID;
         }
     }
     $db->query("SELECT SUBSTRING(UCASE(Title), 1, 1) AS FirstChar, Level,\n\t\t\t\tPageID, Title, Description, MetaTitle, ParentID, StaticPath, Type, Link,\n\t\t\t\t" . (count($parentIDs) ? "IF (PageID IN (" . implode(",", $parentIDs) . ") OR REPLACE(Link, '<P_T_R>', '" . BASE_PATH . "')=" . $db->escape($_SERVER['REQUEST_URI']) . ", 1, 0) AS Opened " : " 0 AS Opened") . ",\n\t\t\t\t" . (!empty($oPage->PageID) ? "IF (PageID=" . $db->escape((int) $oPage->PageID) . ", 1, 0) AS Current" : "0 AS Current") . ",\n\t\t\t\tIF (Modified IS NULL, Created, Modified) AS LastModified\n\t\t\tFROM `page`\n\t\t\tWHERE `WebsiteID` = " . $db->escape((int) WEBSITE_ID) . "\n\t\t\t\tAND `LanguageCode` = " . $db->escape(LANG) . "\n\t\t\t\tAND `Active` = 1\n\t\t\tORDER BY LeftKey");
     $items = array();
     while ($row = $db->fetchRow()) {
         $row['ParentID'] = (int) $row['ParentID'];
         $items[] = $row;
     }
     $result[0]["ParentID"] = 0;
     $result[0]["Children"] = array();
     $result[0]["PageURL"] = substr(BASE_PATH, 0, strlen(BASE_PATH) - 1);
     $result[0]["Type"] = 0;
     $result[0]["Link"] = null;
     $result[0]["StaticPath"] = 'index';
     $bParentID = 0;
     $cPageID = "";
     $cNumber = 0;
     for ($i = 0; $i < count($items); $i++) {
         if (!isset($result[$items[$i]["ParentID"]])) {
             continue;
         }
         // Exclude top level nodes from path
         if ($items[$i]["ParentID"] > 0) {
             $items[$i]["PageURL"] = $result[$items[$i]["ParentID"]]["PageURL"] . "/" . $items[$i]["StaticPath"];
         } else {
             $items[$i]["PageURL"] = $result[$items[$i]["ParentID"]]["PageURL"];
         }
         // Form all possible menus
         $result[$items[$i]["ParentID"]]["Children"][] = $items[$i];
         $result[$items[$i]["PageID"]] =& $result[$items[$i]["ParentID"]]["Children"][count($result[$items[$i]["ParentID"]]["Children"]) - 1];
         if ($items[$i]["Current"]) {
             $bParentID = $items[$i]["ParentID"];
             $cPageID = $items[$i]["PageID"];
         }
         if ($cPageID == $items[$i]["ParentID"]) {
             $cNumber++;
         }
     }
     // Define URLs for pages
     foreach ($result as $id => $node) {
         if ($node["Type"] == 1 || $node["Type"] == 2) {
             if ($node["StaticPath"] == 'index') {
                 // Index page
                 $result[$id]["PageURL"] = BASE_PATH;
             } else {
                 if ($node["Level"] == 1) {
                     // Top level nodes has no URL
                     $result[$id]["PageURL"] = "#";
                 }
             }
         } else {
             // Link
             $result[$id]["PageURL"] = str_replace("<P_T_R>", BASE_PATH, $node["Link"]);
             // Email link
             if (substr($node["Link"], 0, 7) == "mailto:") {
                 $mailTo = "";
                 for ($i = 0; $i < strlen($node["Link"]); $i++) {
                     $mailTo .= "%" . dechex(ord(substr($node["Link"], $i, 1)));
                 }
                 $result[$id]["MailTo"] = $mailTo;
             }
         }
     }
     // Prepare current menu
     $currMenu = array();
     foreach ($result as $id => $node) {
         if ($cNumber > 0) {
             if (isset($node["Current"]) && $node["Current"]) {
                 // Get current page as first element & its children
                 $currMenu[0] = $result[$id];
                 unset($currMenu[0]["Children"]);
                 if (isset($result[$id]["Children"])) {
                     for ($j = 0; $j < count($result[$id]["Children"]); $j++) {
                         $currMenu[] = $result[$id]["Children"][$j];
                     }
                 }
             }
         } else {
             if ($result[$id]["ParentID"] > 0) {
                 // Get brothers of the current page & its parent as first element
                 if ($result[$id]["Level"] > 1 && $bParentID == $result[$id]["PageID"]) {
                     $currMenu[0] = $result[$id];
                     unset($currMenu[0]["Children"]);
                 }
                 if ($bParentID == $result[$id]["ParentID"]) {
                     $currMenu[] = $result[$id];
                 }
             }
         }
     }
     return array($result[0]["Children"], $currMenu);
 }