Example #1
0
 public function getMenuItemClass(Page $page)
 {
     $classes = [];
     if (is_object($this->currentPage) && $page->getCollectionID() == $this->currentPage->getCollectionID()) {
         $classes[] = 'nav-selected';
     }
     if (in_array($page->getCollectionID(), $this->trail)) {
         $classes[] = 'nav-path-selected';
     }
     return implode($classes, ' ');
 }
Example #2
0
 /**
  * Determines whether this nav item is the current page the user is on.
  *
  * @param \Concrete\Core\Page\Page $c The page object for the current page
  *
  * @return bool
  */
 public function isActive(&$c)
 {
     if ($c) {
         $cID = $c->getCollectionPointerID() > 0 ? $c->getCollectionPointerOriginalID() : $c->getCollectionID();
         return $cID == $this->cID;
     }
 }
 public function getPageTypeComposerControlBlockObject(Page $c)
 {
     $app = Application::getFacadeApplication();
     $db = $app->make('database')->connection();
     if (!is_object($this->b)) {
         $setControl = $this->getPageTypeComposerFormLayoutSetControlObject();
         $r = $db->fetchAssoc($q = 'select cdb.bID, cdb.arHandle from PageTypeComposerOutputBlocks cdb inner join CollectionVersionBlocks cvb on (cdb.bID = cvb.bID and cvb.cID = cdb.cID and cvb.cvID = ?) where cdb.ptComposerFormLayoutSetControlID = ? and cdb.cID = ?', [$c->getVersionID(), $setControl->getPageTypeComposerFormLayoutSetControlID(), $c->getCollectionID()]);
         if (!$r) {
             // this is the first run. so we look for the proxy block.
             $pt = PageTemplate::getByID($c->getPageTemplateID());
             $outputControl = $setControl->getPageTypeComposerOutputControlObject($pt);
             if (is_object($outputControl)) {
                 $cm = $c->getPageTypeObject();
                 $mc = $cm->getPageTypePageTemplateDefaultPageObject($pt);
                 $r = $db->fetchAssoc('select bco.bID, cvb.arHandle from btCorePageTypeComposerControlOutput bco inner join CollectionVersionBlocks cvb on cvb.bID = bco.bID where ptComposerOutputControlID = ? and cvb.cID = ?', [$outputControl->getPageTypeComposerOutputControlID(), $mc->getCollectionID()]);
             }
         }
         if ($r) {
             $b = Block::getByID($r['bID'], $c, $r['arHandle']);
             $this->setPageTypeComposerControlBlockObject($b);
             return $this->b;
         }
     }
     return $this->b;
 }
Example #4
0
 /**
  * @param Page $page
  *
  * @return Section
  */
 public static function getBySectionOfSite($page)
 {
     $identifier = sprintf('/multilingual/section/%s', $page->getCollectionID());
     $cache = \Core::make('cache/request');
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         $returnID = $item->get();
     } else {
         $item->lock();
         $tree = $page->getSiteTreeObject();
         $returnID = false;
         if ($tree instanceof SiteTree) {
             $returnID = $tree->getSiteHomePageID();
         }
         $cache->save($item->set($returnID));
     }
     if ($returnID) {
         return static::getByID($returnID);
     }
 }
Example #5
0
 public function movePageDisplayOrderToSibling(Page $c, $position = 'before')
 {
     // first, we get a list of IDs.
     $pageIDs = array();
     $db = Database::get();
     $r = $db->Execute('select cID from Pages where cParentID = ? and cID <> ? order by cDisplayOrder asc', array($this->getCollectionParentID(), $this->getCollectionID()));
     while ($row = $r->FetchRow()) {
         if ($row['cID'] == $c->getCollectionID() && $position == 'before') {
             $pageIDs[] = $this->cID;
         }
         $pageIDs[] = $row['cID'];
         if ($row['cID'] == $c->getCollectionID() && $position == 'after') {
             $pageIDs[] = $this->cID;
         }
     }
     $displayOrder = 0;
     foreach ($pageIDs as $cID) {
         $co = Page::getByID($cID);
         $co->updateDisplayOrder($displayOrder);
         $displayOrder++;
     }
 }
Example #6
0
 public function markPreviousFrontendPage(Page $c)
 {
     $app = Application::getFacadeApplication();
     $app['session']->set('frontendPreviousPageID', $c->getCollectionID());
 }
Example #7
0
 /**
  * @param Page $c
  */
 public function refreshCollectionEdit(&$c)
 {
     if ($this->isLoggedIn() && $c->getCollectionCheckedOutUserID() == $this->getUserID()) {
         $app = Application::getFacadeApplication();
         $db = $app['database']->connection();
         $cID = $c->getCollectionID();
         $dh = $app->make('helper/date');
         $datetime = $dh->getOverridableNow();
         $q = 'update Pages set cCheckedOutDatetimeLastEdit = ? where cID = ?';
         $r = $db->executeQuery($q, array($datetime, $cID));
         $c->cCheckedOutDatetimeLastEdit = $datetime;
     }
 }
 public function setPage(Page $page)
 {
     $this->cID = $page->getCollectionID();
 }
Example #9
0
 /**
  * @param Page $page
  *
  * @return Section
  */
 public static function getBySectionOfSite($page)
 {
     $identifier = sprintf('/multilingual/section/%s', $page->getCollectionID());
     $cache = \Core::make('cache/request');
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         $returnID = $item->get();
     } else {
         $item->lock();
         if ($page->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             $parent = Page::getByID($page->getCollectionParentID());
             if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
                 // this is the default multilingual section.
                 return static::getDefaultSection();
             } else {
                 // this is a stack category page type
                 $locale = $parent->getCollectionHandle();
                 return static::getByLocale($locale);
             }
         }
         // looks at the page, traverses its parents until it finds the proper language
         $nav = \Core::make('helper/navigation');
         $pages = $nav->getTrailToCollection($page);
         $pages = array_reverse($pages);
         $pages[] = $page;
         $ids = self::getIDList();
         $returnID = false;
         foreach ($pages as $pc) {
             if (in_array($pc->getCollectionID(), $ids)) {
                 $returnID = $pc->getCollectionID();
             }
         }
         $item->set($returnID);
     }
     if ($returnID) {
         return static::getByID($returnID);
     }
 }
 public function canPublishPageTypeBeneathTarget(Type $pagetype, \Concrete\Core\Page\Page $page)
 {
     return $page->getCollectionID() == $this->getParentPageID();
 }
Example #11
0
 public function setPageObject(Page $c)
 {
     $this->cID = $c->getCollectionPointerOriginalID() > 0 ? $c->getCollectionPointerOriginalID() : $c->getCollectionID();
 }
Example #12
0
 public function getCollectionID()
 {
     return parent::getCollectionID();
 }
Example #13
0
 public static function getByDefaultsPage(Page $c)
 {
     if ($c->isMasterCollection()) {
         $db = Loader::db();
         $ptID = $db->GetOne('select ptID from PageTypePageTemplateDefaultPages where cID = ?', array($c->getCollectionID()));
         if ($ptID) {
             return static::getByID($ptID);
         }
     }
 }