]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #3085 added $vars to elgg_view_comments()
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 12 Mar 2011 14:52:09 +0000 (14:52 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 12 Mar 2011 14:52:09 +0000 (14:52 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8658 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/views.php
views/default/page/elements/comments.php

index 199f79daec18bdd0f5f4d656c85d6059f8bb8acc..a66b7748b7c3fbd2b27b4e83d26f43849508d648 100644 (file)
@@ -1075,32 +1075,30 @@ function elgg_view_friendly_time($time) {
  *
  * @tip Plugins can override the output by registering a handler
  * for the comments, $entity_type hook.  The handler is responsible
- * for formatting the comments and add comment form.
+ * for formatting the comments and the add comment form.
  *
  * @param ElggEntity $entity      The entity to view comments of
- * @param bool       $add_comment Include a form to add comments
+ * @param bool       $add_comment Include a form to add comments?
+ * @param array      $vars        Variables to pass to comment view
  *
- * @return string|false The HTML (etc) for the comments, or false on failure
+ * @return string|false Rendered comments or false on failure
  * @link http://docs.elgg.org/Entities/Comments
  * @link http://docs.elgg.org/Annotations/Comments
  */
-function elgg_view_comments($entity, $add_comment = true) {
+function elgg_view_comments($entity, $add_comment = true, array $vars = array()) {
        if (!($entity instanceof ElggEntity)) {
                return false;
        }
 
-       $comments = elgg_trigger_plugin_hook('comments', $entity->getType(), array('entity' => $entity), false);
-       if ($comments) {
-               return $comments;
-       } else {
-               $params = array(
-                       'entity' => $entity,
-                       'show_add_form' => $add_comment,
-                       'id' => "{$entity->getSubtype()}-comments",
-               );
-               $output = elgg_view('page/elements/comments', $params);
+       $vars['entity'] = $entity;
+       $vars['show_add_form'] = $add_comment;
+       $vars['class'] = elgg_extract('class', $vars, "{$entity->getSubtype()}-comments");
 
+       $output = elgg_trigger_plugin_hook('comments', $entity->getType(), $vars, false);
+       if ($output) {
                return $output;
+       } else {
+               return elgg_view('page/elements/comments', $vars);
        }
 }
 
index 3d44f5785f0d432b9b5597e83b17924602046938..1b0082ee471991fe50a0740e3db84a5a2ac0ea39 100644 (file)
@@ -5,6 +5,7 @@
  * @uses $vars['entity']        ElggEntity
  * @uses $vars['show_add_form'] Display add form or not
  * @uses $vars['id']            Optional id for the div
+ * @uses $vars['class']         Optional additional class for the div
  */
 
 $show_add_form = elgg_extract('show_add_form', $vars, true);
@@ -14,10 +15,15 @@ if (isset($vars['id'])) {
        $id = "id =\"{$vars['id']}\"";
 }
 
+$class = 'elgg-comments';
+if (isset($vars['class'])) {
+       $class = "$class {$vars['class']}";
+}
+
 // work around for deprecation code in elgg_view()
 unset($vars['internalid']);
 
-echo "<div $id class=\"elgg-comments\">";
+echo "<div $id class=\"$class\">";
 
 $options = array(
        'guid' => $vars['entity']->getGUID(),
@@ -28,7 +34,6 @@ if ($html) {
        echo '<h3>Comments</h3>';
        echo $html;
 }
-//echo strlen($html);
 
 if ($show_add_form) {
        $form_vars = array('name' => 'elgg_add_comment');