Exemple #1
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     $this->aPathRequestParams = array();
     $this->bIsNotFound = false;
     $this->initLanguage();
     // Find requested page
     $oRootPage = PagePeer::getRootPage();
     if ($oRootPage === null) {
         throw new Exception("No root node exists in the database. Use the admin tool to create one.");
     }
     $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $oMatchingNavigationItem = $this->oRootNavigationItem;
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $oParent = $oMatchingNavigationItem;
     while (!$oParent instanceof PageNavigationItem) {
         $oParent = $oParent->getParent();
     }
     if ($oParent !== $oMatchingNavigationItem) {
         $oParent->setCurrent(false);
     }
     self::$CURRENT_PAGE = $oParent->getMe();
     // See if the filter(s) changed anything
     FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oMatchingNavigationItem);
     // There may now be new, virtual navigation items. Follow them.
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     // See if anything has changed
     if (self::$CURRENT_NAVIGATION_ITEM !== $oMatchingNavigationItem && self::$CURRENT_NAVIGATION_ITEM instanceof PageNavigationItem) {
         self::$CURRENT_NAVIGATION_ITEM->setCurrent(false);
         //It is, however, still active
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $iTimesUsed = 0;
     while (self::hasNextPathItem()) {
         $sKey = self::usePath();
         $iTimesUsed++;
         $sValue = null;
         if (self::hasNextPathItem()) {
             $sValue = self::usePath();
             $iTimesUsed++;
         }
         $this->aPathRequestParams[] = $sKey;
         if (!isset($_REQUEST[$sKey]) && $sValue !== null) {
             $_REQUEST[$sKey] = $sValue;
         }
     }
     for ($i = 1; $i <= $iTimesUsed; $i++) {
         self::unusePath();
     }
     if ($oMatchingNavigationItem->isFolder()) {
         $oFirstChild = $oMatchingNavigationItem->getFirstChild(Session::language(), false, true);
         if ($oFirstChild !== null) {
             $aAdditionalPathItems = array();
             $aRequestParams = LinkUtil::getRequestedParameters();
             foreach (self::getRequestPath() as $iKey => $sPathItem) {
                 if ($iKey % 2 === 0 && isset($aRequestParams[$sPathItem])) {
                     unset($aRequestParams[$sPathItem]);
                 }
                 $aAdditionalPathItems[] = $sPathItem;
             }
             LinkUtil::redirectToManager(array_merge($oFirstChild->getLink(), $aAdditionalPathItems), null, $aRequestParams);
         } else {
             $this->bIsNotFound = true;
         }
     }
     if ($oMatchingNavigationItem->isProtected()) {
         if (!$oMatchingNavigationItem->isAccessible()) {
             $oLoginPage = self::$CURRENT_PAGE->getLoginPage();
             if ($oLoginPage !== self::$CURRENT_PAGE) {
                 Session::getSession()->setAttribute('login_referrer_page', self::$CURRENT_PAGE);
                 Session::getSession()->setAttribute('login_referrer', LinkUtil::link($oMatchingNavigationItem->getLink(), "FrontendManager"));
             }
             if ($oLoginPage === null) {
                 LinkUtil::redirect(LinkUtil::link('', "LoginManager"));
             }
             self::$CURRENT_PAGE = $oLoginPage;
         }
     }
     FilterModule::getFilters()->handlePageHasBeenSet(self::$CURRENT_PAGE, $this->bIsNotFound, self::$CURRENT_NAVIGATION_ITEM);
 }