aboutsummaryrefslogtreecommitdiff
path: root/mod/riverdashboard/endpoint/get_comments.php
blob: 017591fa57a61b21cc875b118bc57a135a7720ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
 * Grabs more comments to display.
 */

require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");

$limit = get_input('limit', 25);
// 3 are displayed by default.
$offset = get_input('offset', 3);
$entity_guid = get_input('entity_guid');
if (!$entity = get_entity($entity_guid)) {
	exit;
}

// same deal as the main view...get the newest $limit, but reverse it to put the newest at the bottom.
if ($comments = get_annotations($entity_guid, "", "", 'generic_comment', "", "", $limit, $offset, "desc")) {
	$comments = array_reverse($comments);
}

foreach ($comments as $comment) {
	//get the comment owner
	$comment_owner = get_user($comment->owner_guid);
	//get the comment owner's profile url
	$comment_owner_url = $comment_owner->getURL();

	//display comment
	echo "<div class='river_comment clearfloat'>";
	echo "<span class='river_comment_owner_icon'>";
	echo elgg_view("profile/icon", array('entity' => $comment_owner, 'size' => 'tiny'));
	echo "</span>";

	//truncate comment to 150 characters and strip tags
	$contents = elgg_make_excerpt($comment->value, 150);

	echo "<div class='river_comment_contents'>";
	echo "<a href=\"{$comment_owner_url}\">" . $comment_owner->name . '</a>&nbsp;<span class="twitter_anywhere">' . parse_urls($contents) . '</span>';
	echo "<span class='entity_subtext'>" . elgg_view_friendly_time($comment->time_created) . "</span>";
	echo "</div></div>";
}