示例#1
0
 public function testAliases()
 {
     $parent = Page::getByPath('/test-page-2/foo-bar');
     $subject = Page::getByPath('/another-fun-page');
     $subject->addCollectionAlias($parent);
     $pc = Page::getByPath('/brace-yourself');
     $pc->move($parent);
     $page = $this->createPage('Page 2', $parent);
     $page->reindex();
     $this->list->filterByParentID($parent->getCollectionID());
     $this->list->includeAliases();
     $totalResults = $this->list->getTotalResults();
     $this->assertEquals(3, $totalResults);
     $this->list->filterByKeywords('Page');
     $totalResults = $this->list->getTotalResults();
     // should get two.
     $this->assertEquals(2, $totalResults);
     $nl = new \Concrete\Core\Page\PageList();
     $nl->includeAliases();
     $nl->ignorePermissions();
     $nl->sortByName();
     $total = $nl->getPagination()->getTotalResults();
     $results = $nl->getPagination()->setMaxPerPage(10)->getCurrentPageResults();
     $this->assertEquals(15, $total);
     $this->assertEquals(10, count($results));
     $this->assertTrue($results[2]->isAlias());
     $this->assertEquals('Another Fun Page', $results[2]->getCollectionName());
     $this->assertEquals($results[2]->getCollectionID(), $subject->getCollectionID());
     $this->assertEquals(14, $results[2]->getCollectionPointerOriginalID());
     $this->assertEquals(8, $results[2]->getCollectionID());
 }
示例#2
0
文件: add_blog.php 项目: baardev/lbtb
 public function view()
 {
     $blogify = Loader::helper('blogify');
     $settings = $blogify->getBlogSettings();
     $this->set('settings', $settings);
     $this->setupForm();
     $blogList = new PageList();
     $blogList->sortBy('cDateAdded', 'desc');
     if (isset($_GET['cParentID']) && $_GET['cParentID'] > 0) {
         $blogList->filterByParentID($_GET['cParentID']);
     } else {
         $sections = $this->get('sections');
         $keys = array_keys($sections);
         $keys[] = -1;
         $blogList->filterByParentID($keys);
     }
 }
示例#3
0
 public function getChildPages($parent)
 {
     $list = new PageList();
     $list->filterByExcludeNav(false);
     $list->sortByDisplayOrder();
     $list->filterByParentID($parent->getCollectionID());
     $pages = $list->getResults();
     return $pages;
 }
 public function view()
 {
     $pl = new PageList();
     $pl->filterByPageTypeHandle('catalog');
     $parentCID = Page::getCurrentPage()->getCollectionID();
     $pl->filterByParentID($parentCID);
     $catalogs = $pl->getResults();
     $this->set('catalogs', $catalogs);
 }
 public function view()
 {
     $pl = new PageList();
     $pl->filterByPageTypeHandle('product');
     $parentCID = Page::getCurrentPage()->getCollectionID();
     $pl->filterByParentID($parentCID);
     // $pl->filterByPath($path, $includeAllChildren = true)
     $products = $pl->getResults();
     $this->set('products', $products);
 }
 public static function getChildPage($cID, $ctHandle)
 {
     $pl = new PageList();
     //Filters
     $pl->filterByParentID($cID);
     $pl->filterByPageTypeHandle($ctHandle);
     //Get the page List Results
     $res = $pl->get(1);
     return $res[0];
 }
