/** * Gets the top most content of the layout area * @param Area $area The area * @return LayoutContent The first and root layout content */ function TopMost() { $sql = Access::SqlBuilder(); $tbl = LayoutContent::Schema()->Table(); $where = $sql->Equals($tbl->Field('Area'), $sql->Value($this->area->GetID()))->And_($sql->IsNull($tbl->Field('Parent')))->And_($sql->IsNull($tbl->Field('Previous'))); return LayoutContent::Schema()->First($where); }
/** * The edit/create url base parameters */ protected function EditParams() { $params = array(); $params['page'] = $this->page->GetID(); $params['area'] = $this->area->GetID(); return $params; }
/** * 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); } }
/** * 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); }
/** * Gets the content tree url * @param Area $area * @return string Returns the page content tree url */ protected function AreaUrl(Area $area) { $params = array(); $params['page'] = $this->page->GetID(); $params['area'] = $area->GetID(); return BackendRouter::ModuleUrl(new PageContentTree(), $params); }
/** * The link to the area contents * @param Area $area The area * @return string Returns the url of the area content tree */ protected function AreaUrl(Area $area) { return BackendRouter::ModuleUrl(new LayoutContentTree(), array('area' => $area->GetID())); }
private function GrantOnArea(Area $area, BackendAction $action) { $layout = $area->GetLayout(); if ($area->GetLocked() && !$this->GetUser()->Equals($layout->GetUser())) { return GrantResult::NoAccess(); } return GrantResult::Allowed(); }
private function SaveAreas() { $names = explode(',', $this->Value('Areas')); $prev = null; foreach ($names as $name) { $name = String::Trim($name); if (!$this->AreaNameExists($name)) { $area = new Area(); $area->SetPrevious($prev); $area->SetLayout($this->layout); $area->SetName($name); $area->Save(); $prev = $area; } } }
protected function CreateFormUrl() { $args = array('page' => $this->page->GetID(), 'area' => $this->area->GetID()); return BackendRouter::ModuleUrl(new ModuleForm(), $args); }
/** * The last log item that is directly related to the area * @param Area $area The area * @return LogItem Returns the log item */ static function LastAreaLog(Area $area) { $tblLogArea = LogArea::Schema()->Table(); $tblLogItem = LogItem::Schema()->Table(); $sql = Access::SqlBuilder(); $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed'))); $joinCond = $sql->Equals($tblLogArea->Field('LogItem'), $tblLogItem->Field('ID')); $where = $sql->Equals($tblLogArea->Field('Area'), $sql->Value($area->GetID())); return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogArea), JoinType::Inner(), $joinCond); }
protected function TableSchema() { return Area::Schema(); }