/** * Returns the top most area * @return Area */ public function TopMost() { $sql = Access::SqlBuilder(); $tblArea = Area::Schema()->Table(); $where = $sql->Equals($tblArea->Field('Layout'), $sql->Value($this->layout->GetID()))->And_($sql->IsNull($tblArea->Field('Previous'))); return Area::Schema()->First($where); }
/** * Initializes the areas and stores them in a list with area names as keys */ private function InitAreas() { $sql = Access::SqlBuilder(); $tbl = Area::Schema()->Table(); $where = $sql->Equals($tbl->Field('Layout'), $sql->Value($this->layout->GetID()))->And_($sql->IsNull($tbl->Field('Previous'))); $area = Area::Schema()->First($where); while ($area) { $this->areas[$area->GetName()] = $area; $area = Area::Schema()->ByPrevious($area); } }
protected function BeforeInit() { $this->layout = Layout::Schema()->ByID(Request::GetData('layout')); if (!$this->layout) { //TODO: Message Response::Redirect($this->BackLink()); } $this->file = PathUtil::LayoutTemplate($this->layout); if (!File::Exists($this->file)) { //TODO: Message Response::Redirect($this->BackLink()); } $this->contents = File::GetContents($this->file); return parent::BeforeInit(); }
private function SaveRights() { $groupID = $this->Value('UserGroup'); $userGroup = Usergroup::Schema()->ByID($groupID); $this->layout->SetUserGroup($userGroup); if (!$userGroup) { $oldRights = $this->layout->GetUserGroupRights(); if ($oldRights) { $oldRights->GetContentRights()->Delete(); } $this->layout->SetUserGroupRights(null); } else { $this->layout->SetUserGroup($userGroup); $this->layoutRights->Save(); $this->layout->SetUserGroupRights($this->layoutRights->Rights()); } $this->layout->Save(); }
/** * The edit form url * @param Area $area * @return string */ protected function EditUrl(Area $area) { $args = array('layout' => $this->layout->GetID()); $args['area'] = $area->GetID(); return BackendRouter::ModuleUrl(new AreaForm(), $args); }
protected function TemplateFormUrl(Layout $layout) { return BackendRouter::ModuleUrl(new LayoutTemplateForm(), array('layout' => $layout->GetID())); }
/** * Adds the layout field to the form */ private function AddLayoutField() { $name = 'Layout'; $select = new Select($name); if ($this->page->Exists()) { $select->SetValue($this->page->GetLayout()->GetID()); } $select->AddOption('', Trans('Core.PleaseSelect')); $sql = Access::SqlBuilder(); $tbl = Layout::Schema()->Table(); $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name'))); $layouts = Layout::Schema()->Fetch(false, null, $order); foreach ($layouts as $layout) { $select->AddOption($layout->GetID(), $layout->GetName()); } $this->AddField($select); $this->SetRequired($name); }
/** * Grant evaluation for adding content on top of a layout area * @param Layout $layout The layout * @return GrantResult Returns the grant result telling if creation is allowed */ function GrantAddContentToLayout(Layout $layout) { //dummy content for evaluation $content = new Content(); $content->SetUserGroup($layout->GetUserGroup()); $layoutRights = $layout->GetUserGroupRights(); if ($layoutRights) { $content->SetUserGroupRights($layoutRights->GetContentRights()); } return $this->Grant(BackendAction::Create(), $content); }
/** * The template file for a page layout * @param Layout $layout The page layout * @return string Returns the layout template path */ static function LayoutTemplate(Layout $layout) { $folder = Path::Combine(PHINE_PATH, 'LayoutTemplates'); $file = Path::Combine($folder, $layout->GetName()); return Path::AddExtension($file, 'phtml'); }
/** * The last log item that is directly related to the layout * @param Layout $layout The layout * @return LogItem Returns the log item */ static function LastLayoutLog(Layout $layout) { $tblLogLayout = LogLayout::Schema()->Table(); $tblLogItem = LogItem::Schema()->Table(); $sql = Access::SqlBuilder(); $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed'))); $joinCond = $sql->Equals($tblLogLayout->Field('LogItem'), $tblLogItem->Field('ID')); $where = $sql->Equals($tblLogLayout->Field('Layout'), $sql->Value($layout->GetID())); return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogLayout), JoinType::Inner(), $joinCond); }