aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/views.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-12 14:52:09 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-12 14:52:09 +0000
commit538da56bb1d9acf787362fe0f34747118b00b261 (patch)
tree4b5351b5d4d1ba641dd3b9145332f2b881bf9db9 /engine/lib/views.php
parent0d35e43b9125063af76ef34caabac9dfc95eae01 (diff)
downloadelgg-538da56bb1d9acf787362fe0f34747118b00b261.tar.gz
elgg-538da56bb1d9acf787362fe0f34747118b00b261.tar.bz2
Refs #3085 added $vars to elgg_view_comments()
git-svn-id: http://code.elgg.org/elgg/trunk@8658 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/views.php')
-rw-r--r--engine/lib/views.php26
1 files changed, 12 insertions, 14 deletions
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 199f79dae..a66b7748b 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -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);
}
}