}
}
-/**
- * View the latest comments on a user's content
- *
- * @todo - get_annotations is due to be rewritten so update code and possibly parameters
- *
- * @param <type> $owner_guid
- * @param <type> $type
- * @param <type> $subtype
- * @param <type> $number
- *
- * @return string
- * @since 1.8.0
- */
-function elgg_view_latest_comments($owner_guid, $type = 'object', $subtype = '', $number = 4) {
- $title = elgg_echo('generic_comments:latest');
- $options = array(
- 'annotation_name' => 'generic_comment',
- 'owner_guid' => $owner_guid,
- 'reverse_order_by' => true,
- 'limit' => $number
-
- );
- $comments = elgg_get_annotations($options);
-
- $body = elgg_view('page/components/list', array(
- 'items' => $comments,
- 'pagination' => false,
- 'list_class' => 'elgg-latest-comments',
- ));
-
- return elgg_view_module('aside', $title, $body);
-}
-
/**
* Wrapper function for the image block display pattern.
*
'generic_comment:notfound' => "Sorry, we could not find the specified item.",
'generic_comment:notdeleted' => "Sorry, we could not delete this comment.",
'generic_comment:failure' => "An unexpected error occurred when adding your comment. Please try again.",
+ 'generic_comment:none' => 'No comments',
'generic_comment:email:subject' => 'You have a new comment!',
'generic_comment:email:body' => "You have a new comment on your item \"%s\" from %s. It reads:
// fetch & display latest comments
if ($vars['page'] == 'all') {
- echo elgg_view_latest_comments(0, 'object', 'blog');
+ echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'blog',
+ ));
} elseif ($vars['page'] == 'owner') {
- // @todo - what we want is the latest comments on this user's blog posts - elgg does not support this
- echo elgg_view_latest_comments(elgg_get_page_owner_guid(), 'object', 'blog');
+ echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'blog',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+ ));
}
echo elgg_view('blog/sidebar/archives', $vars);
);
$html = elgg_list_annotations($options);
if ($html) {
- echo '<h3>Comments</h3>';
+ echo '<h3>' . elgg_echo('comments') . '</h3>';
echo $html;
}
--- /dev/null
+<?php
+/**
+ * Display the latest related comments
+ *
+ * Generally used in a sidebar
+ *
+ * @uses $vars['subtypes'] Object subtype string or array of subtypes
+ * @uses $vars['owner_guid'] The owner of the content being commented on
+ * @uses $vars['limit'] The number of comments to display
+ */
+
+$options = array(
+ 'annotation_name' => 'generic_comment',
+ 'owner_guid' => elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE),
+ 'reverse_order_by' => true,
+ 'limit' => elgg_extract('limit', $vars, 4),
+ 'type' => 'object',
+ 'subtypes' => elgg_extract('subtypes', $vars, ELGG_ENTITIES_ANY_VALUE),
+);
+
+$title = elgg_echo('generic_comments:latest');
+$comments = elgg_get_annotations($options);
+if ($comments) {
+ $body = elgg_view('page/components/list', array(
+ 'items' => $comments,
+ 'pagination' => false,
+ 'list_class' => 'elgg-latest-comments',
+ ));
+} else {
+ $body = '<p>' . elgg_echo('generic_comment:none') . '</p>';
+}
+
+echo elgg_view_module('aside', $title, $body);