Exemple #1
0
 public function execute()
 {
     $post = $this->items;
     // Get the blogger object
     $post->author = $post->getAuthor();
     // Determines if the post is featured
     $post->isFeatured = $post->isFeatured();
     // determines if this is a teamblog post
     $post->team_id = $post->source_type == EASYBLOG_POST_SOURCE_TEAM ? $post->source_id : '0';
     // Format microblog postings
     if ($post->posttype) {
         $this->formatMicroblog($post);
     } else {
         $post->posttype = 'standard';
     }
     // We want to format all the content first before the theme displays the content
     $post->text = $post->getContent('entry');
     // Get the total comments
     $post->totalComments = EB::comment()->getCommentCount($post);
     // Get custom fields for this blog post
     $post->fields = $post->getCustomFields();
     // Assign the category object into the blog
     $post->categories = $post->getCategories();
     $post->category = $post->getPrimaryCategory();
     // Get the post assets
     $post->assets = $post->getAssets();
     // Retrieve list of tags
     $post->tags = $post->getTags();
     return $post;
 }
Exemple #2
0
 /**
  * Saves a comment item
  *
  * @since	4.0
  * @access	public
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // Check for acl rules.
     $this->checkAccess('comment');
     // Get the comment id
     $id = $this->input->get('id', 0, 'int');
     // Get the comment object
     $comment = EB::table('Comment');
     $comment->load($id);
     // Get the posted data
     $post = $this->input->getArray('post');
     // Bind the post data
     $comment->bind($post);
     // Try to save the comment
     $state = $comment->store();
     if (!$state) {
         $this->info->set($comment->getError(), 'error');
         return $this->app->redirect('index.php?option=com_easyblog&view=comments&layout=form&id=' . $comment->id);
     }
     // If the comment is published and no notifications sent yet, we need to send it out
     if ($comment->published && !$comment->sent) {
         $comment->comment = EB::comment()->parseBBCode($comment->comment);
         $comment->comment = nl2br($comment->comment);
         // Get the blog object associated with the comment
         $post = $comment->getBlog();
         // Process the emails now
         $comment->processEmails(false, $post);
         // Update the sent flag to sent, so we will never notify more than once
         $comment->updateSent();
     }
     $this->info->set('COM_EASYBLOG_COMMENTS_SAVED', 'success');
     $task = $this->getTask();
     $redirect = 'index.php?option=com_easyblog&view=comments';
     if ($task == 'apply') {
         $redirect .= '&layout=form&id=' . $comment->id;
     }
     return $this->app->redirect($redirect);
 }
Exemple #3
0
 /**
  * Format a list of stdclass objects into comment objects
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function format($items)
 {
     if (!$items) {
         return $items;
     }
     $my = JFactory::getUser();
     $model = EB::model('Comment');
     $comments = array();
     foreach ($items as $item) {
         $comment = EB::table('Comment');
         $comment->bind($item);
         // Load the author
         $comment->getAuthor();
         // Set the raw comments for editing
         $comment->raw = $comment->comment;
         // Set the comment depth
         if (isset($item->depth)) {
             $comment->depth = $item->depth;
         }
         // Format the comment
         $comment->comment = nl2br($comment->comment);
         $comment->comment = EB::comment()->parseBBCode($comment->comment);
         $comment->likesAuthor = '';
         $comment->likesCount = 0;
         $comment->isLike = false;
         if ($this->config->get('comment_likes')) {
             $data = EB::getLikesAuthors($comment->id, 'comment', $my->id);
             $comment->likesAuthor = $data->string;
             $comment->likesCount = $data->count;
             $comment->isLike = $model->isLikeComment($comment->id, $my->id);
         }
         // Determine if the current user liked the item or not
         $comments[] = $comment;
     }
     return $comments;
 }
Exemple #4
0
 /**
  * Retrieves the comment count for a post.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function getCommentCount($id)
 {
     $post = EB::post($id);
     $count = EB::comment()->getCommentCount($post);
     return $count;
 }
    ?>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showcommentcount', 0)) {
    ?>
        <div class="mod-cell pr-10">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
">
                <?php 
    echo EB::string()->getNoun('MOD_TOPBLOGS_COMMENTS', EB::comment()->getCommentCount($post), true);
    ?>
            </a>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showreadmore', true)) {
    ?>
        <div class="mod-cell">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
"><?php 
Exemple #6
0
 /**
  * Retrieves the formatted comment
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	string
  */
 public function getContent($truncate = true)
 {
     if ($truncate) {
         $text = JString::strlen($this->comment) > 150 ? JString::substr($this->comment, 0, 150) . JText::_('COM_EASYBLOG_ELLIPSES') : $this->comment;
     } else {
         $text = EB::comment()->parseBBCode($this->comment);
     }
     $text = strip_tags($text, '<img>');
     return $text;
 }
