public function testExcludingAliasesAndBasicGet() { $subject = Page::getByPath('/test-page-2'); $parent = Page::getByPath('/another-fun-page'); $subject->addCollectionAlias($parent); $this->list->sortBy('cID', 'desc'); $results = $this->list->getResults(); $this->assertEquals(13, count($results)); $this->assertEquals('Foobler', $results[0]->getCollectionName()); }
public function getCommentsByParentIDs($IDs) { $db = Loader::db(); $child_pages = array(); $blogList = new PageList(); $blogList->sortBy('cDateAdded', 'desc'); //$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')"); $blogList->filter(false, "ak_is_canonical_page < 1"); if (!$IDs) { $r = $db->EXECUTE("SELECT DISTINCT cnv.cID FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID ORDER BY cnvMessageDateCreated DESC"); while ($row = $r->fetchrow()) { $IDs[] = $row['cID']; } } if (is_array($IDs)) { foreach ($IDs as $id) { if ($fs) { $fs .= ' OR '; } $path = Page::getByID($id)->getCollectionPath() . '/'; $fs .= "pp.cPath LIKE '{$path}%'"; } $blogList->filter(false, "({$fs})"); } //$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')"); $blogList->filter(false, "ak_is_canonical_page < 1"); $blogResults = $blogList->get(); foreach ($blogResults as $result) { $child_pages[] = $result->getCollectionID(); } $filter = ''; if ($this->request('comment_todo')) { $this->set('comment_todo', $this->request('comment_todo')); switch ($this->request('comment_todo')) { case 'approves': $filter = "WHERE cnvm.cnvIsMessageApproved = 1"; break; case 'unapproves': $filter = "WHERE cnvm.cnvIsMessageDeleted = 1"; break; } } $r = $db->EXECUTE("SELECT * FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID {$filter} ORDER BY cnvMessageDateCreated DESC"); $comments = array(); while ($row = $r->fetchrow()) { $ccObj = Page::getByID($row['cID']); $pID = $ccObj->getCollectionID(); //var_dump($pID.' - '.print_r($child_pages)); if (in_array($pID, $child_pages)) { $comments[] = $row; } } return $comments; }
/** * @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; }
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); } }
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->sortBy($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 = '>'; } else { if ($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 (isset($req['_cvIsApproved'])) { $req['cvIsApproved'] = $req['_cvIsApproved']; } $this->pageList->filterByIsApproved($req['cvIsApproved']); break; case 'permissions_inheritance': $this->pageList->filter('cInheritPermissionsFrom', $req['cInheritPermissionsFrom']); break; case "date_public": $dateFrom = $req['date_public_from']; $dateTo = $req['date_public_to']; if ($dateFrom != '') { $dateFrom = date('Y-m-d', strtotime($dateFrom)); $this->pageList->filterByPublicDate($dateFrom, '>='); $dateFrom .= ' 00:00:00'; } if ($dateTo != '') { $dateTo = date('Y-m-d', strtotime($dateTo)); $dateTo .= ' 23:59:59'; $this->pageList->filterByPublicDate($dateTo, '<='); } break; case "last_modified": $dateFrom = $req['last_modified_from']; $dateTo = $req['last_modified_to']; if ($dateFrom != '') { $dateFrom = date('Y-m-d', strtotime($dateFrom)); $this->pageList->filterByDateLastModified($dateFrom, '>='); $dateFrom .= ' 00:00:00'; } if ($dateTo != '') { $dateTo = date('Y-m-d', strtotime($dateTo)); $dateTo .= ' 23:59:59'; $this->pageList->filterByDateLastModified($dateTo, '<='); } break; case "date_added": $dateFrom = $req['date_added_from']; $dateTo = $req['date_added_to']; if ($dateFrom != '') { $dateFrom = date('Y-m-d', strtotime($dateFrom)); $this->pageList->filterByDateAdded($dateFrom, '>='); $dateFrom .= ' 00:00:00'; } if ($dateTo != '') { $dateTo = date('Y-m-d', strtotime($dateTo)); $dateTo .= ' 23:59: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; }
public function view() { $html = Loader::helper('html'); // $this->addHeaderItem($html->css('css/font-awesome.css','problog')); // $this->addHeaderItem($html->css('css/seo_tools.css','problog')); // $this->addHeaderItem($html->css('app.css')); // $this->addHeaderItem($html->css('redactor.css')); // $this->addHeaderItem($html->css('jquery-ui.css')); // $this->addHeaderItem($html->javascript('jquery.js')); // $this->addHeaderItem('<script type="text/javascript"> var $ = jQuery.noConflict(); </script>'); // $this->addHeaderItem($html->javascript('legacy.js')); // $this->addHeaderItem($html->javascript('jquery-ui.js')); // $this->addHeaderItem($html->javascript('events.js')); //$this->addHeaderItem($html->javascript('app.js')); //$this->addHeaderItem($html->javascript('redactor.js')); // $this->addFooterItem($html->javascript('file-manager.js')); // $this->addFooterItem($html->javascript('seo_tools.js','problog')); $blogify = Loader::helper('blogify'); $settings = $blogify->getBlogSettings(); $blogSectionList = new PageList(); $blogSectionList->filter(false, "ak_blog_section = 1"); $blogSectionList->sortBy('cvName', 'asc'); $tmpSections = $blogSectionList->get(); $sections = array(); foreach ($tmpSections as $_c) { $spk = new AddSubpagePageKey(); $pp = $spk->validate($_c); if ($pp) { $pt = $p; $sections[$_c->getCollectionID()] = $_c->getCollectionName(); } } $ctArray = CollectionType::getList(''); $pageTypes = array(); foreach ($ctArray as $ct) { $spk = new AddSubpagePageKey(); $pp = $spk->validate($ct); if ($pp) { $pageTypes[$ct->getPageTypeID()] = $ct->getPageTypeName(); } } if ($_REQUEST['postID']) { $keys = array_keys($sections); $keys[] = -1; $current_page = Page::getByID($_REQUEST['postID']); $date = $current_page->getCollectionDatePublic(); $canonical_parent_id = $blogify->getCanonicalParent($date, $current_page); $cParentID = $canonical_parent_id; if (in_array($canonical_parent_id, $keys)) { $this->blog = $current_page; } } if (is_object($this->blog)) { $blogTitle = $this->blog->getCollectionName(); $blogDescription = $this->blog->getCollectionDescription(); $blogDate = $this->blog->getCollectionDatePublic(); $ctID = $this->blog->getCollectionTypeID(); $blogBody = ''; $eb = $this->blog->getBlocks('Main'); if (is_object($eb[0])) { $blogBody = $eb[0]->getInstance()->getContent(); } echo "<div class=\"event_warning\"><span class=\"tooltip icon edit\"></span> You are now editing <b><u>{$blogTitle}</u></b></div>"; $task = 'editthis'; $buttonText = t('Update Blog Entry'); $title = 'Update'; } else { $task = 'addthis'; $buttonText = t('Add Blog Entry'); $title = 'Add'; } $this->set('blog', $this->blog); $this->set('blogTitle', $blogTitle); $this->set('blogDescription', $blogDescription); $this->set('blogBody', $blogBody); $this->set('sections', $sections); $this->set('pageTypes', $pageTypes); $this->set('buttonText', $buttonText); }
public function sortBy($field, $direction = "asc") { return parent::sortBy($field, $direction); }
/** * @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; }
protected function loadblogSections() { $blogSectionList = new PageList(); $blogSectionList->setItemsPerPage($this->num); $blogSectionList->filterByBlogSection(1); $blogSectionList->sortBy('cvName', 'asc'); $tmpSections = $blogSectionList->get(); $sections = array(); foreach ($tmpSections as $_c) { $sections[$_c->getCollectionID()] = $_c->getCollectionName(); } $this->sections = $sections; }
/** * render Add Blog dialog */ public function render() { $this->requireAsset('redactor'); $this->requireAsset('core/file-manager'); $blogify = Loader::helper('blogify'); $settings = $blogify->getBlogSettings(); $blogSectionList = new PageList(); $blogSectionList->filter(false, "ak_blog_section = 1"); $blogSectionList->sortBy('cvName', 'asc'); $tmpSections = $blogSectionList->get(); $sections = array(); foreach ($tmpSections as $_c) { $pt = CollectionType::getByID($_c->getCollectionTypeID()); $cmp = new \Permissions($pt); $pp = $cmp->canAddPageType(); if ($pp) { $sections[$_c->getCollectionID()] = $_c->getCollectionName(); } } $ctArray = PageTemplate::getList(''); $pageTemplates = array(); foreach ($ctArray as $ct) { $pms = new AddSubpagePageKey($ct); $pp = $pms->validate(); if ($pp) { $pageTemplates[$ct->getPageTemplateID()] = $ct->getPageTemplateName(); } } if ($_REQUEST['postID']) { $keys = array_keys($sections); $keys[] = -1; $current_page = Page::getByID($_REQUEST['postID']); $date = $current_page->getCollectionDatePublic(); $canonical_parent_id = $blogify->getCanonicalParent($date, $current_page); $cParentID = $canonical_parent_id; if (in_array($canonical_parent_id, $keys)) { $this->blog = $current_page; } } if (is_object($this->blog)) { $blogTitle = $this->blog->getCollectionName(); $blogDescription = $this->blog->getCollectionDescription(); $blogDate = $this->blog->getCollectionDatePublic(); $ptID = $this->blog->getPageTemplateID(); $blogBody = ''; $eb = $this->blog->getBlocks('Main'); foreach ($eb as $b) { if ($b->getBlockTypeHandle() == 'content' || $b->getBlockTypeHandle() == 'core_page_type_composer_control_output') { $blogBody = $b->getInstance()->getContent(); } } echo "<div class=\"alert alert-success\"><span class=\"tooltip icon edit\"></span> " . t('You are now editing') . " <b><u>{$blogTitle}</u></b></div>"; $task = 'editthis'; $buttonText = t('Update Blog Entry'); $title = 'Update'; } else { $task = 'addthis'; $buttonText = t('Add Blog Entry'); $title = 'Add'; } Loader::PackageElement('tools/add_blog', 'problog', array('blog' => $this->blog, 'blogTitle' => $blogTitle, 'blogDescription' => $blogDescription, 'blogBody' => $blogBody, 'sections' => $sections, 'pageTemplates' => $pageTemplates, 'buttonText' => $buttonText, 'ptID' => $ptID, 'settings' => $settings)); }