public static function findPage(Controller $oController) { if (self::$currentPageID > 0) { return; } if ($oController->indexPage()) { $oPage = new Page(); if ($oPage->loadIndexPage()) { if (Controller::getInstance()->controllerExists($oPage["Link"])) { $oController->route[self::$level] = $oPage["Link"]; } self::$level = 1; self::$page = $oPage; self::$currentPageID = $oPage->PageID; } } else { $db = MySQL::getInstance(); $db->query("SELECT PageID, StaticPath, Level, LeftKey, RightKey, Link\n\t\t\t\tFROM `page` WHERE\n\t\t\t\t\tWebsiteID = " . $db->escape(WEBSITE_ID) . "\n\t\t\t\t\tAND StaticPath IN (" . implode(", ", $db->escape($oController->route)) . ")\n\t\t\t\t\tAND LanguageCode = " . $db->escape(LANG) . "\n\t\t\t\t\tAND Level > 1\n\t\t\t\tORDER BY LeftKey"); self::$level = 0; $moduleFound = false; $currentPageID = null; while ($row = $db->fetchRow()) { if ($row["StaticPath"] == $oController->route[0] && $row["Level"] == 2) { $currentPageID = $row["PageID"]; self::$currentLeftKey = $row["LeftKey"]; self::$currentRightKey = $row["RightKey"]; if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) { $oController->route[0] = $row["Link"]; break; } self::$level++; continue; } if (!is_null($currentPageID) && count($oController->route) > self::$level) { if ($row["StaticPath"] == $oController->route[self::$level] && $row["LeftKey"] > self::$currentLeftKey && $row["RightKey"] < self::$currentRightKey) { $currentPageID = $row["PageID"]; self::$currentLeftKey = $row["LeftKey"]; self::$currentRightKey = $row["RightKey"]; if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) { $oController->route[self::$level] = $row["Link"]; break; } self::$level++; } } } if (self::$level == count($oController->route) || $moduleFound != false) { $oPage = new Page(); if ($oPage->loadByID($currentPageID)) { self::$page = $oPage; self::$currentPageID = $oPage->PageID; } } } for ($i = 0; $i < self::$level; $i++) { array_shift($oController->route); } }