Exemple #7
0
						<li>
							<a href="<?php 
            echo EB::_('index.php?option=com_easyblog&view=dashboard&layout=pending');
            ?>
">
								<i class="fa fa-ticket"></i> <?php 
            echo JText::_('COM_EASYBLOG_TOOLBAR_BLOG_POSTS_PENDING');
            ?>
							</a>
						</li>
						<?php 
        }
        ?>

						<?php 
        if ($this->acl->get('manage_comment') && EB::comment()->isBuiltin()) {
            ?>
						<li>
							<a href="<?php 
            echo EB::_('index.php?option=com_easyblog&view=dashboard&layout=comments');
            ?>
">
								<i class="fa fa-comments"></i> <?php 
            echo JText::_('COM_EASYBLOG_TOOLBAR_COMMENTS');
            ?>
							</a>
						</li>
						<?php 
        }
        ?>
				<?php 
        }
        ?>

				<div class="eb-post-comment-text">
					<?php 
        if (JString::strlen($comment->comment) > 130) {
            ?>
						<?php 
            echo JString::substr(strip_tags(EB::comment()->parseBBCode($comment->comment)), 0, 130);
            ?>
					<?php 
        } else {
            ?>
					<?php 
            echo strip_tags(EB::comment()->parseBBCode($comment->comment));
            ?>
					<?php 
        }
        ?>
				</div>

				<a href="<?php 
        echo $post->getPermalink();
        ?>
#comment-<?php 
        echo $comment->id;
        ?>
" class="eb-post-comment-date text-muted"><?php 
        echo $comment->getCreated()->format(JText::_('COM_EASYBLOG_DATE_FORMAT_STATISTICS'));
        ?>
