/** * Gets the last page modification log item * @param Page $page The page * @param Interfaces\IContainerReferenceResolver $resolver * @return LogItem Returns the last log item that changed anything related to the page */ static function LastPageModLog(Page $page, Interfaces\IContainerReferenceResolver $resolver) { $lastLog = self::LastPageLog($page); $pageContents = PageContent::Schema()->FetchByPage(false, $page); foreach ($pageContents as $pageContent) { $content = $pageContent->GetContent(); $contentLog = self::LastContentModLog($content, $resolver); if (self::IsAfter($contentLog, $lastLog)) { $lastLog = $contentLog; } } $layoutLog = self::LastLayoutLog($page->GetLayout()); if (self::IsAfter($layoutLog, $lastLog)) { $lastLog = $layoutLog; } return $lastLog; }
protected function Init() { $this->page = new Page(Request::GetData('page')); $selectedID = Request::GetData('selected'); $this->selected = $selectedID ? PageContent::Schema()->ByID($selectedID) : null; if (!$this->page->Exists()) { Response::Redirect(BackendRouter::ModuleUrl(new SiteList())); return true; } $this->area = new Area(Request::GetData('area')); if (!$this->area->Exists()) { $params = array('site' => $this->page->GetSite()->GetID()); Response::Redirect(BackendRouter::ModuleUrl(new PageTree(), $params)); return true; } $this->tree = new PageContentTreeProvider($this->page, $this->area); $this->pageContent = $this->tree->TopMost(); $this->hasContents = (bool) $this->pageContent; return parent::Init(); }
/** * Initializes a new page content branch * @param PageContent $pageContent The page content */ function __construct(PageContent $pageContent) { $this->page = $pageContent->GetPage(); $this->area = $pageContent->GetArea(); parent::__construct($pageContent); }
protected function TableSchema() { return PageContent::Schema(); }
private function AttachPageContent($isNew) { $provider = new PageContentTreeProvider($this->Page(), $this->Area()); $tree = new TreeBuilder($provider); $pageContent = $this->Content()->GetPageContent(); if (!$pageContent) { $pageContent = new PageContent(); $pageContent->SetArea($this->Area()); $pageContent->SetPage($this->Page()); $provider->AttachContent($pageContent, $this->Content()); } if ($isNew) { $tree->Insert($pageContent, $this->ParentItem(), $this->PreviousItem()); } }
/** * Gets content by item * @param PageContent $item * @return Content */ public function ContentByItem($item) { return $item ? $item->GetContent() : null; }