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();
 }
Example #2
0
 public function filter($viewtype = 'user-post', $profileId = null)
 {
     $ajax = new Disjax();
     $mainframe = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $sort = 'latest';
     $data = null;
     $pagination = null;
     $model = $this->getModel('Posts');
     $tagsModel = $this->getModel('Tags');
     switch ($viewtype) {
         case 'user-achievements':
             $profile = DiscussHelper::getTable('Profile');
             $profile->load($profileId);
             $data = $profile->getBadges();
             break;
         case 'user-tags':
             $data = $tagsModel->getTagCloud('', '', '', $profileId);
             break;
         case 'user-replies':
             $data = $model->getRepliesFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-unresolved':
             $data = $model->getUnresolvedFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-post':
         default:
             if (is_null($profileId)) {
                 break;
             }
             $model = $this->getModel('Posts');
             $data = $model->getPostsBy('user', $profileId);
             $data = DiscussHelper::formatPost($data);
             $pagination = $model->getPagination();
             break;
     }
     // replace the content
     $content = '';
     $tpl = new DiscussThemes();
     $tpl->set('profileId', $profileId);
     if ($viewtype == 'user-post' || $viewtype == 'user-replies' || $viewtype == 'user-unresolved') {
         $nextLimit = DiscussHelper::getListLimit();
         if ($nextLimit >= $pagination->total) {
             // $ajax->remove( 'dc_pagination' );
             $ajax->assign($viewtype . ' #dc_pagination', '');
         }
         $tpl->set('posts', $data);
         $content = $tpl->fetch('main.item.php');
         $ajax->assign($viewtype . ' #dc_list', $content);
         //reset the next start limi
         $ajax->value('pagination-start', $nextLimit);
         if ($nextLimit < $pagination->total) {
             $filterArr = array();
             $filterArr['viewtype'] = $viewtype;
             $filterArr['id'] = $profileId;
             $ajax->assign($viewtype . ' #dc_pagination', $pagination->getPagesLinks('profile', $filterArr, true));
         }
     } else {
         if ($viewtype == 'user-tags') {
             $tpl->set('tagCloud', $data);
             $content = $tpl->fetch('tags.item.php');
             $ajax->assign('discuss-tag-list', $content);
         } else {
             if ($viewtype == 'user-achievements') {
                 $tpl->set('badges', $data);
                 $content = $tpl->fetch('users.achievements.list.php');
                 $ajax->assign('user-achievements', $content);
             }
         }
     }
     $ajax->script('discuss.spinner.hide( "profile-loading" );');
     //$ajax->assign( 'sort-wrapper' , $sort );
     //$ajax->script( 'EasyDiscuss.$("#pagination-filter").val("'.$viewtype.'");');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . '").show();');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . ' #dc_pagination").show();');
     $ajax->send();
 }
Example #3
0
 /**
  * Ajax Call
  * Get raw content from db
  */
 public function ajaxGetRawContent($postId = null)
 {
     $djax = new Disjax();
     if (!empty($postId)) {
         $postTable = DiscussHelper::getTable('Post');
         $postTable->load($postId);
         $djax->value('reply_content_' . $postId, $postTable->content);
     }
     $djax->send();
     return;
 }