]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
updated riverdashboard plugin to use new river display code - javascript code current...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 17 Dec 2010 02:24:39 +0000 (02:24 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 17 Dec 2010 02:24:39 +0000 (02:24 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7652 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/riverdashboard/index.php
mod/riverdashboard/start.php
mod/riverdashboard/views/default/riverdashboard/css.php
mod/riverdashboard/views/default/riverdashboard/js.php
mod/riverdashboard/views/default/riverdashboard/river/body.php [new file with mode: 0644]
mod/riverdashboard/views/default/riverdashboard/river/footer.php [new file with mode: 0644]
mod/riverdashboard/views/default/riverdashboard/rivercomment.php
views/default/forms/likes/display.php

index 2bc5f949c2e6233425500a2434337bdf521d1484..802536416f708a3a6b30bdc485a0647fefd6e0f7 100644 (file)
@@ -62,7 +62,7 @@ if (empty($callback)) {
                'content' => $title . $body,
                'sidebar' => $sidebar
        );
-       $body = elgg_view_layout('one_column_with_sidebar', $params);
+       $body = elgg_view_layout('one_sidebar', $params);
        echo elgg_view_page($title_wording, $body);
 } else {
        header("Content-type: text/html; charset=UTF-8");
index 71eef330ec426fe93915be58b096fa5390113836..e42bc6e01da956e90b291b22b88fafcdf399d16c 100644 (file)
@@ -205,7 +205,6 @@ $posted_max = 0) {
                        " ORDER BY e.last_action desc LIMIT {$offset}, {$limit}";
 
        // Get data
-       //return get_data($sql);
        return get_data($sql, 'elgg_row_to_elgg_river_item');
 }
 
@@ -348,6 +347,25 @@ $posted_max = 0, $pagination = true) {
  * @return string|false Depending on success
  */
 function riverdashboard_view_river_item($item) {
+
+       if (!$item || !$item->getView() || !elgg_view_exists($item->getView())) {
+               return '';
+       }
+
+       $subject = $item->getSubjectEntity();
+       $object = $item->getObjectEntity();
+       if (!$subject || !$object) {
+               // subject is disabled or subject/object deleted
+               return '';
+       }
+
+       $vars = array(
+               'pict' => elgg_view('core/river/image', array('item' => $item)),
+               'body' => elgg_view('riverdashboard/river/body', array('item' => $item)),
+               'class' => 'elgg-river-item',
+       );
+       return elgg_view('layout/objects/media', $vars);
+/*
        if (isset($item->view)) {
                $object = get_entity($item->object_guid);
                $subject = get_entity($item->subject_guid);
@@ -367,4 +385,6 @@ function riverdashboard_view_river_item($item) {
                ));
        }
        return false;
+ * 
+ */
 }
index f4870d1162deb0e18cc804eaf95af8e9ee3c5205..29d0d6bb853846ddf5722d8f2725a80501fc6944 100644 (file)
 }
 
 /* RIVER ENTRY */
