aboutsummaryrefslogtreecommitdiff
path: root/mod/riverdashboard/views/default/river
diff options
context:
space:
mode:
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-10 16:32:05 +0000
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-10 16:32:05 +0000
commit9456cf380a51d4863dd0ee96499763bb32f54284 (patch)
tree510773dbfd611deb6c399958e728f735d16a2ed2 /mod/riverdashboard/views/default/river
parent90c80171f9f089b4f2448c496e72d33432b5d724 (diff)
downloadelgg-9456cf380a51d4863dd0ee96499763bb32f54284.tar.gz
elgg-9456cf380a51d4863dd0ee96499763bb32f54284.tar.bz2
the beginnings of a new activity river with ajax notification and conversation clustering.
git-svn-id: http://code.elgg.org/elgg/trunk@5344 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/riverdashboard/views/default/river')
-rw-r--r--mod/riverdashboard/views/default/river/dashboard.php19
-rw-r--r--mod/riverdashboard/views/default/river/item/list.php59
-rw-r--r--mod/riverdashboard/views/default/river/item/wrapper.php119
-rw-r--r--mod/riverdashboard/views/default/river/relationship/friend/create.php36
-rw-r--r--mod/riverdashboard/views/default/river/sitemessage/create.php18
5 files changed, 233 insertions, 18 deletions
diff --git a/mod/riverdashboard/views/default/river/dashboard.php b/mod/riverdashboard/views/default/river/dashboard.php
new file mode 100644
index 000000000..5fe7c35d3
--- /dev/null
+++ b/mod/riverdashboard/views/default/river/dashboard.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Elgg river for dashboard.
+ */
+
+/// Extract the river
+$river = $vars['river'];
+?>
+<div id="river">
+<?php
+if (($river) && (count($river)>0)) {
+ foreach ($river as $r) {
+ echo $r;
+ }
+} else {
+ echo elgg_echo('river:widget:noactivity');
+}
+?>
+</div><!-- /river --> \ No newline at end of file
diff --git a/mod/riverdashboard/views/default/river/item/list.php b/mod/riverdashboard/views/default/river/item/list.php
new file mode 100644
index 000000000..25774ff08
--- /dev/null
+++ b/mod/riverdashboard/views/default/river/item/list.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ */
+?>
+<div class="river_item_list">
+<?php
+ if (isset($vars['items']) && is_array($vars['items'])) {
+
+ $i = 0;
+ if (!empty($vars['items'])) {
+ foreach($vars['items'] as $item) {
+ echo elgg_view_river_item($item);
+ $i++;
+ if ($i >= $vars['limit']) {
+ break;
+ }
+ }
+ }
+ }
+
+ if ($vars['pagination'] !== false) {
+ $baseurl = $_SERVER['REQUEST_URI'];
+ $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl);
+
+ $nav = '';
+
+ if (sizeof($vars['items']) > $vars['limit']) {
+ $newoffset = $vars['offset'] + $vars['limit'];
+ $urladdition = 'offset='.$newoffset;
+ if (substr_count($baseurl,'?')) {
+ $nexturl = $baseurl . '&' . $urladdition;
+ } else {
+ $nexturl=$baseurl . '?' . $urladdition;
+ }
+
+ $nav .= '<a class="back" href="'.$nexturl.'">&laquo; ' . elgg_echo('previous') . '</a> ';
+ }
+
+ if ($vars['offset'] > 0) {
+ $newoffset = $vars['offset'] - $vars['limit'];
+ if ($newoffset < 0) {
+ $newoffset = 0;
+ }
+ $urladdition = 'offset='.$newoffset;
+ if (substr_count($baseurl,'?')) {
+ $prevurl=$baseurl . '&' . $urladdition;
+ } else {
+ $prevurl=$baseurl . '?' . $urladdition;
+ }
+
+ $nav .= '<a class="forward" href="'.$prevurl.'">' . elgg_echo('next') . ' &raquo;</a> ';
+ }
+
+ if (!empty($nav)) {
+ echo '<div class="river_pagination"><p>'.$nav.'</p><div class="clearfloat"></div></div>';
+ }
+ }
+?>
+</div> \ No newline at end of file
diff --git a/mod/riverdashboard/views/default/river/item/wrapper.php b/mod/riverdashboard/views/default/river/item/wrapper.php
new file mode 100644
index 000000000..1aa508d99
--- /dev/null
+++ b/mod/riverdashboard/views/default/river/item/wrapper.php
@@ -0,0 +1,119 @@
+<?php
+/**
+ * Elgg river item wrapper.
+ * Wraps all river items.
+ */
+
+//set required variables
+$object = get_entity($vars['item']->object_guid);
+//get object url
+$object_url = $object->getURL();
+//user
+//if displaying on the profile get the object owner, else the subject_guid
+if(get_context() == 'profile' && $object->getSubtype() == 'thewire')
+ $user = get_entity($object->owner_guid);
+else
+ $user = get_entity($vars['item']->subject_guid);
+
+//get the right annotation type
+//*todo - use the same for comments, everywhere e.g. comment
+switch($vars['item']->subtype){
+ case 'thewire':
+ $annotation_comment = 'wire_reply';
+ break;
+ default:
+ $annotation_comment = 'generic_comment';
+ break;
+}
+
+//count comment annotations
+$comment_count = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, $annotation_comment);
+
+//count like annotations
+$likes = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, "likes");
+
+//get last two comments display
+$get_comments = get_annotations($vars['item']->object_guid, "", "", $annotation_comment, "", "", 3, 0, "desc");
+
+if($get_comments){
+ //reverse the array so we can display comments in the right order
+ $get_comments = array_reverse($get_comments);
+}
+
+//minus two off the comment total as we display two by default
+if($comment_count < 3)
+ $num_comments = 0;
+else
+ $num_comments = $comment_count - 3;
+?>
+<div class="river_item">
+ <!-- avatar -->
+ <span class="river_item_useravatar" style="float:left;margin:0 10px 10px 0;">
+ <?php
+ echo elgg_view("profile/icon",array('entity' => $user, 'size' => 'small'));
+ ?>
+ </span>
+ <!-- body contents, generated by the river view in each plugin -->
+ <?php
+ echo $vars['body'];
+ ?>
+ <div class="clearfloat"></div>
+ <!-- display comments and likes if on the dashboard/live feed -->
+ <div class="river_item_annotation">
+ <?php
+ //display the number of comments and likes if there are any
+ if($num_comments != 0){
+ echo "<div class='river_more_comments'><span class='more_comments'>";
+ //set the correct context comment or comments
+ if($num_comments == 1)
+ echo "<a href=\"{$object_url}\">+{$num_comments} more comment</a>";
+ else
+ echo "<a href=\"{$object_url}\">+{$num_comments} more comments</a>";
+
+ echo "</span></div>";
+ }
+ //display latest 2 comments if there are any
+ if($get_comments){
+ $counter = 0;
+ $background = "";
+ echo "<div class='river_comments'>";
+ foreach($get_comments as $gc){
+ //get the comment owner
+ $comment_owner = get_user($gc->owner_guid);
+ //get the comment owner's profile url
+ $comment_owner_url = $comment_owner->getURL();
+ // color-code each of the 3 comments
+ if( ($counter == 2 && $comment_count >= 4) || ($counter == 1 && $comment_count == 2) || ($counter == 0 && $comment_count == 1) || ($counter == 2 && $comment_count == 3) )
+ $alt = 'latest';
+ else if( ($counter == 1 && $comment_count >= 4) || ($counter == 0 && $comment_count == 2) || ($counter == 1 && $comment_count == 3) )
+ $alt = 'penultimate';
+
+ //display comment
+ echo "<div class='river_comment {$alt}'>";
+ echo "<div class='river_comment_owner_icon'>";
+ echo elgg_view("profile/icon",array('entity' => $comment_owner, 'size' => 'tiny'));
+ echo "</div>";
+ //truncate comment to 150 characters
+ if(strlen($gc->value) > 150) {
+ $gc->value = substr($gc->value, 0, strpos($gc->value, ' ', 150)) . "...";
+ }
+ $contents = strip_tags($gc->value);
+ echo "<div class='comment_wrapper'>";
+ echo "<a href=\"{$comment_owner_url}\">" . $comment_owner->name . "</a> " . parse_urls($contents);
+ echo "<br /><span class='river_item_time'>" . friendly_time($gc->time_created) . "</span>";
+ echo "<div class=\"clearfloat\"></div>";
+ echo "</div></div>";
+ $counter++;
+ }
+ echo "</div>";
+ }
+ //display the comment link
+ if($vars['item']->type != 'user'){
+ //for now don't display the comment link on bookmarks and wire messages
+ if($vars['item']->subtype != 'thewire' && $vars['item']->subtype != 'bookmarks' && $vars['item']->subtype != '')
+ echo "<span class='comment_link'><a href=\"{$object_url}\">Comment</a></span>";
+ }
+ ?>
+ </div>
+ <div class="clearfloat"></div>
+</div> \ No newline at end of file
diff --git a/mod/riverdashboard/views/default/river/relationship/friend/create.php b/mod/riverdashboard/views/default/river/relationship/friend/create.php
new file mode 100644
index 000000000..916efd407
--- /dev/null
+++ b/mod/riverdashboard/views/default/river/relationship/friend/create.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Elgg relationship create event.
+ * Display something in the river when a relationship is created.
+ */
+
+$statement = $vars['statement'];
+
+$performed_by = $statement->getSubject();
+$event = $statement->getEvent();
+$object = $statement->getObject();
+
+if (is_array($object)) {
+ switch ($object['relationship']) {
+ // Friending
+ case 'friend' :
+ case 'friends' : // 'friends' shouldn't be used, but just incase :)
+
+ // Get second object
+ $userb = $object['object'];
+
+ // Only users can be friends
+ if (($performed_by instanceof ElggUser) && ($userb instanceof ElggUser)) {
+ // User A
+ echo "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a> ";
+
+ // Verb
+ echo elgg_echo('river:relationship:friend');
+
+ // user B
+ echo " <a href=\"{$userb->getURL()}\">{$userb->name}</a>";
+ }
+
+ break;
+ }
+} \ No newline at end of file
diff --git a/mod/riverdashboard/views/default/river/sitemessage/create.php b/mod/riverdashboard/views/default/river/sitemessage/create.php
deleted file mode 100644
index eaceb1a2e..000000000
--- a/mod/riverdashboard/views/default/river/sitemessage/create.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
- $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
- $object = get_entity($vars['item']->object_guid);
- $url = $object->getURL();
-
- $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
- $string = sprintf(elgg_echo("sitemessages:river:created"),$url) . " ";
- $string .= elgg_echo("sitemessages:river:create");
- $string .= "<div class=\"river_content_display\">";
- $string .= $object->description;
- $string .= "</div>";
-
-?>
-
-<?php
- echo $string;
-?> \ No newline at end of file