/** * 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); } }
/** * Saves the layout */ protected function OnSuccess() { $action = Action::Update(); $isNew = !$this->layout->Exists(); if ($isNew) { $action = Action::Create(); $this->layout->SetUser(self::Guard()->GetUser()); } $oldFile = $isNew ? '' : PathUtil::LayoutTemplate($this->layout); $this->layout->SetName($this->Value('Name')); $this->layout->Save(); $logger = new Logger(self::Guard()->GetUser()); $logger->ReportLayoutAction($this->layout, $action); if ($this->CanAssignGroup()) { $this->SaveRights(); } if ($isNew) { $this->SaveAreas(); } $this->UpdateFiles($oldFile); $args = array('layout' => $this->layout->GetID()); Response::Redirect(BackendRouter::ModuleUrl(new AreaList(), $args)); }
/** * 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())); }
/** * 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); }