Example #1
0
 public function sort($sort = null, $filter = null, $categoryId = null)
 {
     $ajax = new Disjax();
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $activeCategory = DiscussHelper::getTable('Category');
     $activeCategory->load($categoryId);
     //todo: check against the config
     $showAllPosts = 'all';
     $postModel = $this->getModel('Posts');
     $posts = $postModel->getData(true, $sort, null, $filter, $categoryId, null, $showAllPosts);
     $pagination = $postModel->getPagination('0', $sort, $filter, $categoryId, $showAllPosts);
     $posts = DiscussHelper::formatPost($posts);
     $nextLimit = DiscussHelper::getListLimit();
     if ($nextLimit >= $pagination->total) {
         $ajax->remove('dc_pagination .pagination-wrap');
     }
     $tpl = new DiscussThemes();
     $tpl->set('posts', $posts);
     $content = $tpl->fetch('main.item.php');
     //reset the next start limi
     $ajax->value('pagination-start', $nextLimit);
     if ($nextLimit < $pagination->total) {
         $filterArr = array();
         $filterArr['filter'] = $filter;
         $filterArr['category_id'] = $categoryId;
         $filterArr['sort'] = $sort;
         $ajax->assign('dc_pagination', $pagination->getPagesLinks('index', $filterArr, true));
     }
     $ajax->script('discuss.spinner.hide( "index-loading" );');
     $ajax->script('EasyDiscuss.$("#pagination-sorting").val("' . $sort . '");');
     $ajax->assign('dc_list', $content);
     $ajax->script('EasyDiscuss.$("#dc_list").show();');
     $ajax->script('EasyDiscuss.$("#dc_pagination").show();');
     $ajax->send();
 }