当前位置: 首页>>代码示例>>PHP>>正文


PHP DiscussHelper::getDefaultRepliesSorting方法代码示例

本文整理汇总了PHP中DiscussHelper::getDefaultRepliesSorting方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::getDefaultRepliesSorting方法的具体用法?PHP DiscussHelper::getDefaultRepliesSorting怎么用?PHP DiscussHelper::getDefaultRepliesSorting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DiscussHelper的用法示例。


在下文中一共展示了DiscussHelper::getDefaultRepliesSorting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $config = DiscussHelper::getConfig();
     // Sorting and filters.
     $sort = JRequest::getString('sort', DiscussHelper::getDefaultRepliesSorting());
     $filteractive = JRequest::getString('filter', 'allposts');
     $id = JRequest::getInt('id');
     $acl = DiscussHelper::getHelper('ACL');
     // Add noindex for print view by default.
     if (JRequest::getInt('print') == 1) {
         $doc->setMetadata('robots', 'noindex,follow');
     }
     // Get current logged in user.
     $my = JFactory::getUser();
     // Determine if the logged in user is an admin.
     $isAdmin = DiscussHelper::isSiteAdmin();
     // Load the post table out.
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     // Need raw content for later use
     $post->content_raw = $post->content;
     // If id is not found, we need to redirect gracefully.
     if (!$state || !$post->published || !$id) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     if ($post->private && $my->id != $post->user_id && !$isAdmin && !DiscussHelper::isModerator($post->category_id, $my->id)) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // Check whether this is a valid discussion
     if ($post->parent_id != 0 || $post->published == DISCUSS_ID_PENDING && (!$isAdmin && $post->user_id != $my->id)) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // check the discussion is under moderation
     if ($post->published == 4 && !DiscussHelper::isModerator($post->category_id, $my->id) && !$isAdmin) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOTICE_POST_SUBMITTED_UNDER_MODERATION'), 'error');
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
         $app->close();
     }
     // Load the category.
     $category = DiscussHelper::getTable('Category');
     $category->load((int) $post->category_id);
     if ($post->category_id && !$category->canAccess()) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // Add pathway for category here.
     DiscussHelper::getHelper('Pathway')->setCategoryPathway($category);
     // Set breadcrumbs for this discussion.
     $this->setPathway($this->escape($post->title));
     // Mark as viewed for notifications.
     $this->logView();
     // Update hit count for this discussion.
     $post->hit();
     // Set page headers
     $this->setPageHeaders($post);
     // Before sending the title and content to be parsed, we need to store this temporarily in case it needs to be accessed.
     $post->title_clear = $post->title;
     // Filter badwords
     $post->title = DiscussHelper::wordFilter($post->title);
     $post->content = DiscussHelper::wordFilter($post->content);
     // Get the tags for this discussion
     $postsTagsModel = $this->getModel('PostsTags');
     $tags = $postsTagsModel->getPostTags($id);
     // Get adsense codes here.
     $adsense = DiscussHelper::getAdsense();
     $postsModel = DiscussHelper::getModel('Posts');
     // Get the answer for this discussion.
     $answer = $postsModel->getAcceptedReply($post->id);
     // Format the answer object.
     if ($answer) {
         $answer = DiscussHelper::formatReplies($answer, $category);
         $answer = $answer[0];
     }
     // Get a list of replies for this post.
     $data = $this->getReplies($category, $post, $sort, $answer);
     $replies = $data->replies;
     $totalReplies = $data->total;
     $hasMoreReplies = $data->more;
     $readMoreURI = $data->readmore;
     // Get comments for the post
     $commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
     $post->comments = false;
     if ($config->get('main_commentpost')) {
         $comments = $post->getComments($commentLimit);
         $post->comments = DiscussHelper::formatComments($comments);
     }
     // get reply comments count
     $post->commentsCount = $post->getTotalComments();
     // Get the post access object here.
     $access = $post->getAccess($category);
     $post->access = $access;
     // Add custom values.
     $postOwner = $post->getOwner();
     $profileTable = DiscussHelper::getTable('Profile');
     if ($postOwner->id) {
         $profileTable->load($postOwner->id);
     }
     $post->user = $profileTable;
     // update user's post read flag
//.........这里部分代码省略.........
开发者ID:pguilford,项目名称:vcomcc,代码行数:101,代码来源:view.html.php

示例2: getReplies

 /**
  * Get replies based on pagination load more
  *
  * @since   3.0
  * @access  public
  * @param   null
  * @author  Jason Rey <jasonrey@stackideas.com>
  */
 public function getReplies()
 {
     $theme = new DiscussThemes();
     $ajax = DiscussHelper::getHelper('Ajax');
     $model = DiscussHelper::getModel('Posts');
     $config = DiscussHelper::getConfig();
     $id = JRequest::getInt('id', 0);
     $sort = JRequest::getString('sort', DiscussHelper::getDefaultRepliesSorting());
     $start = JRequest::getInt('start', 0);
     $total = $model->getTotalReplies($id);
     if ($start >= $total) {
         return $ajax->reject();
     }
     $replies = $model->getReplies($id, $sort, $start, $config->get('layout_replies_list_limit'));
     if (empty($replies)) {
         return $ajax->reject();
     }
     $count = count($replies);
     $nextCycle = $start + $count < $total;
     // Load the category
     $post = DiscussHelper::getTable('Posts');
     $post->load($id);
     $category = DiscussHelper::getTable('Category');
     $category->load((int) $post->category_id);
     $replies = DiscussHelper::formatReplies($replies, $category);
     $html = '';
     foreach ($replies as $reply) {
         $theme->set('category', $category);
         $theme->set('question', $post);
         $theme->set('post', $reply);
         $html .= '<li>' . $theme->fetch('post.reply.item.php') . '</li>';
     }
     return $ajax->resolve($html, $nextCycle);
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:42,代码来源:view.ajax.php


注:本文中的DiscussHelper::getDefaultRepliesSorting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。