private function PageByID($id) { if (!$id) { return null; } $page = Page::Schema()->ByID($id); if (!$page) { throw new \Exception(Trans('Core.Replacer.Error.PageNotFound.ID_{0}', $id)); } return $page; }
protected function Init() { $this->site = new Site(Request::GetData('site')); $selectedID = Request::GetData('selected'); $this->selected = $selectedID ? Page::Schema()->ByID($selectedID) : null; if (!$this->site->Exists()) { Response::Redirect(BackendRouter::ModuleUrl(new SiteList())); return true; } $this->tree = new PageTreeProvider($this->site); $this->page = $this->tree->TopMost(); $this->hasPages = (bool) $this->page; return parent::Init(); }
protected function Init() { $this->prefix = Request::GetData('prefix'); $this->page = Page::Schema()->ByID(Request::GetData('page')); if (!$this->page) { throw new \Exception('Required parameter page invalid or missing'); } $this->serializer = new ArrayLinesSerializer(); $this->oblParams = FrontendRouter::GatherParams($this->page->GetUrl()); $this->params = $this->serializer->LinesToArray(Request::GetData('params')); $this->AddObligatoryFields(); $this->AddOptionalParamsField(); $this->AddFragmentField(); $this->AddSubmit(); return parent::Init(); }
/** * Finds the 404 page for a site * @param Site $site The site whise 404 page is searched for * @return Page The 404 page */ static function Page404(Site $site) { $sql = Access::SqlBuilder(); $tblPage = Page::Schema()->Table(); $where = $sql->Equals($tblPage->Field('Type'), $sql->Value((string) PageType::NotFound()))->And_($sql->Equals($tblPage->Field('Site'), $sql->Value($site->GetID()))); return Page::Schema()->First($where); }
protected function OnSuccess() { $page = $this->Value('page'); if (!$page) { $this->UnsetPage(); $this->CloseModal(); } else { if ($this->pageOnly) { $objPage = Page::Schema()->ByID($page); $page = $this->SetJSFieldValue('#' . $this->prefix . 'Page', $page); $this->SetJSHtml('#' . $this->prefix . 'Name', $objPage->GetName()); $this->CloseModal(); return; } } $params = array(); $params['prefix'] = $this->prefix; $params['page'] = $this->Value('page'); $params['params'] = Request::GetData('params'); $params['fragment'] = Request::GetData('fragment'); $this->RedirectModal(BackendRouter::AjaxUrl(new AjaxPageParams(), $params)); }
/** * Reports a layout action with dependencies to the log * @param Layout $layout The layout being manipulated * @param Enums\Action $action The operation executed on the layout */ function ReportLayoutAction(Layout $layout, Enums\Action $action) { $logItem = $this->CreateLogItem(Enums\ObjectType::Layout(), $action); if (!$action->Equals(Enums\Action::Delete())) { $logLayout = new LogLayout(); $logLayout->SetLogItem($logItem); $logLayout->SetLayout($layout); $logLayout->Save(); } else { //pages are deleted in cascade $pages = Page::Schema()->FetchByLayout(false, $layout); foreach ($pages as $page) { $this->ReportPageAction($page, Enums\Action::Delete()); } } }
private function SiteCondition() { $sql = Access::SqlBuilder(); $tbl = Page::Schema()->Table(); return $sql->Equals($tbl->Field('Site'), $sql->Value($this->site->GetID())); }
/** * Returns the first child of the page * @param Page $item * @return Page Returns the first child */ public function FirstChildOf($item) { $sql = Access::SqlBuilder(); $tbl = Page::Schema()->Table(); if ($item) { $where = $sql->Equals($tbl->Field('Parent'), $sql->Value($item->GetID()))->And_($sql->IsNull($tbl->Field('Previous'))); return Page::Schema()->First($where); } else { return $this->TopMost(); } }
/** * Gets the selected page */ public function GetPage() { return $this->Value('Page') ? Page::Schema()->ByID($this->Value('Page')) : null; }
protected function TableSchema() { return Page::Schema(); }
/** * Saves the page url and returns it * @param PageUrl $pageUrl The page url * @return PageUrl Returns the page url with properties attached */ public function Save(PageUrl $pageUrl = null) { $exists = $pageUrl && $pageUrl->Exists(); $page = $this->Value('Page') ? Page::Schema()->ByID($this->Value('Page')) : null; if (!$page) { if ($exists) { $pageUrl->Delete(); } return null; } if (!$exists) { $pageUrl = new PageUrl(); } $pageUrl->SetPage($page); $pageUrl->SetFragment($this->Value('Fragment')); $pageUrl->Save(); $this->SaveParams($pageUrl); return $pageUrl; }