/**
  * Returns the root and first content element in a page and area
  * @return PageContent Returns the first and root content
  */
 function TopMost()
 {
     $sql = Access::SqlBuilder();
     $tbl = PageContent::Schema()->Table();
     $where = $sql->Equals($tbl->Field('Page'), $sql->Value($this->page->GetID()))->And_($sql->Equals($tbl->Field('Area'), $sql->Value($this->area->GetID())))->And_($sql->IsNull($tbl->Field('Parent')))->And_($sql->IsNull($tbl->Field('Previous')));
     return PageContent::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;
 }
 function __construct(Page $page, Page $selected = null, $disabled = false)
 {
     $this->page = $page;
     $this->selected = $selected;
     $this->checked = $this->page->Equals($selected);
     $this->tree = new PageTreeProvider($this->page->GetSite());
     $this->child = $this->tree->FirstChildOf($this->page);
     $this->disabled = $disabled;
 }
Example #4
0
 /**
  * Gets the page's user group
  * @param Page $page
  * @return Usergroup
  */
 static function FindPageGroup(Page $page)
 {
     $currPage = $page;
     $result = null;
     do {
         $result = $currPage->GetUserGroup();
         $currPage = $currPage->GetParent();
     } while (!$result && $currPage);
     if (!$result && $page->GetSite()) {
         return $page->GetSite()->GetUserGroup();
     }
     return $result;
 }
Example #5
0
 /**
  * Gets the rights of the page
  * @param Page $page
  * @return BackendPageRights
  */
 static function FindPageRights(Page $page)
 {
     $currPage = $page;
     $result = null;
     do {
         $result = $currPage->GetUserGroupRights();
         $currPage = $currPage->GetParent();
     } while (!$result && $currPage);
     if (!$result && $page->GetSite()) {
         $siteRights = $page->GetSite()->GetUserGroupRights();
         if ($siteRights) {
             return $siteRights->GetPageRights();
         }
     }
     return $result;
 }
Example #6
0
 /**
  * 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);
 }
Example #7
0
 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();
 }
 /**
  * Gets the page's member groups
  * @param Page $page
  * @return Membergroup[] Returns the member groups assigned to the page
  */
 static function PageMembergroups(Page $page)
 {
     if (!$page->Exists()) {
         return array();
     }
     $sql = Access::SqlBuilder();
     $tblPmg = PageMembergroup::Schema()->Table();
     $tblMg = Membergroup::Schema()->Table();
     $join = $sql->Join($tblPmg);
     $joinCondition = $sql->Equals($tblPmg->Field('MemberGroup'), $tblMg->Field('ID'));
     $where = $sql->Equals($tblPmg->Field('Page'), $sql->Value($page->GetID()));
     $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name')));
     return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition);
 }
Example #9
0
 /**
  * The link for the back button
  * @return string Returns the url to the page tree
  */
 protected function BackLink()
 {
     $params = array('site' => $this->site->GetID());
     if ($this->page->Exists()) {
         $params['selected'] = $this->page->GetID();
     } else {
         if ($this->previous) {
             $params['selected'] = $this->previous->GetID();
         } else {
             if ($this->parent) {
                 $params['selected'] = $this->parent->GetID();
             }
         }
     }
     return BackendRouter::ModuleUrl(new PageTree(), $params);
 }
Example #10
0
 /**
  * Saves the page selection
  */
 protected function OnSuccess()
 {
     $allParams = array();
     foreach ($this->oblParams as $param) {
         $allParams[$param] = $this->Value($param);
     }
     $optParams = $this->serializer->LinesToArray($this->Value('OptionalParameters'));
     foreach ($optParams as $name => $value) {
         if (!isset($allParams[$name])) {
             $allParams[$name] = $value;
         }
     }
     $this->SetJSFieldValue('#' . $this->prefix . 'Params', $this->serializer->ArrayToLines($allParams));
     $this->SetJSFieldValue('#' . $this->prefix . 'Page', $this->page->GetID());
     $this->SetJSFieldValue('#' . $this->prefix . 'Fragment', $this->Value('Fragment'));
     $this->SetJSHtml('#' . $this->prefix . 'Url', FrontendRouter::PageUrl($this->page, $allParams, $this->Value('Fragment')));
     $this->CloseModal();
 }