示例#7
0
文件: bulk.php 项目: ngreimel/kovent
 /**
  * @return bool|PageList
  */
 public function getRequestedSearchResults()
 {
     $dh = Loader::helper('concrete/dashboard/sitemap');
     if (!$dh->canRead()) {
         return false;
     }
     $pageList = new PageList();
     if ($_REQUEST['submit_search']) {
         $pageList->resetSearchRequest();
     }
     $req = $_REQUEST;
     $pageList->displayUnapprovedPages();
     $pageList->sortBy('cDateModified', 'desc');
     $cvName = htmlentities($req['cvName'], ENT_QUOTES, APP_CHARSET);
     if ($cvName != '') {
         $pageList->filterByName($cvName);
     }
     if ($req['cParentIDSearchField'] > 0) {
         if ($req['cParentAll'] == 1) {
             $pc = Page::getByID($req['cParentIDSearchField']);
             $cPath = $pc->getCollectionPath();
             $pageList->filterByPath($cPath);
         } else {
             $pageList->filterByParentID($req['cParentIDSearchField']);
         }
         $parentDialogOpen = 1;
     }
     $keywords = htmlentities($req['keywords'], ENT_QUOTES, APP_CHARSET);
     $pageList->filterByKeywords($keywords, true);
     if ($req['numResults']) {
         $pageList->setItemsPerPage($req['numResults']);
     }
     if ($req['ptID']) {
         $pageList->filterByPageTypeID($req['ptID']);
     }
     if ($_REQUEST['noKeywords'] == 1) {
         $pageList->filter('CollectionSearchIndexAttributes.ak_meta_keywords', NULL, '=');
         $this->set('keywordCheck', true);
         $parentDialogOpen = 1;
     }
     if ($_REQUEST['noDescription'] == 1) {
         $pageList->filter('CollectionSearchIndexAttributes.ak_meta_description', NULL, '=');
         $this->set('descCheck', true);
         $parentDialogOpen = 1;
     }
     $this->set('searchRequest', $req);
     $this->set('parentDialogOpen', $parentDialogOpen);
     return $pageList;
 }
示例#8
0
 public function view()
 {
     $pl = new PageList();
     if ($this->ptID) {
         $pl->filterByPageTypeID($this->ptID);
     }
     if ($this->cParentID) {
         $pl->filterByParentID($this->cParentID);
     }
     $query = $pl->deliverQueryObject();
     $query->select('date_format(cv.cvDatePublic, "%Y") as navYear, date_format(cv.cvDatePublic, "%m") as navMonth');
     $query->groupBy('navYear, navMonth');
     $query->orderBy('cvDatePublic', 'desc');
     $r = $query->execute();
     $dates = array();
     while ($row = $r->fetch()) {
         $dates[] = array('year' => $row['navYear'], 'month' => $row['navMonth']);
     }
     $this->set('dates', $dates);
 }
示例#9
0
文件: Feed.php 项目: ngreimel/kovent
 /**
  * @return \Concrete\Core\Page\PageList
  */
 public function getPageListObject()
 {
     $pl = new PageList();
     $pl->setItemsPerPage($this->itemsPerFeed);
     $pl->sortByPublicDateDescending();
     if (!$this->checkPagePermissions) {
         $pl->ignorePermissions();
     } else {
         $vp = \Concrete\Core\Permission\Key\Key::getByHandle('view_page');
         $guest = \Group::getByID(GUEST_GROUP_ID);
         $access = GroupEntity::getOrCreate($guest);
         // we set page permissions to be Guest group only, because
         // authentication won't work with RSS feeds
         $pl->setPermissionsChecker(function ($page) use($vp, $access) {
             $vp->setPermissionObject($page);
             $pa = $vp->getPermissionAccessObject($page);
             if (!is_object($pa)) {
                 return false;
             }
             return $pa->validateAccessEntities(array($access));
         });
     }
     if ($this->cParentID) {
         if ($this->pfIncludeAllDescendents) {
             $parent = \Page::getByID($this->cParentID);
             if (is_object($parent) && !$parent->isError()) {
                 $pl->filterByPath($parent->getCollectionPath());
             }
         } else {
             $pl->filterByParentID($this->cParentID);
         }
     }
     if ($this->pfDisplayAliases) {
         $pl->includeAliases();
     }
     if ($this->ptID) {
         $pl->filterByPageTypeID($this->ptID);
     }
     if ($this->pfDisplayFeaturedOnly) {
         $pl->filterByAttribute('is_featured', true);
     }
     return $pl;
 }
