/**
  * 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);
 }
Example #2
0
 /**
  * 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);
     }
 }
Example #3
0
 /**
  * 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));
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 protected function TemplateFormUrl(Layout $layout)
 {
     return BackendRouter::ModuleUrl(new LayoutTemplateForm(), array('layout' => $layout->GetID()));
 }
Example #6
0
 /**
  * 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);
 }