Facebook like river dashboard/模仿Facebook的river dashboard v0.53

Release Notes

New version released in plugin pack from snow.

This plugin is nearly stable,but I still suggest to test it in a local site before use in a public site.

改进到现在已经比较稳定了,不过还是建议先在测试站点上试一下没问题在用在运营中的网站上

What's this?

A modify to the riverdashboard.

  • Comment on a river item right on the riverdashboard.
  • List comments of a river item
  • show some object right in river,such as tidypic images.

Installation

Extract the two folder,riverdashboard and pack_of_roaming_cat into your elgg's mod folder.

What's new in 0.53

  • Bug fix.this is the nearly-stable version
  • show blog full content in river
  • show a loading icon when loading river image
  • fixes for IE6
  • Fixed a bug in 0.52 that may cause images display incorrect.

What'new in 0.50

  • show image thumb for tidypic,but need a hack of tidypic.Codes gived below.
  • comments and comment form show by default
  • comment pagenation and post use ajax now

TO show image thumb for tidypic,edit tidypic/actions/upload.php,about line 120~130

add

add_to_river('river/object/image/create', 'create', $_SESSION['guid'], $file->guid);

before

} else { //file exceeds file size limit, so delete it
    $file->delete();
    array_push($not_uploaded, $name);

and make sure riverdashboard is below tidypics in the tool admin panel

==========================

Extra view useage:

echo elgg_view('river/item/extra',
                    array('performed_by' => $performed_by,
                        'object' => $object,
                        'body' => $body,
                        'show_comment' => TRUE,)
                    );

in some river item's view.

Examples:

blog/views/default/river/object/blog/create.php

<?php
    /**
     * Show full content of blog in river
     *
     * @package ImprovedRiverDashboard
     */
    /**
     * @author Snow.Hellsing <snow.hellsing@firebloom.cc>
     * @copyright FireBloom Studio
     * @link http://firebloom.cc
     */

    $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>";
    $summary .= elgg_echo("blog:river:create") . " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
    $toggle = "<div><a onclick=\"$('#blog_details-{$object->guid}').toggle();return false;\" class=\"river_item_toggle_details\" href=\"\">".elgg_echo('toggle_details').'</a></div>';
    $details = "<div id=\"blog_details-{$object->guid}\" class=\"blog_post\" style=\"display:none\">";
    $details .= "<h2>$object->title</h2>";
    $details .= elgg_view('output/longtext',array('value'=>$object->description));
    $details .= '</div>';    

    echo elgg_view('river/item/extra',
                    array('performed_by'=>$performed_by,
                        'object'=>$object,
                        'body'=>$summary.$toggle.$details,
                        'show_comment'=>TRUE));
?>

=======================================================

这是什么?

riverdashboard的修改版

  • 可以在riverdashboard上对一个东西添加评论
  • 列出river上的一个东西已有的评论
  • 让一些东西在river上显示更详细的信息,比如tidypics现在显示缩略图

安装

把riverdashboard和pack_of_roaming_cat这俩文件夹解压到elgg的mod目录下

说明

  • 要让tidypics显示缩略图还需要改动tidypics的一些代码,上面已经给出来了
  • 要让更多种类的river item可以使用评论功能的话,可以去修改它们的river\object\xxx\create视图,上面已经给出了一些示例代码

Here comes the screenshot:

image

ImprovedRiverDashboard riverdashboard

ImprovedRiverDashboard widget

  • about the %s problem, i did the fix suggested here, edited the english file (en.php) and edit the line to:

    'image:river:created' => " uploaded",

    but that just gets rid of the '%s' text, how to display the username in text next to the user's avatar? thanks

  • I have made some modifications to this plugin to make it look more like facebook.

    Some changes I made:

    1) if there are no comments, comment box does not show, otherwise show box

    2) if there are more than 3 comments, show first and last and a "show more comments" option in the middle

    3) change the display to a tabular format , name is displayed on top (like facebook), etc

    4) Changed the "show / hide comment" link to just "Comment"

    see the screens below. i can post my change code if anybody is interested

     

    showing "show more comments" when there are 3+ comments

     

    image

     

     

    image

     

    image

  • oops sorry screens shots got messed up, can't edit my previous post

  • Yeah magic, post that code man :-)

  • hmmm ok here are the changes I made to:

     

    mod\riverdashboard\views\default\river\item\extra.php

    <?php
        /**
         * extra view of river item
         * replaces the default wrappers inner div
         * performer and time,maybe comment of a river item
         *
         * @package ImprovedRiverDashboard
         */
        /**
         * @author Snow.Hellsing <snow.hellsing@firebloom.cc>
         * @copyright FireBloom Studio
         * @link http://firebloom.cc
         */
        $performed_by = $vars['performed_by'];
        $object = $vars['object'];
        $body = $vars['body'];
        $show_comment = $vars['show_comment'];
       
        //echo '</div>';//break from basic_river_item_view
    ?>
    <script type="text/javascript">
    function addComment(entityId)
    {
      var cText = "itemCommentForm"+entityId;
      document.getElementById(cText).style.display = '';
    }
    function displayMoreComments(cId,numRows) {

    var idName = 'showMore'+cId;
     document.getElementById(idName).style.display = 'none';
     
    var i=1;
    var rows = parseInt(numRows);
    rows = rows - 1;
    for (i=1;i<=rows;i++){
          cName = 'comment';
         cName = cName+cId;
        cName = cName+i;
        document.getElementById(cName).style.display = '';
     }

    }
    </script>

        <table >
            <tr>
            <td valign="top" align="left">
                <?php echo elgg_view("profile/icon",
                        array(
                            'entity' => $performed_by,
                            'size' => 'small'));
                ?>
                </td>
            <td>
                <table valign="top" align="left">
                  <tr valign="top">
                    <b><a href="<?php echo $performed_by->getURL(); ?>"><?php echo $performed_by->name; ?></a></b>
                    <?php echo $body; ?>
                  </tr>
                  <tr>
                    <div align="left">
                        <span class="riverTime" color="#808080"><?php echo friendly_time($object->time_created); ?> &#149;</span>           
                        <span class="riverComment"> <a href="nojava.html" onclick="document.getElementById('itemCommentForm<?php echo $object->guid; ?>').style.display = '';return false"> Comment </span>
                        <br />               
                    </div>
                  </tr>
           


        <?php
                    //$entityItem = $object->getContainerEntity();
                    $count = $object->countAnnotations('generic_comment');
                    $commentArray = $object->getAnnotations('generic_comment',100,0,"asc");
                    //$count = sizeof($commentArray);
                    if ($count == 0) {
                        ;//do nothing
                    }
                    else if ($count <= 3) { //show all comments
                            print("<tr bgcolor=\"#FFEAFF\" align=\"left\"><td>");
                            echo list_annotations($object->guid,'generic_comment',100);
                            print("</td></tr>");
                    }
                    else { //display first and last comment, with an "show # more comments" option in the middle
                    $annotation = $commentArray[0];
                     print("<tr bgcolor=\"#FFEAFF\" align=\"left\"><td>");
                     echo  elgg_view_annotation($annotation, "", false);
                     print("</td></tr>");
                       $moreCommentNum = $count - 2;
                     print("<tr bgcolor=\"#FFEAFF\" align=\"left\"><td id=\"showMore".$object->guid."\" class=\"generic_commentText\">");
                     print("  <a href=\"#\" onclick=\"javascript:displayMoreComments(".$object->guid.",".$count.");return false\">Show $moreCommentNum more comments...</a>");
                     print("</td></tr>");


                    $i = 1;
                    for ($i = 1; $i < ($count - 1); $i++) {
                      $annotation = $commentArray[$i];
                        print("<tr bgcolor=\"#FFEAFF\" align=\"left\"><td style=\"display: none\" id=\"comment".$object->guid.$i."\" >");
                        echo elgg_view_annotation($annotation,"",false);
                        print("</td></tr>");
                    }

                    $annotation = $commentArray[$count - 1];
                     print("<tr bgcolor=\"#FFEAFF\" align=\"left\"><td>");
                     echo  elgg_view_annotation($annotation, "", false);
                     print("</td></tr>");
               
       

                    }
                ?>

                  <tr align="left">
            <?php
                if ($count > 0) {
                    print("<td align=\"left\" id=\"itemCommentForm".$object->guid."\"");
                }
                else {
                    print("<td align=\"left\" id=\"itemCommentForm".$object->guid."\" style=\"display: none;\">");
                }
            ?>


                           <?php echo elgg_view('river/forms/comment',array('entity' => $object));?>
                    </td>
                  </tr>



                </table>
            </td>
          </tr>
        </table>

     

    =========

    in mod\riverdashboard\views\default\river\item\wrapper.php,

    I removed the friendly time code as it already displayed elsewhere

     

    =========

    my     mod\riverdashboard\views\default\river\forms\comment.php

    <?php

        /**
         * Elgg comments add form
         * Customized for river dashboard use by Snow.Hellsing
         *
         * @package Elgg
         * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
         * @author Curverider Ltd <info@elgg.com>
         * @copyright Curverider Ltd 2008-2009
         * @link http://elgg.com/
         *
         * @uses $vars['entity']
         */
        /**
         * @author Snow.Hellsing <snow.hellsing@firebloom.cc>
         * @copyright FireBloom Studio
         * @link http://firebloom.cc
         */
         
         if (isset($vars['entity']) && isloggedin()) {
             $form_body = elgg_view('input/text',array('internalname' => 'generic_comment'));
             $form_body .= elgg_view('input/hidden', array('internalname' => 'entity_guid', 'value' => $vars['entity']->getGUID()));
             $form_body .= elgg_view('input/submit', array('value' => elgg_echo("river:comment:post")));
    ?>
    <div class="generic_comment"><!-- start of generic_comment div -->
           

            <div class="generic_comment_details">           
                <?php echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/riverdashboard/comment"));?>           
            </div><!-- end of generic_comment_details -->
        </div><!-- end of generic_comment div -->
    <?php
        }//if (isset($vars['entity']) && isloggedin())
    ?>

     

     

    ========

    views/default/annotation/generic_comment.php

     

    <?php

        /**
         * Elgg generic comment
         *
         * @package Elgg
         * @subpackage Core
         * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
         * @author Curverider Ltd
         * @copyright Curverider Ltd 2008-2009
         * @link http://elgg.org/
         *
         */

        $owner = get_user($vars['annotation']->owner_guid);

    ?>


        <div class="generic_comment"><!-- start of generic_comment div -->
           
            <div class="generic_comment_icon">           
                <?php
                    echo elgg_view("profile/icon",
                                array(
                                    'entity' => $owner,
                                    'size' => 'small'));
                ?>
            </div>

            <div class="generic_comment_details">
              
             <p class="generic_comment_owner">
       <a href="<?php echo $owner->getURL(); ?>"><?php echo $owner->name; ?></a> <?php echo friendly_time($vars['annotation']->time_created); ?>
    </p>
                <!-- output the actual comment -->
                <?php echo elgg_view("output/longtext",array("value" => $vars['annotation']->value)); ?>
               
               
                <?php
                   
                    // if the user looking at the comment can edit, show the delete link
                    if ($vars['annotation']->canEdit()) {
                       
                ?>
                <p>
                    <?php

                        echo elgg_view("output/confirmlink",array(
                                                            'href' => $vars['url'] . "action/comments/delete?annotation_id=" . $vars['annotation']->id,
                                                            'text' => elgg_echo('delete'),
                                                            'confirm' => elgg_echo('deleteconfirm'),
                                                        ));
           
                    ?>
                </p>
           
                <?php
                    } //end of can edit if statement
                ?>
            </div><!-- end of generic_comment_details -->
        </div><!-- end of generic_comment div -->

     

    and my related css changes:

    /* ***************************************

        GENERIC COMMENTS

    *************************************** */

    .generic_comment_owner {

        font-size: 90%;

        color:#666666;

    }
    .generic_commentText {

        -webkit-border-radius: 8px;

        -moz-border-radius: 8px;
    padding:5px;
    margin:0 5px 5px 5px;
       border-bottom:1px solid #999999;


    }

    .generic_comment {

        background:#FFEAFF;

        -webkit-border-radius: 8px;

        -moz-border-radius: 8px;

        padding:5px;

        margin:0 5px 5px 5px;
       border-bottom:1px solid #999999;


    }

    .generic_comment_icon {

        float:left;

    }

    .generic_comment_details {

        margin-left: 30px;
        width: 350px;


    }

    .generic_comment_details p {

        margin: 0 0 5px 0;

    }

    .generic_comment_owner {

        color:#666666;

        margin: 0px;

        font-size:90%;

       
    }

    .riverTime {
      color: #808080;
      font-size: 10px;
    }
    .riverComment {
      color: blue;
      font-size: 10px;
    }

     

     

     

  • Has anyone got the code (or a link to the code) to make a riverpost with a new comment move the whole post to the top of the river.  This was described in this post....

    I mean, that when user posting a comment with riverdashboard, whole riverpost became the first in riverdashboard(it can de realised as duplicating the old post with a new created date, and replacing old riverpost with message "User posted the comment to link", without showihg all post replys, for exepting flood with duplicated posts on the page)

     

     

  • i found it!

    some of us have been getting a empty white page on the riverdashboard

    it was a <? tag in riverdashboard/views/default/river/item/extra.php
    if your server is not configed to accept short php tags (<? vs <?php) you get the blank page

    riverdashboard/views/default/river/item/extra.php, line 48
    change to:

    <?php
        if ($show_comment) {
    ?>

    cheers

    tmo

  • @tdnguyen16

    To make the river display code for both friends and yourself in the one river stream...

    in engine/lib/river2.php replace the get_river_items function with the following:

    function get_river_items(
                                $subject_guid = 0,
                                $object_guid = 0,
                                $subject_relationship = '',
                                $type = '',
                                $subtype = '',
                                $action_type = '',
                                $limit = 20,
                                $offset = 0,
                                $posted_min = 0,
                                $posted_max = 0
                             ) {
                                
                // Get config
                    global $CONFIG;
                                
                // Sanitise variables
                    if (!is_array($subject_guid)) {
                        $subject_guid = (int) $subject_guid;
                    } else {
                        foreach($subject_guid as $key => $temp) {
                            $subject_guid[$key] = (int) $temp;
                        }
                    }
                    if (!is_array($object_guid)) {
                        $object_guid = (int) $object_guid;
                    } else {
                        foreach($object_guid as $key => $temp) {
                            $object_guid[$key] = (int) $temp;
                        }
                    }
                    if (!empty($type)) $type = sanitise_string($type);
                    if (!empty($subtype)) $subtype = sanitise_string($subtype);
                    if (!empty($action_type)) $action_type = sanitise_string($action_type);
                    $limit = (int) $limit;
                    $offset = (int) $offset;
                    $posted_min = (int) $posted_min;
                    $posted_max = (int) $posted_max;
                   
                // Construct 'where' clauses for the river
                    $where = array();
                    $where[] = str_replace("and enabled='yes'",'',str_replace('owner_guid','subject_guid',get_access_sql_suffix()));
                   
                    if (!is_array($subject_relationship) && empty($subject_relationship))
                    {
                        if (!empty($subject_guid))
                        {
                            if (!is_array($subject_guid)) {
                                $where[] = " subject_guid = {$subject_guid} ";
                            } else {
                                $where[] = " subject_guid in (" . implode(',',$subject_guid) . ") ";
                            }
                        }
                    }
                    else
                    {
                        $guids = array();  // this moved up here
                       
                        if (!is_array($subject_guid))
                        {
                            // ADDED BY CHRISG
                            if (is_array($subject_relationship))
                            {
                                $entities = array();
                               
                                foreach($subject_relationship as $sr)
                                {
                                    if (empty($sr))
                                        $guids[] = $subject_guid;
                                    else
                                    {
                                        $new_entities = get_entities_from_relationship($sr,$subject_guid,false,'','',0,'',9999);
                                       
                                        if ($new_entities)
                                            $entities = array_merge($entities, $new_entities);
                                    }
                                }
                               
                                if (!count($entities))
                                    $entities = false;
                            }
                            else
                                $entities = get_entities_from_relationship($subject_relationship,$subject_guid,false,'','',0,'',9999);
                            // END CHRISG ADD   
                               
                            if ($entities)
                            {
                                foreach($entities as $entity)
                                    $guids[] = (int) $entity->guid;
                                   
                                $where[] = " subject_guid in (" . implode(',',$guids) . ") ";
                            }
                            else
                            {
                                return array();
                            }
                        }
                    }
                    if (!empty($object_guid))
                        if (!is_array($object_guid)) {
                            $where[] = " object_guid = {$object_guid} ";
                        } else {
                            $where[] = " object_guid in (" . implode(',',$object_guid) . ") ";
                        }
                    if (!empty($type)) $where[] = " type = '{$type}' ";
                    if (!empty($subtype)) $where[] = " subtype = '{$subtype}' ";
                    if (!empty($action_type)) $where[] = " action_type = '{$action_type}' ";
                    if (!empty($posted_min)) $where[] = " posted > {$posted_min} ";
                    if (!empty($posted_max)) $where[] = " posted < {$posted_max} ";
                   
                    $whereclause = implode(' and ', $where);
                   
                // Construct main SQL
                    $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
                           
                // Get data
                    return get_data($sql);
               
            }

    This will allow $subject_relationship to be passed as an array.

     

    Then in mod/riverdashboard/index.php

    search for "switch($orient) {" and then change the "case 'friends':" to

    case 'friends':    $subject_guid = $_SESSION['user']->guid;
                                $relationship_type = array('', 'friend');
                                break;

    This will cause both your own AND your friends posts to display when you click on the "friends" tab.

  • thanks chrisg, i will try out the solution you provided, much appreciated

  • @timomeara Thanks so much.New release will include this fix.And sorry for all guys troubled by this mistake.

    @jededitor I can't repeat the icon overlaping problem,may this caused by your site's theme?

    @Andrew this problem solved.New release won't be long.

    @tdnguyen16 Thanks so much for your work^^ May I include your work in the next release?

    @imcobarn riverdashboard/index.php,line 41-51,append contents to $area1.

  • @snow I suspect you are right as the plugin uses the site defaults to display those lines. Which plugin handles those BTW as I think I will remove the icons?

  • @jededitor I'm sure.Disable all plugins than enable one by one may be a way to catch the bayguy.^^

  • snow.hellsing sure no problem you can use any part of the code as you see fits. 

     

  • @snow

    Hah! Typical - its something in my theme....

  • @Snow

    Got it! Thanks for the plugin pointer Snow!

  • Has anyone looked into letting useres and admins delete comments. I thought this would be a simple thing that other people already have done so I dont have to spend time on it. If not Ill work on it and post the results.

    gh

  • a quick poor man fix to "%s added the image %s to album %s" 

    I changed 

    $summary .= elgg_echo("image:river:created");  

    in 

    elgg/mod/riverdashboard/views/default/river/object/image/create.php

     

    to

    $summary .= sprintf(elgg_echo("image:river:created"),$performed_by->name, $image_link, $album_link);

     

    but 

    the message is: Michal added the image to album

    so missing image link and album name;) 

    but as I said, it was quick fix;)

     

    Michal

  • Hi!

    I have the same problem that jededitor

    the icon is overlapped by the text!

    where is the problem? thanks

    image

  • Small Edit to my patch  to make the river display entries for both yourself and friends in one stream. 

    8 lines below "ADDED BY CHRISG" should read:

    $entities[] = get_entity($subject_guid);
  • @dagrfics: To remove the small icons set:

    $vars['item']->action_type = '';

    in the river view for the entry: (eg: mod/groups/views/default/river/group/create.php)

  • Hi, Im a new bie at elgg...can anyone help me with

    -How do i remove all feeds from the river dash, i want the friends and mine tab to appear 1st and prefereably together...

    Thanks

    Antonio

  • Found the secret to the icon text overlap...

    add spaces..   4 of them do it... in the create.php for   the different mods  

    ie...   for The Wire

    go to mod/thewire/views/default/river/object/thewire/create.php

    then change

        $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";

    to

        $url = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";

     

    this does it nicely

    &nbsp;&nbsp;&nbsp;&nbsp;

     

  • By the way...   this is a brilliant mod...   brilliant!

  • here is a fix for the tidypics issue with %s displaying:

    in views/default/river/object/image/create.php

    replace the contents between the php tags with this:

        /**
         * @author Snow.Hellsing <snow.hellsing@firebloom.cc>
         * @copyright FireBloom Studio
         * @link http://firebloom.cc
         */

        $performed_by = get_entity($vars['item']->subject_guid);
        //$image = get_entity($vars['item']->object_guid);
        $object = get_entity($vars['item']->object_guid);
        if($object->title) {
            $title = $object->title;
        } else {
            $title = "untitled";
        }
       
        $url = $vars['url'];
        $album = get_entity($object->container_guid);
        $mime = $object->mimetype;
        $person_link = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
        $image_link = "<a href=\"" . $object->getURL() . "\">" . $title . "</a>";
        $album_link = "<a href='". $album->getURL() . "'>" . $album->title . "</a>";
       
       
        $summary .= sprintf(elgg_echo("image:river:created"),$person_link, $image_link, $album_link);

       
       
        $goto_full = "<a href=\"{$object->getURL()}\" target=\"_blank\" class=\"goto_full\" id=\"image_toggle-{$object->guid}\">".elgg_echo('river:image:goto_full')."</a>";
       
        $thumb = "<img src=\"{$url}mod/tidypics/thumbnail.php?file_guid={$object->guid}&size=small\" border=\"0\" alt=\"thumbnail\"/>";
       
        echo elgg_view('river/item/extra',
                        array('performed_by'=>$performed_by,
                            'object'=>$object,
                            'body'=>$summary.' - '.$goto_full.'<br />'.$thumb,
                            'show_comment'=>TRUE)
                        );

  • @ David Connolly and anyone with the icon overlap problem. I tried David Connolly solution but it did nothing for me. I then removed the riverdashboard and pack_of_roaming_cat, and I also moved my original riverdashboard that I named to riverdashboar_org outside of the mod folder. I then moved the two folders(riverdashboard and pack_of_roaming_cat) back to the mod folder. I then made sure the riverdashboard is below tidypics in the tool admin panel and it works ... for the most part...

Snow.Hellsing

This cat has travelled far far away and dont know when will come back.I still remember my promises.Sorry,guys.

Stats

  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 34030
  • Recommendations: 5

Other Projects

View Snow.Hellsing's plugins