Exemple #1
0
 /**
  * This function is used for isCurrent() and isSection() to prepare
  * the cached answers.
  */
 protected function prepareCurrentAndSection()
 {
     if (!self::$currentPageID) {
         self::$currentPageID = Director::currentPage() ? Director::currentPage()->ID : null;
         if (!isset(self::$currentPageID)) {
             self::$currentPageID = -1;
             $nextID = Director::currentPage() && isset(Director::currentPage()->Parent->ID) ? Director::currentPage()->Parent->ID : null;
         } else {
             $nextID = SiteTree::$currentPageID;
         }
         $table = Versioned::current_stage() == "Live" ? "SiteTree_Live" : "SiteTree";
         SiteTree::$currentSectionIDs = array();
         while ($nextID) {
             self::$currentSectionIDs[] = $nextID;
             $nextID = DB::query("SELECT ParentID FROM SiteTree WHERE ID = {$nextID}")->value();
         }
     }
 }
	/**
	 * This function is used for isCurrent() and isSection() to prepare
	 * the cached answers.
	 */
	protected function prepareCurrentAndSection() {
		if(!self::$currentPageID || Director::urlParam('URLSegment') != self::$currentPageIDSetFromURLSegment) {
			self::$currentPageID = Director::currentPage() ? Director::currentPage()->ID : null;
			self::$currentPageIDSetFromURLSegment = Director::urlParam('URLSegment');
			
			if(!isset(self::$currentPageID)) {
				self::$currentPageID = -1;
				$nextID = (Director::currentPage() && isset(Director::currentPage()->Parent->ID))
					? Director::currentPage()->Parent->ID
					: null;
			} else {
				$nextID = SiteTree::$currentPageID;
			}

			$table = (Versioned::current_stage() == "Live")
				? "SiteTree_Live"
				: "SiteTree";

			SiteTree::$currentSectionIDs = array();
			while($nextID) {
				self::$currentSectionIDs[] = $nextID;
				$nextID = DB::query("SELECT ParentID FROM SiteTree WHERE ID = $nextID")->value();
			}
		}
	}