public function getBlogSectionPages() { $blogSectionList = new ProblogList(); $blogSectionList->displayUnapprovedPages(); $blogSectionList->setItemsPerPage(10); $blogSectionList->filter(false, "csi.ak_blog_section = 1"); $blogSectionList->sortBy('cvName', 'asc'); $tmpSections = $blogSectionList->getResults(); $sections = array(); foreach ($tmpSections as $_c) { $sections[$_c->getCollectionID()] = $_c->getCollectionName(); } return $sections; }
public function getPages($query = null) { $b = Block::getByID($this->bID); $exclude_list = array('tags', 'categories', 'tag_cloud', 'archive'); $template = strtolower($b->getBlockFilename()); if (!in_array($template, $exclude_list)) { $pl = new ProblogList(); $db = Loader::db(); $bID = $this->bID; if ($this->bID) { $q = "select * from btProBlogList where bID = '{$bID}'"; $r = $db->query($q); if ($r) { $row = $r->fetchRow(); } } else { $row['num'] = $this->num; $row['cParentID'] = $this->cParentID; $row['cThis'] = $this->cThis; $row['orderBy'] = $this->orderBy; $row['ctID'] = $this->ctID; $row['rss'] = $this->rss; $row['category'] = $this->category; $row['title'] = $this->title; $row['paginate'] = $this->paginate; $row['displayAliases'] = $this->displayAliases; $row['subscribe'] = $this->subscribe; $row['rssTitle'] = $this->rssTitle; $row['rssDescription'] = $this->rssDescription; $row['truncateSummaries'] = $this->truncateSummaries; $row['truncateChars'] = $this->truncateChars; $row['use_content'] = $this->use_content; $row['author'] = $this->author; } $cArray = array(); switch ($row['orderBy']) { case 'display_asc': $pl->sortByDisplayOrder(); break; case 'display_desc': $pl->sortByDisplayOrderDescending(); break; case 'chrono_asc': $pl->sortByPublicDateTime(); break; case 'alpha_asc': $pl->sortByName(); break; case 'alpha_desc': $pl->sortByNameDescending(); break; default: $pl->sortByPublicDateDescending(); break; } $num = (int) $row['num']; if ($num > 0) { $pl->setItemsPerPage($num); } $c = Page::getCurrentPage(); if (is_object($c)) { $this->cID = $c->getCollectionID(); } $cParentID = $row['cThis'] ? $this->cID : $row['cParentID']; //$pl->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')"); $pl->filter(false, "ak_is_canonical_page < 1"); $pl->filterByPublicDate(date('Y-m-d H:i:s'), '<='); //filter by publish date Loader::model('attribute/categories/collection'); if ($this->displayFeaturedOnly == 1) { $cak = CollectionAttributeKey::getByHandle('is_featured'); if (is_object($cak)) { $pl->filterByIsFeatured(1); } } if (!$row['displayAliases']) { $pl->filterByIsAlias(0); } $pl->filter('cvName', '', '!='); if ($row['ctID']) { $ctID = $row['ctID']; $pl->filter(false, "p.ptID = {$ctID}"); } $columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable()); if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) { $pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)'); } if (intval($cParentID) != 0) { $path = Page::getByID($cParentID)->getCollectionPath(); $pl->filterByPath($path); } if ($row['author']) { $pl->filterByBlogAuthor($row['author']); } if ($this->category != t('All Categories')) { $selected_cat = explode(', ', $this->category); if ($this->filter_strict > 0) { $condition = ' AND '; } else { $condition = ' OR '; } foreach ($selected_cat as $cat) { $cat = str_replace("'", "\\'", $cat); if ($fi) { $category_filter .= $condition; } $category_filter .= "ak_blog_category LIKE '%\n{$cat}\n%'"; $fi++; } $pl->filter(false, "(" . $category_filter . ")"); } //$pl->debug(); //Pagination... $showPagination = false; if ($this->paginate > 0) { $pagination = $pl->getPagination(); $pages = $pagination->getCurrentPageResults(); if ($pagination->getTotalPages() > 1 && $this->paginate) { $showPagination = true; $pagination = $pagination->renderDefaultView(); $this->set('pagination', $pagination); } } else { $pages = $pl->getResults(); } if ($showPagination) { $this->requireAsset('css', 'core/frontend/pagination'); } $this->set('pl', $pl); } return $pages; }
public function getPages($query = null) { global $c; $db = Loader::db(); $bID = $this->bID; if ($this->bID) { $q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btRelatedPages where bID = '{$bID}'"; $r = $db->query($q); if ($r) { $row = $r->fetchRow(); } } else { $row['num'] = $this->num; $row['cParentID'] = $this->cParentID; $row['cThis'] = $this->cThis; $row['orderBy'] = $this->orderBy; $row['ctID'] = $this->ctID; $row['rss'] = $this->rss; $row['displayAliases'] = $this->displayAliases; } $pl = new ProblogList(); $cArray = array(); switch ($row['orderBy']) { case 'display_asc': $pl->sortByDisplayOrder(); break; case 'display_desc': $pl->sortByDisplayOrderDescending(); break; case 'chrono_asc': $pl->sortByPublicDate(); break; case 'alpha_asc': $pl->sortByName(); break; case 'alpha_desc': $pl->sortByNameDescending(); break; default: $pl->sortByPublicDateDescending(); break; } $num = (int) $row['num']; if ($num > 0) { $pl->setItemsPerPage($num); } $c = Page::getCurrentPage(); if (is_object($c)) { $this->cID = $c->getCollectionID(); } $cParentID = $row['cThis'] ? $this->cID : $row['cParentID']; //$pl->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')"); $pl->filter(false, "ak_is_canonical_page < 1"); $pl->filter('cvName', '', '!='); if ($row['ctID']) { $ctID = $row['ctID']; $pl->filter(false, "p.ptID = {$ctID}"); } $columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable()); if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) { $pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)'); } if (intval($row['cParentID']) != 0 && intval($row['cParentID']) != 9999) { $path = Page::getByID($cParentID)->getCollectionPath(); $pl->filterByPath($path); } else { if (is_object($c)) { $parent = $c->getCollectionParentID(); $pl->filterByParentID($parent); } } if ($this->displayFeaturedOnly == 1) { $cak = CollectionAttributeKey::getByHandle('is_featured'); if (is_object($cak)) { $pl->filterByIsFeatured(1); } } if ($this->getAttributeKeyID()) { if ($this->akID == 'same_tags') { if (!is_object($c)) { $c = Page::getByID($this->ccID); } $ak_handle = 'tags'; $tags = $c->getAttribute($ak_handle); //$fields_array = explode(',',$tags); if ($tags) { $fields_array = $tags->getOptions(); } } else { if (!is_object($c)) { $c = Page::getByID($this->ccID); } $ak = CollectionAttributeKey::getByID($this->getAttributeKeyID()); $ak_handle = $ak->getAttributeKeyHandle(); $fields_array = explode(',', $this->fields); } //var_dump($fields_array); if ($fields_array) { foreach ($fields_array as $field) { if ($fs) { $filter .= ' OR '; } else { $filter .= '('; } $filter .= "ak_" . $ak_handle . " LIKE '%\n{$field}\n%'"; $fs++; } $filter .= ')'; } } if (is_object($c)) { $pl->filter(false, 'p.cID != ' . $c->getCollectionID()); } if ($filter) { $pl->Filter(false, $filter); } //$pl->debug(); $pl->ignoreAliases(); $pages = $pl->getResults(); $this->set('pl', $pl); return $pages; }