protected function Init()
 {
     $this->area = new Area(Request::GetData('area'));
     $selectedID = Request::GetData('selected');
     $this->selected = $selectedID ? LayoutContent::Schema()->ByID($selectedID) : null;
     if (!$this->area->Exists()) {
         Response::Redirect(BackendRouter::ModuleUrl(new LayoutList()));
         return true;
     }
     $this->tree = new LayoutContentTreeProvider($this->area);
     $this->layoutContent = $this->tree->TopMost();
     $this->hasContents = (bool) $this->layoutContent;
     return parent::Init();
 }
Example #2
0
 private function AttachLayoutContent($isNew)
 {
     $provider = new LayoutContentTreeProvider($this->Area());
     $tree = new TreeBuilder($provider);
     $layoutContent = $this->Content()->GetLayoutContent();
     if (!$layoutContent) {
         $layoutContent = new LayoutContent();
         $layoutContent->SetArea($this->Area());
         $layoutContent->SetContent($this->Content());
     }
     $provider->AttachContent($layoutContent, $this->Content());
     if ($isNew) {
         $tree->Insert($layoutContent, $this->ParentItem(), $this->PreviousItem());
     }
 }
 /**
  * Initializes a new layout content branch
  * @param LayoutContent $layoutContent The page content 
  */
 function __construct(LayoutContent $layoutContent)
 {
     $this->area = $layoutContent->GetArea();
     parent::__construct($layoutContent);
 }
 /**
  * Attaches item and content
  * @param LayoutContent $item
  * @param Content $content
  */
 public function AttachContent($item, Content $content)
 {
     $item->SetContent($content);
     $item->Save();
     $content->SetLayoutContent($item);
     $content->Save();
 }
 protected function TableSchema()
 {
     return LayoutContent::Schema();
 }
Example #6
0
 /**
  * Gets the last area modification log item
  * @param Area $area The area
  * @return LogItem Returns the last log item that changed anything related to the area
  */
 static function LastAreaModLog(Area $area, Interfaces\IContainerReferenceResolver $resolver)
 {
     $lastLog = $this->LastAreaLog($area);
     $areaContents = LayoutContent::Schema()->FetchByArea(false, $area);
     foreach ($areaContents as $areaContent) {
         $content = $areaContent->GetContent();
         $contentLog = self::LastContentModLog($content, $resolver);
         if (self::IsAfter($contentLog, $lastLog)) {
             $lastLog = $contentLog;
         }
     }
     return $lastLog;
 }