]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
updated bookmarks widget to use 1.7 APIs
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 19 Nov 2010 12:11:10 +0000 (12:11 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 19 Nov 2010 12:11:10 +0000 (12:11 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7346 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/bookmarks/views/default/widgets/bookmarks/edit.php
mod/bookmarks/views/default/widgets/bookmarks/view.php

index deba1c01223ae3f05c60f2f6b9b8de13cf7cff56..edb6afdf23b3e315dd69b44a91c93a9f83d57f0f 100644 (file)
@@ -5,6 +5,10 @@
  * @package ElggBookmarks
  */
 
+// set default value
+if (!isset($vars['entity']->num_display)) {
+       $vars['entity']->num_display = 4;
+}
 ?>
 <p>
        <?php echo elgg_echo('bookmarks:numbertodisplay'); ?>:
index b401f86ad242237f9e520b0d29f3142f0106bc11..cbd0012bb3f43ae6f5634c5073cef8bc86b768a2 100644 (file)
@@ -1,52 +1,57 @@
 <?php
+
 /**
  * Elgg bookmark widget view
- * 
+ *
  * @package ElggBookmarks
  */
-
 //get the num of shares the user want to display
 $num = $vars['entity']->num_display;
-               
-//if no number has been set, default to 4
-if(!$num)
-       $num = 4;
-                       
-//grab the users bookmarked items
-$bookmarks = elgg_get_entities('object', 'bookmarks',$vars['entity']->owner_guid, "", $num, 0, false);
-               
-if($bookmarks){
-
-       foreach($bookmarks as $b){
-                       
+
+$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($s->time_created);
+               $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($s->description)
-                       $info .= "<a href=\"javascript:void(0);\" class=\"share_more_info\">".elgg_echo('bookmarks:more')."</a></small></p><div class=\"share_desc\"><p>{$s->description}</p></div>";
-               else 
+               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 
+               }
+
+               //display
                echo "<div class='ContentWrapper bookmarks'>";
                echo "<div class='shares_widget_content'>" . $info . "</div></div>";
+       }
 
-       } 
-
-       $user_inbox = elgg_get_site_url() . "pg/bookmarks/" . elgg_get_page_owner()->username;
-       if (get_entities('object', 'bookmarks', $vars['entity']->container_guid, '', '', '', true) > $num)      
-               echo "<div class='ContentWrapper bookmarks more'><a href=\"{$user_inbox}\">".elgg_echo('bookmarks:read')."</a></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>";
-}
\ No newline at end of file
+}