aboutsummaryrefslogtreecommitdiff
path: root/mod/bookmarks/views/default/widgets/bookmarks/view.php
blob: cbd0012bb3f43ae6f5634c5073cef8bc86b768a2 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

/**
 * Elgg bookmark widget view
 *
 * @package ElggBookmarks
 */
//get the num of shares the user want to display
$num = $vars['entity']->num_display;

$options = array(
	'type' => 'object',
	'subtype' => 'bookmarks',
	'container_guid' => $vars['entity']->owner_guid,
	'limit' => $num,
);
$bookmarks = elgg_get_entities($options);

$options['count'] = true;
$num_bookmarks = elgg_get_entities($options);


if ($bookmarks) {

	foreach ($bookmarks as $b) {

		//get the owner
		$owner = $b->getOwnerEntity();

		//get the time
		$friendlytime = elgg_view_friendly_time($b->time_created);

		//get the bookmark title
		$info = "<div class='river_object_bookmarks_create'><p class=\"shares_title\"><a href=\"{$b->address}\">{$b->title}</a></p></div>";

		//get the user details
		$info .= "<p class=\"shares_timestamp\"><small>{$friendlytime} ";

		//get the bookmark description
		if ($b->description) {
			$info .= "<a href=\"javascript:void(0);\" class=\"share_more_info\">" . elgg_echo('bookmarks:more') . "</a></small></p><div class=\"share_desc\"><p>{$b->description}</p></div>";
		} else {
			$info .= "</small></p>";
		}

		//display
		echo "<div class='ContentWrapper bookmarks'>";
		echo "<div class='shares_widget_content'>" . $info . "</div></div>";
	}

	if ($num_bookmarks > $num) {
		$user_inbox = elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner()->username;
		echo "<div class='ContentWrapper bookmarks more'><a href=\"{$user_inbox}\">" . elgg_echo('bookmarks:read') . "</a></div>";
	}
} else {
	echo "<div class='ContentWrapper'>" . elgg_echo("bookmarks:widget:description") . "</div>";
}