Exemple #9
0
 /**
  * Retrieves total number of comments the author made on the site.
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getCommentsCount()
 {
     if (!EB::comment()->isBuiltin()) {
         return 0;
     }
     $db = EB::db();
     $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__easyblog_comment') . ' ' . 'WHERE ' . $db->nameQuote('created_by') . '=' . $db->Quote($this->id) . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote(1);
     $db->setQuery($query);
     return $db->loadResult();
 }
Exemple #10
0
 public static function processComment($data, $row, $params)
 {
     $row->comment_id = isset($data->comment_id) ? $data->comment_id : '';
     $row->comment = isset($data->comment) ? $data->comment : '';
     $row->commentor = isset($data->commentor) ? $data->commentor : '0';
     $row->comment_title = isset($data->comment_title) ? $data->comment_title : '';
     $row->commentor_name = isset($data->commentor_name) ? $data->commentor_name : '';
     if ($params->get('showlatestcomment', true)) {
         if ($row->commentor != 0) {
             $commentor = EB::user($row->commentor);
             $row->commentor = $commentor;
         } else {
             $obj = new stdClass();
             $obj->id = '0';
             $obj->nickname = !empty($row->commentor_name) ? $row->commentor_name : JText::_('COM_EASYBLOG_GUEST');
             $commentor = EB::table('Profile');
             $commentor->bind($obj);
             $row->commentor = $commentor;
         }
     }
     $comment = strip_tags($row->comment);
     $commentLength = JString::strlen($comment);
     $comment = '"' . $comment . '"';
     $comment = EB::comment()->parseBBCode($comment);
     $row->comment = $commentLength > 150 ? JString::substr($comment, 0, 150) . '...' : $comment;
     return $row;
 }
Exemple #11
0
 /**
  * Retrieves a list of comments from a blog post
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getBlogComment($id, $limitFrontEnd = 0, $sort = 'asc', $lite = false)
 {
     $db = EB::db();
     $config = EB::getConfig();
     $sort = $config->get('comment_sort', 'asc');
     if ($lite) {
         $query = 'SELECT a.* FROM `#__easyblog_comment` a';
         $query .= ' INNER JOIN #__users AS c ON a.`created_by` = c.`id`';
         $query .= ' WHERE a.`post_id` = ' . $db->Quote($id);
         $query .= ' AND a.`published` = 1';
     } else {
         $query = 'SELECT a.*, (count(b.id) - 1) AS `depth` FROM `#__easyblog_comment` AS a';
         $query .= ' INNER JOIN `#__easyblog_comment` AS b';
         $query .= ' LEFT JOIN `#__users` AS c ON a.`created_by` = c.`id`';
         $query .= ' WHERE a.`post_id` = ' . $db->Quote($id);
         $query .= ' AND b.`post_id` = ' . $db->Quote($id);
         $query .= ' AND a.`published` = 1';
         $query .= ' AND b.`published` = 1';
         $query .= ' AND a.`lft` BETWEEN b.`lft` AND b.`rgt`';
         $query .= ' GROUP BY a.`id`';
     }
     // prepare the query to get total comment
     $queryTotal = 'SELECT COUNT(1) FROM (';
     $queryTotal .= $query;
     $queryTotal .= ') AS x';
     // continue the query.
     $limit = $this->getState('limit');
     $limitstart = $this->getState('limitstart');
     switch ($sort) {
         case 'desc':
             $query .= ' ORDER BY a.`rgt` desc';
             break;
         default:
             $query .= ' ORDER BY a.`lft` asc';
             break;
     }
     if ($limitFrontEnd > 0) {
         $query .= ' LIMIT ' . $limitFrontEnd;
     } else {
         $query .= ' LIMIT ' . $limitstart . ',' . $limit;
     }
     if ($limitFrontEnd <= 0) {
         $db->setQuery($queryTotal);
         $this->_total = $db->loadResult();
         jimport('joomla.html.pagination');
         $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
     }
     // the actual content sql
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         return $result;
     }
     // Format the comments
     $result = EB::comment()->format($result);
     return $result;
 }
Exemple #12
0
 private function prepareNewCommentStream(&$item)
 {
     $comment = EB::table('Comment');
     $comment->load($item->contextId);
     // Format the likes for the stream
     $likes = Foundry::likes();
     $likes->get($comment->id, 'blog', 'comments');
     $item->likes = $likes;
     $url = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, true, null, false, true);
     // Apply comments on the stream
     $item->comments = Foundry::comments($item->contextId, 'blog', 'comments', SOCIAL_APPS_GROUP_USER, array('url' => $url));
     $post = EB::post($comment->post_id);
     $date = EB::date($post->created);
     // Parse the bbcode from EasyBlog
     $comment->comment = EB::comment()->parseBBCode($comment->comment);
     $this->set('comment', $comment);
     $this->set('date', $date);
     $this->set('permalink', $url);
     $this->set('blog', $post);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     $item->opengraph->addDescription($comment->comment);
 }
Exemple #13
0
 /**
  * Get total number of comments for this blog post
  *
  * @access	public
  * @param	null
  * @return	int
  */
 public function getTotalComments()
 {
     if (!isset(self::$commentCounts[$this->id])) {
         $count = EB::comment()->getCommentCount($this);
         self::$commentCounts[$this->id] = $count;
     }
     return self::$commentCounts[$this->id];
 }