Example #11
0
 /**
  * Renders the complete page by requiring the page layout
  * @return string Returns the page contents
  */
 function Render()
 {
     self::$currentPage = $this->page;
     self::$Title = self::$currentPage->GetTitle();
     self::$Description = self::$currentPage->GetDescription();
     self::$Keywords = self::$currentPage->GetKeywords();
     if ($this->page->GetType() == (string) PageType::NotFound()) {
         header('HTTP/1.0 404 Not Found');
     } else {
         if ($this->page->GetType() !== (string) PageType::Normal()) {
             throw new \Exception('Internal phine error: not normal page called');
         }
     }
     ob_start();
     require PathUtil::LayoutTemplate($this->layout);
     $result = ob_get_clean();
     $replacer = new Replacer();
     return $replacer->RealizeVariables($result);
 }
Example #12
0
 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));
 }
Example #13
0
 /**
  * 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());
         }
     }
 }
Example #14
0
 /**
  * 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;
 }
 /**
  * Sets previous page
  * @param Page $item The page
  * @param Page $previous The previous page
  */
 public function SetPrevious($item, $previous)
 {
     $item->SetPrevious($previous);
 }
Example #16
0
 /**
  * The page end comment
  * @param Page $page
  * @return CommentLine
  */
 function PageEndComment(Page $page)
 {
     $text = str_replace('{0}', $page->GetID(), self::END_PAGE_COMMENT);
     return new CommentLine($text);
 }
Example #17
0
 private function PageAllowed(Page $page)
 {
     if ($page->GetType() != (string) PageType::Normal() || $page->GetSitemapRelevance() == 0) {
         return false;
     }
     return $this->guard->Allow(Action::Read(), $page);
 }
Example #18
0
 /**
  * The link for the back button
  * @return string Returns the url to the page tree
  */
 protected function BackLink()
 {
     $params = array('site' => $this->page->GetSite()->GetID());
     $params['selected'] = $this->page->GetID();
     return BackendRouter::ModuleUrl(new PageTree(), $params);
 }
Example #19
0
 /**
  * Gets the selected page
  */
 public function GetPage()
 {
     return $this->Value('Page') ? Page::Schema()->ByID($this->Value('Page')) : null;
 }
Example #20
0
 protected function TableSchema()
 {
     return Page::Schema();
 }
Example #21
0
 private function ReplacePageUrl(Page $page, Token $token, $startPos, &$endPos)
 {
     $params = $token->PropertyParams;
     if ($page->Equals(PageRenderer::Page())) {
         //merge current GET parameters on current page
         $params = array_merge(Request::GetArray(), $params);
     }
     $url = FrontendRouter::PageUrl($page, $params);
     $this->InsertValue($url, $token, $startPos, $endPos);
 }
Example #22
0
 /**
  * Grant evaluation for adding a page on top of the site
  * @param Site $site The site
  * @return GrantResult The result
  */
 function GrantAddPageToSite(Site $site)
 {
     //Dummy page for evaluation
     $page = new Page();
     $page->SetUserGroup($site->GetUserGroup());
     $siteRights = $site->GetUserGroupRights();
     if ($siteRights) {
         $page->SetUserGroupRights($siteRights->GetPageRights());
     }
     return $this->Grant(BackendAction::Create(), $page);
 }
Example #23
0
 /**
  * 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);
 }
Example #24
0
 /**
  * The last log item that is directly related to the page
  * @param Page $page The page
  * @return LogItem Returns the log item
  */
 static function LastPageLog(Page $page)
 {
     $tblLogPage = LogPage::Schema()->Table();
     $tblLogItem = LogItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
     $joinCond = $sql->Equals($tblLogPage->Field('LogItem'), $tblLogItem->Field('ID'));
     $where = $sql->Equals($tblLogPage->Field('Page'), $sql->Value($page->GetID()));
     return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogPage), JoinType::Inner(), $joinCond);
 }