-.river-item {
+.elgg-river-item {
        border-bottom:1px solid #cccccc;
        padding:7px 0 7px 0;
 }
-.river-item p {
+.elgg-river-item p {
        margin:0;
 }
-.river-item .entity-subtext {
+.elgg-river-item .entity-subtext {
        display: block;
        line-height: 1.4em;
 }
        margin-left: 7px;
 }
 /* hidden list of users that liked item */
-.river-item .elgg-likes-user {
+.elgg-likes-user {
        border-bottom:1px solid white;
        padding:3px;
 }
-.river-item .elgg-likes-user .entity-listing-icon {
+.elgg-likes-user .entity-listing-icon {
        margin:3px 0 4px 2px;
 }
-.river-item .elgg-likes-user .entity-listing-info {
+.elgg-likes-user .entity-listing-info {
        width:635px;
 }
 #profile-content .river-item .elgg-likes-user .entity-listing-info { /* when likes is displayed on profile page activity stream */
        width:600px;
 }
-.river-item .elgg-likes-user .entity-metadata {
+.elgg-likes-user .entity-metadata {
        margin-top:3px;
 }
-.river-item p.elgg-likes-owner {
+p.elgg-likes-owner {
        padding-top:0;
 }
-.river-item a.river-more-comments {
+a.river-more-comments {
        display:block;
        float:right;
        padding:1px 7px 1px 7px;
        -webkit-border-top-left-radius:4px;
        -webkit-border-top-right-radius:4px;
 }
-.river-item a.river-more-comments.off {
+a.river-more-comments.off {
        background-color: white;
 }
-.river-item .river-comment-owner-icon {
+.river-comment-owner-icon {
        float:left;
        margin:3px 8px 4px 2px;
 }
-.river-item .river-comment-contents {
+.river-comment-contents {
        margin-left:34px;
 }
 a.river-more-comments {
index 09b1113d84949a6a30ad6a3f7568b5aa86b25b3d..9286d33fed20af24de75b1852ceb588e762881aa 100644 (file)
@@ -1,7 +1,7 @@
 <script type="text/javascript">
        $(document).ready(function() {
                $('.river-comment-form-button').click(function() {
-                       elgg_slide_toggle(this, '.river-item', '.river-comment_form');
+                       elgg_slide_toggle(this, '.elgg-module', '.river-comment-form');
                });
 
                $('.likes_user_list_button').click(function() {
diff --git a/mod/riverdashboard/views/default/riverdashboard/river/body.php b/mod/riverdashboard/views/default/riverdashboard/river/body.php
new file mode 100644 (file)
index 0000000..ab12276
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Body of river item
+ *
+ * @uses $vars[item]
+ */
+
+$item = $vars[item];
+$subject = $item->getSubjectEntity();
+$object = $item->getObjectEntity();
+
+// river item header
+$params = array(
+       'href' => $subject->getURL(),
+       'text' => $subject->name,
+);
+$subject_link = elgg_view('output/url', $params);
+$timestamp = elgg_get_friendly_time($item->getPostedTime());
+$header = "$subject_link <span class=\"elgg-river-timestamp\">$timestamp</span>";
+
+// body
+$body = elgg_view($item->getView(), array('item' => $item));
+if ($object->getType() == 'object' && $vars['item']->annotation_id == 0) {
+       $body .= '<div></div>';
+       $body .= "<a class='river-comment-form-button link'>Comment</a>";
+       $body .= elgg_view('forms/likes/link', array('entity' => $object));
+}
+
+// footer
+$footer = elgg_view('riverdashboard/river/footer', $vars);
+
+$params = array(
+       'header' => $header,
+       'body' => $body,
+       'footer' => $footer,
+       'show_inner' => false,
+);
+echo elgg_view('layout/objects/module', $params);
diff --git a/mod/riverdashboard/views/default/riverdashboard/river/footer.php b/mod/riverdashboard/views/default/riverdashboard/river/footer.php
new file mode 100644 (file)
index 0000000..82aae00
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/**
+ * River item footer
+ */
+
+
+$object = get_entity($vars['item']->object_guid);
+$object_url = $object->getURL();
+$likes_count = elgg_count_likes($object);
+
+//user
+//if displaying on the profile get the object owner, else the subject_guid
+if (elgg_get_context() == 'profile' && $object->getSubtype() ==  'thewire') {
+       $user = get_entity($object->owner_guid);
+} else {
+       $user = get_entity($vars['item']->subject_guid);
+}
+
+// get last three comments display
+// want the 3 most recent comments (order by time_created desc = 3 2 1 limit 3)
+// but will display them with the newest at the bottom (1 2 3)
+if ($comments = get_annotations($vars['item']->object_guid, "", "", 'generic_comment', "", "", 3, 0, "desc")) {
+       $comments = array_reverse($comments);
+}
+
+// for displaying "+N more"
+// -3 from the count because the 3 displayed don't count in the "more"
+$comment_count = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, 'generic_comment');
+if ($comment_count < 3) {
+       $more_comments_count = 0;
+} else {
+       $more_comments_count = $comment_count - 3;
+}
+
+// body contents, generated by the river view in each plugin
+echo $vars['body'];
+
+// display latest 3 comments if there are any
+if ($comments){
+       $counter = 0;
+
+       echo "<div class='river-comments-tabs clearfix'>";
+       echo "<a class='river-more-comments show_comments_button link'>" . elgg_echo('comments') . '</a>';
+
+       if ($likes_count != 0) {
+               echo elgg_view('forms/likes/display', array('entity' => $object));
+       }
+
+       echo "</div>"; // close river-comments-tabs
+
+       echo "<div class='river-comments'>";
+
+       if ($likes_count != 0) {
+               //show the users who liked the object
+               // this is loaded via ajax to avoid pounding the server with avatar requests.
+               echo "<div class='likes-list hidden'></div>";
+       }
+
+       echo "<div class=\"comments_container\">";
+       // display appropriate comment link
+       if ($more_comments_count > 0) {
+               echo "<a class=\"river-more-comments show_more_button link\">" .
+               elgg_echo('riverdashboard:n_more_comments', array($more_comments_count)) . '</a>';
+
+               echo "<a style=\"display: none\" class=\"river-more-comments show_less_button link\">" . elgg_echo('riverdashboard:show_less') . '</a>';
+       }
+       echo "<div class=\"comments_list\">";
+       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();
+               // color-code each of the 3 comments
+               // @todo this isn't used in CSS...
+               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 clearfix'>";
+               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_get_excerpt($comment->value, 150);
+
+               echo "<div class='river-comment-contents'>";
+               echo "<a href=\"{$comment_owner_url}\">" . $comment_owner->name . '</a>&nbsp;<span class="elgg_excerpt">' . parse_urls($contents) . '</span>';
+               echo "<span class='entity-subtext'>" . elgg_view_friendly_time($comment->time_created) . "</span>";
+               echo "</div></div>";
+               $counter++;
+       }
+
+       // close comments_list, comments_container and river-comments
+       echo '</div></div>' . elgg_make_river_comment($object) . '</div>';
+} else {
+       // tab bar nav - for users that liked object
+       if ($vars['item']->type != 'user' && $likes_count != 0) {
+               echo "<div class='river-comments-tabs clearfix'>";
+       }
+
+       if ($likes_count != 0) {
+               echo elgg_view('forms/likes/display', array('entity' => $object));
+       }
+
+       if ($vars['item']->type != 'user' && $likes_count != 0) {
+               echo "</div>"; // close river-comments-tabs
+       }
+
+       if ($vars['item']->type != 'user') {
+               echo "<div class='river-comments'>";
+       }
+       if ($likes_count != 0) {
+               //show the users who liked the object
+               echo "<div class='likes-list hidden'>";
+               echo list_annotations($object->getGUID(), 'likes', 99);
+               echo "</div>";
+       }
+
+       // if there are no comments to display
+       // and this is not a user - include the inline comment form
+       if ($vars['item']->type != 'user') {
+               echo elgg_make_river_comment($object);
+       }
+       if ($vars['item']->type != 'user') {
+               echo "</div>";
+       }
+}
+?>
index d6037557d2db12c9be2e45d3fec5f8f18f3e0660..e1c6ab07fcded9bcc073a3510f6dfc777156cfb7 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 if (isset($vars['entity']) && isloggedin()) {
-       $form_body = "<div class='river-comment_form hidden'>";
+       $form_body = "<div class='river-comment-form hidden'>";
        $form_body .= elgg_view('input/text',array(
                                                        'internalname' => 'generic_comment',
                                                        'value' => 'Add a comment...',
index 36e2cddc296e3c3766f84086e0dab279c95864bb..e71688bacc0790ec260a156501a38f618f8fe540 100644 (file)
@@ -18,6 +18,6 @@ if (isset($vars['entity']) && isloggedin()) {
                        $user_string = elgg_echo('likes:userslikedthis');
                }
 
-               echo "<a class='river_more_comments off likes_user_list_button link'>" . elgg_count_likes($vars['entity']) . " " . $user_string . "</a>";
+               echo "<a class='river-more-comments off likes-user-list-button link'>" . elgg_count_likes($vars['entity']) . " " . $user_string . "</a>";
        }
 }
\ No newline at end of file