Exemple #14
0
 /**
  * Allows caller to update comments via ajax
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function update()
 {
     $ajax = EB::ajax();
     // Get the comment object
     $id = $this->input->get('id', 0, 'int');
     $comment = EB::table('Comment');
     $comment->load($id);
     if (!$id || !$comment->id) {
         return $ajax->reject(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_COMMENT'));
     }
     if (!EB::isSiteAdmin() && ($this->acl->get('edit_comment') || $this->my->id != $comment->created_by) && !$this->acl->get('manage_comment')) {
         return $ajax->reject(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_COMMENT'));
     }
     // Get the updated comment
     $message = $this->input->get('message', '', 'default');
     if (!$message) {
         return $ajax->reject(JText::_('COM_EASYBLOG_COMMENTS_EMPTY_COMMENT_NOT_ALLOWED'));
     }
     $comment->comment = $message;
     // Update the comment
     $comment->store();
     // Format the output back
     $output = nl2br($message);
     $output = EB::comment()->parseBBCode($output);
     return $ajax->resolve($output, $message);
 }
Exemple #15
0
 /**
  *
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function insetCommentActivity($comment, EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return false;
     }
     // We do not want to add activities if new comment activity is disabled.
     if (!$this->config->get('integrations_jomsocial_comment_new_activity')) {
         return false;
     }
     $command = 'easyblog.comment.add';
     // Get the post title
     $title = $this->getPostTitle($post);
     // Get the permalink
     $permalink = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false, true) . '#comment-' . $comment->id;
     // Get the content
     $content = '';
     if ($this->config->get('integrations_jomsocial_submit_content')) {
         $content = $comment->comment;
         $content = EB::comment()->parseBBCode($content);
         $content = nl2br($content);
         $content = strip_tags($content);
         $content = JString::substr($content, 0, $this->config->get('integrations_jomsocial_comments_length'));
     }
     $obj = new stdClass();
     $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_COMMENT_ADDED', $permalink, $title);
     if (!$comment->created_by) {
         $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_GUEST_COMMENT_ADDED', $permalink, $title);
     }
     $obj->content = $content;
     $obj->cmd = $command;
     $obj->actor = $comment->created_by;
     $obj->target = 0;
     $obj->app = 'easyblog';
     $obj->cid = $comment->id;
     if ($this->config->get('integrations_jomsocial_activity_likes')) {
         $obj->like_id = $comment->id;
         $obj->like_type = 'com_easyblog.comments';
     }
     if ($this->config->get('integrations_jomsocial_activity_comments')) {
         $obj->comment_id = $comment->id;
         $obj->comment_type = 'com_easyblog.comments';
     }
     // add JomSocial activities
     CFactory::load('libraries', 'activities');
     CActivityStream::add($obj);
 }
Exemple #16
0
 /**
  * Get total number of comments for this blog post
  *
  * @access	public
  * @param	null
  * @return	int
  */
 public function getTotalComments()
 {
     static $comments = array();
     if (!isset($comments[$this->id])) {
         $count = EB::comment()->getCommentCount($this);
         $comments[$this->id] = $count;
     }
     return $comments[$this->id];
 }
Exemple #17
0
 /**
  * Caches the comment counters
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function cacheCommentCount($postIds = array())
 {
     // we only cache the comment if built-in comment enabled.
     if (!EB::comment()->isBuiltin()) {
         return;
     }
     $model = EB::model('Comment');
     $counters = $model->preloadCommentCount($postIds);
     // Determines if system is running on built in comments
     $builtIn = EB::comment()->isBuiltin();
     foreach ($postIds as $id) {
         // We can only cache this if the comment is built in
         if ($builtIn) {
             $total = isset($counters[$id]) ? $counters[$id] : 0;
         } else {
             $post = $this->get($id, 'post');
             $tmppost = EB::post();
             $tmppost->bind($post, array('force' => true));
             $total = EB::comment()->getCommentCount($tmppost);
         }
         EasyBlogPost::$commentCounts[$id] = $total;
     }
 }
Exemple #18
0
 /**
  * Prepares the comment output
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function prepareComments(&$blog)
 {
     $config = EB::config();
     $my = JFactory::getUser();
     $result = new stdClass();
     // add checking if comment system disabled by site owner
     if ($this->config->get('main_comment') && $blog->allowcomment) {
         // Retrieve blog comments
         $comments = EB::comment()->getBlogComment($blog->id);
         $result->pagination = EB::comment()->pagination;
         $result->comments = $comments;
     }
     // Set the total number of comments for this blog post
     $blog->totalComments = EB::comment()->getCommentCount($blog);
     return $result;
 }
Exemple #19
0
        <?php 
}
?>
    </div>

    <?php 
echo $adsense->beforecomments;
?>

    <?php 
echo $post->event->afterDisplayContent;
?>

    <?php 
if ($this->config->get('main_comment') && $post->allowcomment && $this->entryParams->get('post_comment_form', true)) {
    ?>
        <?php 
    echo EB::comment()->getCommentHTML($post);
    ?>
    <?php 
}
?>
</div>

<div class="eb-adsense-foot clearfix">
    <?php 
echo $adsense->footer;
?>
</div>