public function getResults(Request $request) { $pl = new PageList(); $query = $request->query->all(); $keywords = $query['keywords']; $ptID = $query['ptID']; $startingPoint = intval($query['startingPoint']); $datetime = \Core::make('helper/form/date_time')->translate('datetime', $query); $pl->ignorePermissions(); if ($startingPoint) { $parent = \Page::getByID($startingPoint, 'ACTIVE'); $pl->filterByPath($parent->getCollectionPath()); } if ($datetime) { $pl->filterByPublicDate($datetime, '>='); } if ($ptID) { $pl->filterByPageTypeID($ptID); } if ($keywords) { $pl->filterByKeywords($keywords); } $pl->setItemsPerPage(1000); $results = $pl->getResults(); $items = array(); foreach ($results as $c) { $item = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\Page(); $item->setItemId($c->getCollectionID()); $items[] = $item; } return $items; }
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()); }
/** * @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; }
/** * Filters keyword fields by keywords (including name, description, content, and attributes. * @param $keywords */ public function filterByKeywords($keywords) { return parent::filterByKeywords($keywords); }
/** * @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; }