示例#10
0
 public function search()
 {
     $dh = Loader::helper('concrete/dashboard/sitemap');
     if (!$dh->canRead()) {
         return false;
     }
     if ($_REQUEST['submitSearch']) {
         $this->searchRequest->resetSearchRequest();
     }
     $req = $this->searchRequest->getSearchRequest();
     $columns = PageSearchColumnSet::getCurrent();
     if (!$this->pageList->getActiveSortColumn()) {
         $col = $columns->getDefaultSortColumn();
         $this->pageList->sanitizedSortBy($col->getColumnKey(), $col->getColumnDefaultSortDirection());
     }
     $cvName = htmlentities($req['cvName'], ENT_QUOTES, APP_CHARSET);
     $this->pageList->setPageVersionToRetrieve(\Concrete\Core\Page\PageList::PAGE_VERSION_RECENT);
     if ($cvName != '') {
         $this->pageList->filterByName($cvName);
     }
     if ($req['numResults'] && Loader::helper('validation/numbers')->integer($req['numResults'])) {
         $this->pageList->setItemsPerPage($req['numResults']);
     }
     if ($req['ptID']) {
         $this->pageList->filterByPageTypeID($req['ptID']);
     }
     if (is_array($req['field'])) {
         foreach ($req['field'] as $i => $item) {
             $this->fields[] = $this->getField($item);
             // due to the way the form is setup, index will always be one more than the arrays
             if ($item != '') {
                 switch ($item) {
                     case 'keywords':
                         $keywords = htmlentities($req['keywords'], ENT_QUOTES, APP_CHARSET);
                         $this->pageList->filterByFulltextKeywords($keywords);
                         break;
                     case 'num_children':
                         $symbol = '=';
                         if ($req['cChildrenSelect'] == 'gt') {
                             $symbol = '>';
                         } elseif ($req['cChildrenSelect'] == 'lt') {
                             $symbol = '<';
                         }
                         $this->pageList->filterByNumberOfChildren($req['cChildren'], $symbol);
                         break;
                     case 'owner':
                         $ui = \UserInfo::getByUserName($req['owner']);
                         if (is_object($ui)) {
                             $this->pageList->filterByUserID($ui->getUserID());
                         } else {
                             $this->pageList->filterByUserID(-1);
                         }
                         break;
                     case 'theme':
                         $this->pageList->filter('pThemeID', $req['pThemeID']);
                         break;
                     case 'parent':
                         if (isset($req['_cParentAll'])) {
                             $req['cParentAll'] = $req['_cParentAll'];
                         }
                         if ($req['cParentIDSearchField'] > 0) {
                             if ($req['cParentAll'] == 1) {
                                 $pc = \Page::getByID($req['cParentIDSearchField']);
                                 $cPath = $pc->getCollectionPath();
                                 $this->pageList->filterByPath($cPath);
                             } else {
                                 $this->pageList->filterByParentID($req['cParentIDSearchField']);
                             }
                         }
                         break;
                     case 'version_status':
                         if (in_array($req['versionToRetrieve'], array(\Concrete\Core\Page\PageList::PAGE_VERSION_RECENT, \Concrete\Core\Page\PageList::PAGE_VERSION_ACTIVE))) {
                             $this->pageList->setPageVersionToRetrieve($req['versionToRetrieve']);
                         }
                         break;
                     case 'permissions_inheritance':
                         $this->pageList->filter('cInheritPermissionsFrom', $req['cInheritPermissionsFrom']);
                         break;
                     case "date_public":
                         $wdt = Loader::helper('form/date_time');
                         /* @var $wdt \Concrete\Core\Form\Service\Widget\DateTime */
                         $dateFrom = $wdt->translate('date_public_from', $req);
                         if ($dateFrom) {
                             $this->pageList->filterByPublicDate($dateFrom, '>=');
                         }
                         $dateTo = $wdt->translate('date_public_to', $req);
                         if ($dateTo != '') {
                             if (preg_match('/^(.+\\d+:\\d+):00$/', $dateTo, $m)) {
                                 $dateTo = $m[1] . ':59';
                             }
                             $this->pageList->filterByPublicDate($dateTo, '<=');
                         }
                         break;
                     case "last_modified":
                         $wdt = Loader::helper('form/date_time');
                         /* @var $wdt \Concrete\Core\Form\Service\Widget\DateTime */
                         $dateFrom = $wdt->translate('last_modified_from', $req);
                         if ($dateFrom) {
                             $this->pageList->filterByDateLastModified($dateFrom, '>=');
                         }
                         $dateTo = $wdt->translate('last_modified_to', $req);
                         if ($dateTo) {
                             if (preg_match('/^(.+\\d+:\\d+):00$/', $dateTo, $m)) {
                                 $dateTo = $m[1] . ':59';
                             }
                             $this->pageList->filterByDateLastModified($dateTo, '<=');
                         }
                         break;
                     case "date_added":
                         $wdt = Loader::helper('form/date_time');
                         /* @var $wdt \Concrete\Core\Form\Service\Widget\DateTime */
                         $dateFrom = $wdt->translate('date_added_from', $req);
                         if ($dateFrom) {
                             $this->pageList->filterByDateAdded($dateFrom, '>=');
                         }
                         $dateTo = $wdt->translate('date_added_to', $req);
                         if ($dateTo) {
                             if (preg_match('/^(.+\\d+:\\d+):00$/', $dateTo, $m)) {
                                 $dateTo = $m[1] . ':59';
                             }
                             $this->pageList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     default:
                         $akID = $item;
                         $fak = CollectionAttributeKey::getByID($akID);
                         if (!is_object($fak) || !$fak instanceof CollectionAttributeKey) {
                             break;
                         }
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setRequestArray($req);
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($this->pageList);
                         break;
                 }
             }
         }
     }
     $ilr = new PageSearchResult($columns, $this->pageList, URL::to('/ccm/system/search/pages/submit'), $this->fields);
     $this->result = $ilr;
 }
示例#11
0
 /**
  * Filters by parent ID
  * @param array | integer $cParentID
  */
 public function filterByParentID($cParentID)
 {
     return parent::filterByParentID($cParentID);
 }
示例#12
0
 /**
  * @return bool|PageList
  */
 public function getRequestedSearchResults()
 {
     $dh = $this->app->make('helper/concrete/dashboard/sitemap');
     if (!$dh->canRead()) {
         return false;
     }
     $pageList = new PageList();
     if ($this->request('submit_search')) {
         $pageList->resetSearchRequest();
     }
     $pageList->displayUnapprovedPages();
     $pageList->sortBy('cDateModified', 'desc');
     $cvName = $this->request('cvName');
     if ($cvName) {
         $pageList->filterByName($cvName);
     }
     $cParentIDSearchField = $this->request('cParentIDSearchField');
     if ($cParentIDSearchField > 0) {
         if ($this->request('cParentAll') == 1) {
             $pc = Page::getByID($cParentIDSearchField);
             if ($pc && !$pc->isError()) {
                 $cPath = $pc->getCollectionPath();
                 $pageList->filterByPath($cPath);
             }
         } else {
             $pageList->filterByParentID($cParentIDSearchField);
         }
         $parentDialogOpen = 1;
     }
     $keywords = $this->request('keywords');
     $pageList->filterByKeywords($keywords, true);
     $numResults = $this->request('numResults');
     if ($numResults) {
         $pageList->setItemsPerPage($numResults);
     }
     $ptID = $this->request('ptID');
     if ($ptID) {
         $pageList->filterByPageTypeID($ptID);
     }
     if ($this->request('noDescription') == 1) {
         $pageList->filter(false, "csi.ak_meta_description is null or csi.ak_meta_description = ''");
         $this->set('descCheck', true);
         $parentDialogOpen = 1;
     } else {
         $parentDialogOpen = null;
     }
     $this->set('searchRequest', $_REQUEST);
     $this->set('parentDialogOpen', $parentDialogOpen);
     return $pageList;
 }
示例#13
0
 function get_forum_pages()
 {
     $c = Page::getCurrentPage();
     if ($c->getPageTypeHandle() == 'forum_post') {
         $parentCID = $c->getCollectionParentID();
         $forumPages = array(Page::getByID($parentCID));
     } else {
         $parentCID = $c->getCollectionID();
         if ($parentCID < 1 || $parentCID == false) {
             $parentCID = 1;
         }
         $fpl = new PageList();
         $fpl->sortByDisplayOrder();
         $fpl->filterByParentID($parentCID);
         $fpl->filterByAttribute('forum_category', true);
         $forumPages = $fpl->get();
         if (count($forumPages) < 2) {
             if ($c->getAttribute('forum_category')) {
                 $forumPages = array($c);
             }
         }
     }
     return $forumPages;
 }