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


PHP DiscussHelper::formatReplies方法代码示例

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


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

示例1: ajaxReadmoreReplies

 function ajaxReadmoreReplies($limitstart = null, $sorting = null, $type = 'questions', $parentId = null, $filter = null, $category = null)
 {
     $ajax = new Disjax();
     $model = $this->getModel('Posts');
     $limitstart = (int) $limitstart;
     $mainframe = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     $posts = $model->getReplies($parentId, $sorting, $limitstart);
     $pagination = $model->getPagination($parentId, $sorting);
     $my = JFactory::getUser();
     $posts = DiscussHelper::formatPost($posts);
     $parent = DiscussHelper::getTable('Post');
     $parent->load($parentId);
     //check all the 'can' or 'canot' here.
     $acl = DiscussHelper::getHelper('ACL');
     $isMainLocked = $parent->islock ? true : false;
     $canDelete = false;
     $canTag = false;
     $canReply = $acl->allowed('add_reply', '0');
     if ($config->get('main_allowdelete', 2) == 2) {
         $canDelete = $isSiteAdmin ? true : false;
     } else {
         if ($config->get('main_allowdelete', 2) == 1) {
             $canDelete = $acl->allowed('delete_reply', '0');
         }
     }
     $category = DiscussHelper::getTable('Category');
     $category->load($category);
     $posts = DiscussHelper::formatReplies($posts, $category);
     $template = new DiscussThemes();
     $template->set('replies', $posts);
     $template->set('config', $config);
     $template->set('canReply', $canReply);
     $template->set('canDelete', $canDelete);
     $template->set('isMainLocked', $isMainLocked);
     //$template->set( 'isMine'		, false );
     //$template->set( 'isAdmin'		, false );
     $template->set('isMine', DiscussHelper::isMine($parent->user_id));
     $template->set('isAdmin', DiscussHelper::isSiteAdmin());
     $html = $template->fetch('reply.item.php');
     $nextLimit = $limitstart + DiscussHelper::getListLimit();
     if ($nextLimit >= $pagination->total) {
         $ajax->remove('dc_pagination a');
     }
     $ajax->value('pagination-start', $nextLimit);
     $ajax->script('EasyDiscuss.$("#dc_response").children().children( ":last").addClass( "separator" );');
     $ajax->append('dc_response tbody', $html);
     $ajax->send();
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:49,代码来源:view.ajax.php

示例2: getReplies

 private function getReplies($category, $post, $sort, $answer)
 {
     $config = DiscussHelper::getConfig();
     $postsModel = DiscussHelper::getModel('Posts');
     $my = JFactory::getUser();
     // Get a list of replies for this discussion
     $replies = array();
     $hasMoreReplies = false;
     $totalReplies = 0;
     $readMoreURI = '';
     if ($category->canViewReplies()) {
         $repliesLimit = $config->get('layout_replies_list_limit');
         $totalReplies = $postsModel->getTotalReplies($post->id);
         $hasMoreReplies = false;
         $limitstart = null;
         $limit = null;
         if ($repliesLimit && !JRequest::getBool('viewallreplies')) {
             $limit = $repliesLimit;
             $hasMoreReplies = $totalReplies - $repliesLimit > 0;
         }
         $replies = $postsModel->getReplies($post->id, $sort, $limitstart, $limit);
         if (count($replies) > 0) {
             $repliesIds = array();
             $authorIds = array();
             foreach ($replies as $reply) {
                 $repliesIds[] = $reply->id;
                 $authorIds[] = $reply->user_id;
             }
             if ($answer) {
                 if (is_array($answer)) {
                     $answer = $answer[0];
                 }
                 $repliesIds[] = $answer->id;
                 $authorIds[] = $answer->user_id;
             }
             $post->loadBatch($repliesIds);
             $post->setAttachmentsData('replies', $repliesIds);
             // here we include the discussion id into the array as well.
             $repliesIds[] = $post->id;
             $authorIds[] = $post->user_id;
             $post->setLikeAuthorsBatch($repliesIds);
             DiscussHelper::getHelper('Post')->setIsLikedBatch($repliesIds);
             $post->setPollQuestionsBatch($repliesIds);
             $post->setPollsBatch($repliesIds);
             $post->setLikedByBatch($repliesIds, $my->id);
             $post->setVoterBatch($repliesIds);
             $post->setHasVotedBatch($repliesIds);
             $post->setTotalCommentsBatch($repliesIds);
             $commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
             $post->setCommentsBatch($repliesIds, $commentLimit);
             // Reduce SQL queries by pre-loading all author object.
             $authorIds = array_unique($authorIds);
             $profile = DiscussHelper::getTable('Profile');
             $profile->init($authorIds);
         }
         $readMoreURI = JURI::getInstance()->toString();
         $delimiteter = JString::strpos($readMoreURI, '&') ? '&' : '?';
         $readMoreURI = $hasMoreReplies ? $readMoreURI . $delimiteter . 'viewallreplies=1' : $readMoreURI;
         // Format the reply items.
         $replies = DiscussHelper::formatReplies($replies, $category);
     }
     $data = new stdClass();
     $data->replies = $replies;
     $data->total = $totalReplies;
     $data->more = $hasMoreReplies;
     $data->readmore = $readMoreURI;
     return $data;
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:68,代码来源:view.html.php

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