Esempio n. 1
0
 public function view()
 {
     $this->loadblogSections();
     $blogList = new ProblogList();
     $blogList->displayUnapprovedPages();
     $blogList->includeSystemPages(true);
     $blogList->includeInactivePages(true);
     $blogList->sortBy('cDateAdded', 'desc');
     if (isset($_GET['cParentID']) && $_GET['cParentID'] > 0) {
         $path = Page::getByID($_GET['cParentID'])->getCollectionPath();
         $blogList->filterByPath($path);
     }
     //$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')");
     $blogList->filter(false, "ak_is_canonical_page < 1");
     if (empty($_GET['cParentID'])) {
         $sections = $this->get('sections');
         $keys = array_keys($sections);
         if (is_array($keys)) {
             foreach ($keys as $id) {
                 $fs .= ' OR ';
                 $path = Page::getByID($id)->getCollectionPath() . '/';
                 $fs .= "pp.cPath LIKE '{$path}%'";
             }
             $blogList->filter(false, "(pp.cPath LIKE '/!drafts/%'{$fs})");
         }
     }
     $blogList->displayUnapprovedPages();
     if (!empty($_GET['like'])) {
         $blogList->filterByName($_GET['like']);
     }
     if ($_GET['only_unaproved'] > 0) {
         $blogList->filter(false, "p.cIsActive != 1");
     }
     $blogList->setItemsPerPage($this->num);
     if (!empty($_GET['cat'])) {
         $cat = $_GET['cat'];
         $blogList->filter(false, "ak_blog_category LIKE '%\n{$cat}\n%'");
     }
     if (!empty($_GET['tag'])) {
         $tag = $_GET['tag'];
         $blogList->filter(false, "ak_tags LIKE '%\n{$tag}\n%'");
     }
     //$blogList->debug();
     $blogResults = $blogList->get();
     $this->set('blogResults', $blogResults);
     $this->set('blogList', $blogList);
     $this->set('cat_values', $this->getblogCats());
     $this->set('tag_values', $this->getblogTags());
     $this->set('sortOrder', $this->request('ccm_order_by_direction'));
     if ($this->request('ccm_order_by_direction') == 'asc') {
         $nextSort = 'desc';
     } else {
         $nextSort = 'asc';
     }
     $this->set('nextSort', $nextSort);
     $this->set('controller', $this);
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public function getPrevPost($c)
 {
     $cID = $c->getCollectionID();
     $this->loadblogSections();
     $pl = new ProblogList();
     $pl->setItemsPerPage(1);
     $pl->filter(false, "cv.cID < {$cID}");
     //$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'), '<=');
     $sections = $this->sections;
     $keys = array_keys($sections);
     if (is_array($keys)) {
         foreach ($keys as $id) {
             if ($fs) {
                 $fs .= ' OR ';
             }
             $path = Page::getByID($id)->getCollectionPath() . '/';
             $fs .= "pp.cPath LIKE '{$path}%'";
         }
         $pl->filter(false, "({$fs})");
     }
     $posts = $pl->get();
     $np = $posts[0];
     if ($np) {
         return Loader::helper('navigation')->getLinkToCollection($np);
     }
 }
Esempio n. 5
0
 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;
 }