コード例 #1
0
ファイル: PageView.php プロジェクト: ramziammar/websites
 private function recordPageID()
 {
     $currentPage = Director::currentPage();
     if ($currentPage) {
         $this->PageID = $currentPage->ID;
     }
 }
コード例 #2
0
	function getBlogHolder() {
		$page = Director::currentPage();
		
		if($page->is_a("BlogHolder")) {
			return $page;
		} else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
			return $page->getParent();
		} else {
			return DataObject::get_one("BlogHolder");
		}
	}
コード例 #3
0
	function getBlogHolder() {
		$page = Director::currentPage();
		
		if($page instanceof BlogHolder) {
			return $page;
		} elseif(($page instanceof BlogEntry) && ($page->getParent() instanceof BlogHolder)) {
			return $page->getParent();
		} else {
			return DataObject::get_one('BlogHolder');
		}
	}
 static function addPage()
 {
     $historyString = Session::get("LastPagesVisited");
     $historyArray = unserialize($historyString);
     if (!is_array($historyArray)) {
         $historyArray = array();
     }
     $page = Director::currentPage();
     if ($page) {
         $pageID = $page->ID;
         if ($pageID) {
             if (!in_array($pageID, $historyArray)) {
                 array_unshift($historyArray, $pageID);
                 if (count($historyArray) > self::$number_of_pages_back) {
                     array_pop($historyArray);
                 }
             } elseif ($historyArray[count($historyArray) - 1] == $pageID) {
                 array_pop($historyArray);
                 array_unshift($historyArray, $pageID);
             }
         }
     }
     Session::set("LastPagesVisited", serialize($historyArray));
 }
コード例 #5
0
ファイル: SiteTree.php プロジェクト: ramziammar/websites
 /**
  * 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();
         }
     }
 }
コード例 #6
0
ファイル: SiteTree.php プロジェクト: neopba/silverstripe-book
	/**
	 * 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();
			}
		}
	}