From 4533dcf9aeead704f346db038c5b692512aab890 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 19 Nov 2010 12:33:42 +0000 Subject: updated file widget to use 1.7 elgg_get_entities* APIs git-svn-id: http://code.elgg.org/elgg/trunk@7347 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/file/views/default/widgets/filerepo/edit.php | 6 ++ mod/file/views/default/widgets/filerepo/view.php | 108 +++++++++++------------ 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/mod/file/views/default/widgets/filerepo/edit.php b/mod/file/views/default/widgets/filerepo/edit.php index 0d1901662..0ee794dca 100644 --- a/mod/file/views/default/widgets/filerepo/edit.php +++ b/mod/file/views/default/widgets/filerepo/edit.php @@ -1,4 +1,10 @@ num_display)) { $vars['entity']->num_display = 4; diff --git a/mod/file/views/default/widgets/filerepo/view.php b/mod/file/views/default/widgets/filerepo/view.php index 09c29a3ce..41a968dce 100644 --- a/mod/file/views/default/widgets/filerepo/view.php +++ b/mod/file/views/default/widgets/filerepo/view.php @@ -1,73 +1,71 @@ owner_guid; - //the number of files to display - $number = (int) $vars['entity']->num_display; - if (!$number) { - $number = 4; - } - - //get the layout view which is set by the user in the edit panel - $get_view = (int) $vars['entity']->gallery_list; - if (!$get_view || $get_view == 1) { - $view = "list"; - }else{ - $view = "gallery"; - } - - //get the user's files - $files = get_user_objects($vars['entity']->owner_guid, "file", $number, 0); - - //if there are some files, go get them - if ($files) { - - echo "
"; - - if($view == "gallery"){ - - echo "
"; +$owner_guid = $vars['entity']->owner_guid; +$number = $vars['entity']->num_display; - //display in gallery mode - foreach($files as $f){ +//get the layout view which is set by the user in the edit panel +$get_view = (int) $vars['entity']->gallery_list; +if (!$get_view || $get_view == 1) { + $view = "list"; +} else { + $view = "gallery"; +} - $mime = $f->mimetype; - echo "getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . ""; +//get the user's files +$options = array( + 'type' => 'object', + 'subtype' => 'file', + 'limit' => $number, + 'container_guid' => $owner_guid +); +$files = elgg_get_entities($options); - } +//if there are some files, go get them +if ($files) { - echo "
"; + echo "
"; - }else{ + if ($view == "gallery") { - //display in list mode - foreach($files as $f){ + echo "
"; - $mime = $f->mimetype; - echo "
"; - echo ""; - echo "
"; - echo "

" . $f->title . "

"; - echo "

" . elgg_view_friendly_time($f->time_created) . "

"; - echo "
"; + //display in gallery mode + foreach ($files as $f) { - } + $mime = $f->mimetype; + echo "getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . ""; + } - } - - - //get a link to the users files - $users_file_url = elgg_get_site_url() . "pg/file/" . get_user($f->owner_guid)->username; - - echo ""; - echo "
"; + echo "
"; + } else { + //display in list mode + foreach ($files as $f) { + + $mime = $f->mimetype; + echo "
"; + echo ""; + echo "
"; + echo "

" . $f->title . "

"; + echo "

" . elgg_view_friendly_time($f->time_created) . "

"; + echo "
"; + } + } - } else { - echo "

" . elgg_echo("file:none") . "

"; + //get a link to the users files + $users_file_url = elgg_get_site_url() . "pg/file/" . get_user($f->owner_guid)->username; - } + echo ""; + echo "
"; +} else { + echo "

" . elgg_echo("file:none") . "

"; +} ?> \ No newline at end of file -- cgit v1.2.3