]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
almost finished updating the file plugin to work with new html/css
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 1 Jan 2011 17:55:18 +0000 (17:55 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 1 Jan 2011 17:55:18 +0000 (17:55 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7804 36083f99-b078-4883-b0ff-0f9b5a30f544

26 files changed:
mod/blog/views/default/widgets/blog/edit.php
mod/file/actions/file/delete.php
mod/file/actions/file/download.php
mod/file/actions/file/save.php [deleted file]
mod/file/actions/file/upload.php
mod/file/classes/FilePluginFile.php
mod/file/edit.php
mod/file/friends.php
mod/file/index.php
mod/file/languages/en.php
mod/file/lib/file.php [new file with mode: 0644]
mod/file/search.php
mod/file/start.php
mod/file/upload.php
mod/file/views/default/file/css.php
mod/file/views/default/file/group_module.php [new file with mode: 0644]
mod/file/views/default/file/groupprofile_files.php [deleted file]
mod/file/views/default/file/icon.php
mod/file/views/default/file/typecloud.php
mod/file/views/default/file/upload.php [deleted file]
mod/file/views/default/forms/file/upload.php [new file with mode: 0644]
mod/file/views/default/widgets/filerepo/content.php
mod/file/views/default/widgets/filerepo/edit.php
mod/file/world.php
mod/groups/views/default/groups/css.php
views/default/output/confirmlink.php

index aaa9d1a108188689b7345859a0e40c293caed2e3..fbf86833f7c0abda56738465e2f7e80c12fddc7c 100644 (file)
@@ -10,7 +10,7 @@ if (!isset($vars['entity']->num_display)) {
 
 $params = array(
        'internalname' => 'params[num_display]',
-       'value' => $vars['entity']->num_display = 4,
+       'value' => $vars['entity']->num_display,
        'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
 );
 $dropdown = elgg_view('input/pulldown', $params);
index 9357d4955c06c2e83c2f7cca5b118f9a37e0eb78..fe03e50772d25f7954bbdcf95c28b8e1b0239ccd 100644 (file)
@@ -1,65 +1,33 @@
 <?php
-
-       /**
-        * Elgg file delete
-        * 
-        * @package ElggFile
-        */
-
-               $guid = (int) get_input('file');
-               if ($file = get_entity($guid)) {
-
-                       if ($file->canEdit()) {
-
-                               $container = get_entity($file->container_guid);
-                               
-                               $thumbnail = $file->thumbnail;
-                               $smallthumb = $file->smallthumb;
-                               $largethumb = $file->largethumb;
-                               if ($thumbnail) {
-
-                                       $delfile = new ElggFile();
-                                       $delfile->owner_guid = $file->owner_guid;
-                                       $delfile->setFilename($thumbnail);
-                                       $delfile->delete();
-
-                               }
-                               if ($smallthumb) {
-
-                                       $delfile = new ElggFile();
-                                       $delfile->owner_guid = $file->owner_guid;
-                                       $delfile->setFilename($smallthumb);
-                                       $delfile->delete();
-
-                               }
-                               if ($largethumb) {
-
-                                       $delfile = new ElggFile();
-                                       $delfile->owner_guid = $file->owner_guid;
-                                       $delfile->setFilename($largethumb);
-                                       $delfile->delete();
-
-                               }
-                               
-                               if (!$file->delete()) {
-                                       register_error(elgg_echo("file:deletefailed"));
-                               } else {
-                                       system_message(elgg_echo("file:deleted"));
-                               }
-
-                       } else {
-                               
-                               $container = get_loggedin_user();
-                               register_error(elgg_echo("file:deletefailed"));
-                               
-                       }
-
-               } else {
-                       
-                       register_error(elgg_echo("file:deletefailed"));
-                       
-               }
-               
-               forward("pg/file/$container->username/");
-
-?>
\ No newline at end of file
+/**
+* Elgg file delete
+* 
+* @package ElggFile
+*/
+
+$guid = (int) get_input('guid');
+
+$file = new FilePluginFile($guid);
+if (!$file->guid) {
+       register_error(elgg_echo("file:deletefailed"));
+       forward('pg/file/all');
+}
+
+if (!$file->canEdit()) {
+       register_error(elgg_echo("file:deletefailed"));
+       forward($file->getURL());
+}
+
+$container = $file->getContainerEntity();
+
+if (!$file->delete()) {
+       register_error(elgg_echo("file:deletefailed"));
+} else {
+       system_message(elgg_echo("file:deleted"));
+}
+
+if (elgg_instanceof($container, 'group')) {
+       forward("pg/file/group/$container->guid/owner");
+} else {
+       forward("pg/file/owner/$container->username");
+}
index 210735b744c3f94ba1a3060cd872def3696708cd..6768bd4b13adcc67e9babc452515c175c0e7bbe4 100644 (file)
@@ -1,37 +1,11 @@
 <?php
-       /**
       * Elgg file browser download action.
-        * 
       * @package ElggFile
       */
+/**
+ * Elgg file browser download action.
+ *
+ * @package ElggFile
+ */
 
-       // Get the guid
-       $file_guid = get_input("file_guid");
-       
-       // Get the file
-       $file = get_entity($file_guid);
-       
-       if ($file)
-       {
-               $mime = $file->getMimeType();
-               if (!$mime) $mime = "application/octet-stream";
-               
-               $filename = $file->originalfilename;
-               
-               // fix for IE https issue 
-               header("Pragma: public"); 
-               header("Content-type: $mime");
-               if (strpos($mime, "image/")!==false)
-                       header("Content-Disposition: inline; filename=\"$filename\"");
-               else
-                       header("Content-Disposition: attachment; filename=\"$filename\"");
+// @todo this is here for backwards compatibility (first version of embed plugin?)
+$download_page_handler = elgg_get_plugin_path() . 'file/download.php';
 
-               $contents = $file->grabFile();
-               $splitString = str_split($contents, 8192);
-               foreach($splitString as $chunk)
-                       echo $chunk;
-               exit;
-       }
-       else
-               register_error(elgg_echo("file:downloadfailed"));
-?>
\ No newline at end of file
+include $download_page_handler;
diff --git a/mod/file/actions/file/save.php b/mod/file/actions/file/save.php
deleted file mode 100644 (file)
index 17a9b16..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-       /**
-        * Elgg file browser save action
-        * 
-        * @package ElggFile
-        */
-
-       global $CONFIG;
-       
-       // Get variables
-       $title = strip_tags(get_input("title"));
-       $desc = get_input("description");
-       $tags = get_input("tags");
-       $access_id = (int) get_input("access_id");
-       
-       $guid = (int) get_input('file_guid');
-       
-       if (!$file = get_entity($guid)) {
-               register_error(elgg_echo("file:uploadfailed"));
-               forward(elgg_get_site_url() . "pg/file/" . get_loggedin_user()->username);
-               exit;
-       }
-       
-       $result = false;
-       
-       $container_guid = $file->container_guid;
-       $container = get_entity($container_guid);
-       
-       if ($file->canEdit()) {
-       
-               $file->access_id = $access_id;
-               $file->title = $title;
-               $file->description = $desc;
-       
-               // Save tags
-                       $tags = explode(",", $tags);
-                       $file->tags = $tags;
-
-                       $result = $file->save();
-       }
-       
-       if ($result)
-               system_message(elgg_echo("file:saved"));
-       else
-               register_error(elgg_echo("file:uploadfailed"));
-       
-       forward(elgg_get_site_url() . "pg/file/" . $container->username);
-?>
\ No newline at end of file
index 081b6a3128a529899e68956bf5183d12922cbac9..5ce98c101faa90d17667ebed43d9f82901946b67 100644 (file)
 <?php
-       /**
-        * Elgg file browser uploader/edit action
-        * 
-        * @package ElggFile
-        */
-
-       global $CONFIG;
-       
-       // Get variables
-       $title = get_input("title");
-       $desc = get_input("description");
-       $access_id = (int) get_input("access_id");
-       $container_guid = (int) get_input('container_guid', 0);
-       $ajax = get_input('ajax', FALSE);
-       
-       if ($container_guid == 0) {
-               $container_guid = get_loggedin_userid();
+/**
+ * Elgg file uploader/edit action
+ *
+ * @package ElggFile
+ */
+
+// Get variables
+$title = get_input("title");
+$desc = get_input("description");
+$access_id = (int) get_input("access_id");
+$container_guid = (int) get_input('container_guid', 0);
+$guid = (int) get_input('file_guid');
+$tags = get_input("tags");
+
+$ajax = get_input('ajax', FALSE);
+
+if ($container_guid == 0) {
+       $container_guid = get_loggedin_userid();
+}
+
+elgg_make_sticky_form('file');
+
+
+// check whether this is a new file or an edit
+$new_file = true;
+if ($guid > 0) {
+       $new_file = false;
+}
+
+if ($new_file) {
+       // must have a file if a new file upload
+       if (empty($_FILES['upload']['name'])) {
+
+               $error = elgg_echo('file:nofile');
+
+               if ($ajax) {
+                       echo json_encode(array(
+                               'status' => 'error',
+                               'message' => $error
+                       ));
+                       exit;
+               } else {
+                       register_error($error);
+                       forward(REFERER);
+               }
        }
-       $guid = (int) get_input('file_guid');
-       $tags = get_input("tags");
-       
-       // check whether this is a new file or an edit
-       $new_file = true;
-       if ($guid > 0) {
-               $new_file = false;
+
+       $file = new FilePluginFile();
+       $file->subtype = "file";
+
+       // if no title on new upload, grab filename
+       if (empty($title)) {
+               $title = $_FILES['upload']['name'];
        }
-       
-       if ($new_file) {
-               // must have a file if a new file upload
-               if (empty($_FILES['upload']['name'])) {
-                       // cache information in session
-                       $_SESSION['uploadtitle'] = $title;
-                       $_SESSION['uploaddesc'] = $desc;
-                       $_SESSION['uploadtags'] = $tags;
-                       $_SESSION['uploadaccessid'] = $access_id;
-                       
-                       $error = elgg_echo('file:nofile');
-                       
-                       if ($ajax) {
-                               echo json_encode(array(
-                                       'status' => 'error',
-                                       'message' => $error
-                               ));
-                               exit;
-                       } else {
-                               register_error($error);
-                               forward(REFERER);
-                       }
-               }
-               
-               $file = new FilePluginFile();
-               $file->subtype = "file";
-               
-               // if no title on new upload, grab filename
-               if (empty($title)) {
-                       $title = $_FILES['upload']['name'];
+
+} else {
+       // load original file object
+       $file = new FilePluginFile($guid);
+       if (!$file) {
+               register_error(elgg_echo('file:cannotload'));
+               forward(REFERER);
+       }
+
+       // user must be able to edit file
+       if (!$file->canEdit()) {
+               register_error(elgg_echo('file:noaccess'));
+               forward(REFERER);
+       }
+}
+
+$file->title = $title;
+$file->description = $desc;
+$file->access_id = $access_id;
+$file->container_guid = $container_guid;
+
+$tags = explode(",", $tags);
+$file->tags = $tags;
+
+// we have a file upload, so process it
+if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
+
+       $prefix = "file/";
+
+       // if previous file, delete it
+       if ($new_file == false) {
+               $filename = $file->getFilenameOnFilestore();
+               if (file_exists($filename)) {
+                       unlink($filename);
                }
-       
+
+               // use same filename on the disk - ensures thumbnails are overwritten
+               $filestorename = $file->getFilename();
+               $filestorename = elgg_substr($filestorename, elgg_strlen($prefix));
        } else {
-               // load original file object
-               $file = get_entity($guid);
-               if (!$file) {
-                       register_error(elgg_echo('file:cannotload'));
-                       forward(REFERER);
-               }
-               
-               // user must be able to edit file
-               if (!$file->canEdit()) {
-                       register_error(elgg_echo('file:noaccess'));
-                       forward(REFERER);
-               }
+               $filestorename = elgg_strtolower(time().$_FILES['upload']['name']);
        }
-       
-       $file->title = $title;
-       $file->description = $desc;
-       $file->access_id = $access_id;
-       $file->container_guid = $container_guid;
-       
-       $tags = explode(",", $tags);
-       $file->tags = $tags;
-       
-       // we have a file upload, so process it
-       if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
-               
-               $prefix = "file/";
-               
-               // if previous file, delete it
-               if ($new_file == false) {
-                       $filename = $file->getFilenameOnFilestore();
-                       if (file_exists($filename)) {
-                               unlink($filename);
-                       }
-
-                       // use same filename on the disk - ensures thumbnails are overwritten
-                       $filestorename = $file->getFilename();
-                       $filestorename = elgg_substr($filestorename, elgg_strlen($prefix));
-               } else {
-                       $filestorename = elgg_strtolower(time().$_FILES['upload']['name']);
+
+       $file->setFilename($prefix.$filestorename);
+       $file->setMimeType($_FILES['upload']['type']);
+       $file->originalfilename = $_FILES['upload']['name'];
+       $file->simpletype = file_get_simple_type($_FILES['upload']['type']);
+
+       $file->open("write");
+       $file->write(get_uploaded_file('upload'));
+       $file->close();
+
+       $guid = $file->save();
+
+       // if image, we need to create thumbnails (this should be moved into a function)
+       if ($guid && $file->simpletype == "image") {
+               $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true);
+               if ($thumbnail) {
+                       $thumb = new ElggFile();
+                       $thumb->setMimeType($_FILES['upload']['type']);
+
+                       $thumb->setFilename($prefix."thumb".$filestorename);
+                       $thumb->open("write");
+                       $thumb->write($thumbnail);
+                       $thumb->close();
+
+                       $file->thumbnail = $prefix."thumb".$filestorename;
+                       unset($thumbnail);
                }
-               
-               $file->setFilename($prefix.$filestorename);
-               $file->setMimeType($_FILES['upload']['type']);
-               $file->originalfilename = $_FILES['upload']['name'];
-               $file->simpletype = get_general_file_type($_FILES['upload']['type']);
-       
-               $file->open("write");
-               $file->write(get_uploaded_file('upload'));
-               $file->close();
-               
-               $guid = $file->save();
-               
-               // if image, we need to create thumbnails (this should be moved into a function)
-               if ($guid && $file->simpletype == "image") {
-                       $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true);
-                       if ($thumbnail) {
-                               $thumb = new ElggFile();
-                               $thumb->setMimeType($_FILES['upload']['type']);
-                               
-                               $thumb->setFilename($prefix."thumb".$filestorename);
-                               $thumb->open("write");
-                               $thumb->write($thumbnail);
-                               $thumb->close();
-                               
-                               $file->thumbnail = $prefix."thumb".$filestorename;
-                               unset($thumbnail);
-                       }
-                       
-                       $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true);
-                       if ($thumbsmall) {
-                               $thumb->setFilename($prefix."smallthumb".$filestorename);
-                               $thumb->open("write");
-                               $thumb->write($thumbsmall);
-                               $thumb->close();
-                               $file->smallthumb = $prefix."smallthumb".$filestorename;
-                               unset($thumbsmall);
-                       }
-                       
-                       $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false);
-                       if ($thumblarge) {
-                               $thumb->setFilename($prefix."largethumb".$filestorename);
-                               $thumb->open("write");
-                               $thumb->write($thumblarge);
-                               $thumb->close();
-                               $file->largethumb = $prefix."largethumb".$filestorename;
-                               unset($thumblarge);
-                       }
+
+               $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true);
+               if ($thumbsmall) {
+                       $thumb->setFilename($prefix."smallthumb".$filestorename);
+                       $thumb->open("write");
+                       $thumb->write($thumbsmall);
+                       $thumb->close();
+                       $file->smallthumb = $prefix."smallthumb".$filestorename;
+                       unset($thumbsmall);
+               }
+
+               $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false);
+               if ($thumblarge) {
+                       $thumb->setFilename($prefix."largethumb".$filestorename);
+                       $thumb->open("write");
+                       $thumb->write($thumblarge);
+                       $thumb->close();
+                       $file->largethumb = $prefix."largethumb".$filestorename;
+                       unset($thumblarge);
                }
-       } else {
-               // not saving a file but still need to save the entity to push attributes to database
-               $file->save();
        }
-       
-       // make sure session cache is cleared
-       unset($_SESSION['uploadtitle']);
-       unset($_SESSION['uploaddesc']);
-       unset($_SESSION['uploadtags']);
-       unset($_SESSION['uploadaccessid']);
-       
-       // handle results differently for new files and file updates
-       // ajax is only for new files from embed right now.
-       if ($new_file) {
-               if ($guid) {
-                       $message = elgg_echo("file:saved");
-                       if ($ajax) {
-                               echo json_encode(array(
-                                       'status' => 'success',
-                                       'message' => $message
-                               ));
-                               exit;
-                               
-                       } else {
-                               system_message($message);
-                               add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid);
-                       }
+} else {
+       // not saving a file but still need to save the entity to push attributes to database
+       $file->save();
+}
+
+// file saved so clear sticky form
+elgg_clear_sticky_form('file');
+
+
+// handle results differently for new files and file updates
+// ajax is only for new files from embed right now.
+if ($new_file) {
+       if ($guid) {
+               $message = elgg_echo("file:saved");
+               if ($ajax) {
+                       echo json_encode(array(
+                               'status' => 'success',
+                               'message' => $message
+                       ));
+                       exit;
+
                } else {
-                       // failed to save file object - nothing we can do about this
-                       $error = elgg_echo("file:uploadfailed");
-                       
-                       if ($ajax) {
-                               echo json_encode(array(
-                                       'status' => 'error',
-                                       'message' => $error
-                               ));
-                               exit;
-                               
-                       } else {
-                               register_error($error);
-                       }
-               }
-       
-               if (!$ajax) {
-                       $container_user = get_entity($container_guid);
-                       forward(elgg_get_site_url() . "pg/file/" . $container_user->username);
+                       system_message($message);
+                       add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid);
                }
-       
        } else {
-               if ($guid) {
-                       system_message(elgg_echo("file:saved"));
+               // failed to save file object - nothing we can do about this
+               $error = elgg_echo("file:uploadfailed");
+
+               if ($ajax) {
+                       echo json_encode(array(
+                               'status' => 'error',
+                               'message' => $error
+                       ));
+                       exit;
+
                } else {
-                       register_error(elgg_echo("file:uploadfailed"));
+                       register_error($error);
                }
-               
-               forward($file->getURL());
-       }       
+       }
+
+       if (!$ajax) {
+               $container_user = get_entity($container_guid);
+               forward(elgg_get_site_url() . "pg/file/" . $container_user->username);
+       }
+
+} else {
+       if ($guid) {
+               system_message(elgg_echo("file:saved"));
+       } else {
+               register_error(elgg_echo("file:uploadfailed"));
+       }
+
+       forward($file->getURL());
+}      
index 7397bfa4bf06328dd8810c9329656e95dba9bc18..edf9142317e8b356a27dace331fef0c428755e79 100644 (file)
@@ -13,4 +13,19 @@ class FilePluginFile extends ElggFile {
        public function __construct($guid = null) {
                parent::__construct($guid);
        }
+
+       public function delete() {
+
+               $thumbnails = array($this->thumbnail, $this->smallthumb, $this->largethumb);
+               foreach ($thumbnails as $thumbnail) {
+                       if ($thumbnail) {
+                               $delfile = new ElggFile();
+                               $delfile->owner_guid = $this->owner_guid;
+                               $delfile->setFilename($thumbnail);
+                               $delfile->delete();
+                       }
+               }
+
+               return parent::delete();
+       }
 }
index da22cacdf94de5f9c2c8b51e04a7390c9a9118d1..aa4b60a83892f5bbd9cfefcb61a95150b3444e93 100644 (file)
@@ -5,33 +5,37 @@
  * @package ElggFile
  */
 
+elgg_load_library('elgg:file');
+
 gatekeeper();
 
 $file_guid = (int) get_input('guid');
-$file = get_entity($file_guid);
+$file = new FilePluginFile($file_guid);
 if (!$file) {
        forward();
 }
+if (!$file->canEdit()) {
+       forward();
+}
+
+$title = elgg_echo('file:edit');
 
 elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
 elgg_push_breadcrumb($file->title, $file->getURL());
-elgg_push_breadcrumb(elgg_echo('file:edit'));
+elgg_push_breadcrumb($title);
 
 elgg_set_page_owner_guid($file->getContainerGUID());
 
-if (!$file->canEdit()) {
-       forward();
-}
-
-$title = elgg_echo('file:edit');
-$content = elgg_view_title($title);
-$content .= elgg_view("file/upload", array('entity' => $file));
+$form_vars = array('enctype' => 'multipart/form-data');
+$body_vars = file_prepare_form_vars($file);
+var_dump($body_vars);
+$content = elgg_view_form('file/upload', $form_vars, $body_vars);
 
 $body = elgg_view_layout('content', array(
        'content' => $content,
        'title' => $title,
        'filter' => '',
-       'header' => '',
+       'buttons' => '',
 ));
 
 echo elgg_view_page($title, $body);
index 201f86f62a3a99ee212ffa12cf10a22652f54cf2..795aa21ceefd7df614df2ca6034cfc3400e480c3 100644 (file)
@@ -5,36 +5,28 @@
  * @package ElggFile
  */
 
+$owner = elgg_get_page_owner();
+
 elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
 elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
 
 
-$owner = elgg_get_page_owner();
-
-$title = elgg_echo("file:friends",array($owner->name));
+$title = elgg_echo("file:friends", array($owner->name));
 
-elgg_push_context('search');
 // offset is grabbed in list_user_friends_objects
 $content = list_user_friends_objects($owner->guid, 'file', 10, false);
-elgg_pop_context();
-
-$area1 .= get_filetype_cloud($owner->guid, true);
-
-// handle case where friends don't have any files
-if (empty($content)) {
-       $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>";
-} else {
-       $area2 .= $content;
+if (!$content) {
+       $content = elgg_echo("file:none");
 }
 
-//get the latest comments on all files
-$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc");
-$area3 = elgg_view('comments/latest', array('comments' => $comments));
+$sidebar = file_get_type_cloud($owner->guid, true);
 
 $body = elgg_view_layout('content', array(
        'filter_context' => 'friends',
        'content' => $content,
        'title' => $title,
+       'sidebar' => $sidebar,
 ));
 
 echo elgg_view_page($title, $body);
index bdda62786e6588cfd2e073dc6fe4db248592886f..940f9c30f035d81077c0eeef6347c3c2a5724567 100644 (file)
@@ -45,7 +45,7 @@ if ($owner->guid == get_loggedin_userid()) {
        }
 }
 
-// Get objects
+// List files
 $content = elgg_list_entities(array(
        'types' => 'object',
        'subtypes' => 'file',
@@ -53,20 +53,18 @@ $content = elgg_list_entities(array(
        'limit' => 10,
        'full_view' => FALSE,
 ));
-
-$get_filter = get_filetype_cloud(elgg_get_page_owner_guid());
-if ($get_filter) {
-       $area1 .= $get_filter;
-} else {
-       $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>";
+if (!$content) {
+       $content = elgg_echo("file:none");
 }
 
-//get the latest comments on the current users files
-$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,elgg_get_page_owner_guid());
-$area3 = elgg_view('comments/latest', array('comments' => $comments));
+$sidebar = file_get_type_cloud(elgg_get_page_owner_guid());
+if (elgg_instanceof($owner, 'user')) {
+       $sidebar .= elgg_view_latest_comments(elgg_get_page_owner_guid(), 'object', 'file');
+}
 
 $params['content'] = $content;
 $params['title'] = $title;
+$params['sidebar'] = $sidebar;
 
 $body = elgg_view_layout('content', $params);
 
index f06124031ec79018774102cefe468b1fa778f71c..14de64ed5d78c5f50c02e2ec5917c3e889c16cf8 100644 (file)
@@ -28,6 +28,8 @@ $english = array(
        'file:via' => 'via files',
        'file:upload' => "Upload a file",
        'file:replace' => 'Replace file content (leave blank to not change file)',
+       'file:list:title' => "%s's %s %s",
+       'file:title:friends' => "Friends'",
 
        'file:new' => 'Upload a file',
 
@@ -38,6 +40,7 @@ $english = array(
 
        'file:types' => "Uploaded file types",
 
+       'file:type:' => 'Files',
        'file:type:all' => "All files",
        'file:type:video' => "Videos",
        'file:type:document' => "Documents",
diff --git a/mod/file/lib/file.php b/mod/file/lib/file.php
new file mode 100644 (file)
index 0000000..6ca49e9
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * File helper functions
+ *
+ * @package ElggFile
+ */
+
+/**
+ * Prepare the upload/edit form variables
+ *
+ * @param FilePluginFile $file
+ * @return array
+ */
+function file_prepare_form_vars($file = null) {
+
+       // input names => defaults
+       $values = array(
+               'title' => '',
+               'description' => '',
+               'access_id' => ACCESS_DEFAULT,
+               'tags' => '',
+               'container_guid' => elgg_get_page_owner_guid(),
+               'guid' => null,
+               'entity' => $file,
+       );
+
+       if ($file) {
+               foreach (array_keys($values) as $field) {
+                       $values[$field] = $file->$field;
+               }
+       }
+
+       if (elgg_is_sticky_form('file')) {
+               foreach (array_keys($values) as $field) {
+                       $values[$field] = elgg_get_sticky_value('file', $field);
+               }
+       }
+
+       elgg_clear_sticky_form('file');
+
+       return $values;
+}
index 0e541c276f1d97f6e8d2082e76d18c4196ecbd95..157b5b8b81eedfcdded6a3543b58af91676d97f8 100644 (file)
@@ -8,93 +8,91 @@
 // Load Elgg engine
 require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
 
+$page_owner_guid = get_input('page_owner', null);
+if ($page_owner_guid) {
+       elgg_set_page_owner_guid($page_owner_guid);
+}
+$owner = elgg_get_page_owner();
+
+group_gatekeeper();
 
 // Get input
 $md_type = 'simpletype';
 $tag = get_input('tag');
 $listtype = get_input('listtype');
+$friends = get_input('friends', false);
 
-$friends = (int) get_input('friends_guid', 0);
-if ($friends) {
-       if ($owner_guid = get_user_friends($user_guid, "", 999999, 0)) {
-               foreach ($owner_guid as $key => $friend)
-                       $owner_guid[$key] = (int) $friend->getGUID();
+
+// breadcrumbs
+elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
+if ($owner) {
+       if (elgg_instanceof($owner, 'user')) {
+               elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username");
        } else {
-               $owner_guid = array();
-       }
-} else {
-       $owner_guid = get_input('owner_guid', 0);
-       if (substr_count($owner_guid, ',')) {
-               $owner_guid = explode(",", $owner_guid);
+               elgg_push_breadcrumb($owner->name, "pg/file/group/$owner->guid/owner");
        }
 }
-$page_owner = get_input('page_owner', 0);
-if ($page_owner) {
-       set_page_owner($page_owner);
+if ($friends && $owner) {
+       elgg_push_breadcrumb(elgg_echo('friends'), "pg/file/friends/$owner->username");
+}
+if ($tag) {
+       elgg_push_breadcrumb(elgg_echo("file:type:$tag"));
 } else {
-       if ($friends) {
-               set_page_owner($friends);
-       } else {
-               if ($owner_guid > 0 && !is_array($owner_guid))
-                       set_page_owner($owner_guid);
-       }
+       elgg_push_breadcrumb(elgg_echo('all'));
 }
 
-if (is_callable('group_gatekeeper'))
-       group_gatekeeper();
-
-if (empty($tag)) {
-       $title = elgg_echo('file:type:all');
-       $area2 = elgg_view_title(elgg_echo('file:type:all'));
-       $area2 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'file'));
+// title
+if (!$owner) {
+       // world files
+       $title = elgg_echo('all') . ' ' . elgg_echo("file:type:$tag");
 } else {
-       $title = elgg_echo('searchtitle', array($tag));
-       if (is_array($owner_guid)) {
-               //$area2 = elgg_view_title(elgg_echo("file:friends:type:" . $tag));
-               $area2 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file'));
-       } else if (elgg_get_page_owner_guid() && elgg_get_page_owner_guid() != get_loggedin_userid()) {
-               //$area2 = elgg_view_title(elgg_echo("file:user:type:" . $tag,array(elgg_get_page_owner()->name)));
-               $area2 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'file'));
-       } else {
-               //$area2 = elgg_view_title(elgg_echo("file:type:" . $tag));
-               $area2 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'file'));
-       }
+       $friend_string = $friends ? elgg_echo('file:title:friends') : '';
+       $type_string = elgg_echo("file:type:$tag");
+       $title = elgg_echo('file:list:title', array($owner->name, $friend_string, $type_string));
 }
+
+
+$sidebar = file_get_type_cloud($page_owner_guid, $friends);
+
 if ($friends) {
-       $area1 = get_filetype_cloud($friends, true);
-} else if ($owner_guid) {
-       $area1 = get_filetype_cloud($owner_guid);
-} else {
-       $area1 = get_filetype_cloud();
+       // elgg_does not support getting objects that belong to an entity's friends
+       $friend_entities = get_user_friends($page_owner_guid, "", 999999, 0);
+       if ($friend_entities) {
+               $friend_guids = array();
+               foreach ($friend_entities as $friend) {
+                       $friend_guids[] = $friend->getGUID();
+               }
+       }
+       $page_owner_guid = $friend_guids;
 }
 
-elgg_push_context('search');
-
-$offset = (int) get_input('offset', 0);
 $limit = 10;
-
 if ($listtype == "gallery") {
        $limit = 12;
 }
 
-if (!empty($tag)) {
-       $params = array(
-               'metadata_name' => $md_type,
-               'metadata_value' => $tag,
-               'types' => 'object',
-               'subtypes' => 'file',
-               'owner_guid' => $owner_guid,
-               'limit' => $limit,
-       );
-       $area2 .= elgg_list_entities_from_metadata($params);
+$params = array(
+       'types' => 'object',
+       'subtypes' => 'file',
+       'container_guid' => $page_owner_guid,
+       'limit' => $limit,
+       'full_view' => false,
+);
+
+if ($tag) {
+       $params['metadata_name'] = $md_type;
+       $params['metadata_value'] = $tag;
+       $content = elgg_list_entities_from_metadata($params);
 } else {
-       $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset));
+       $content = elgg_list_entities($params);
 }
 
-elgg_pop_context();
-
-$content = "<div class='files'>" . $area1 . $area2 . "</div>";
-
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content));
+$body = elgg_view_layout('content', array(
+       'filter' => '',
+       'buttons' => '',
+       'content' => $content,
+       'title' => $title,
+       'sidebar' => $sidebar,
+));
 
 echo elgg_view_page($title, $body);
\ No newline at end of file
index d58940f4069595bb8084e75059a0e3767aa028ad..46503b3a7b542cb1bef28192094a75e6bd9ec62f 100644 (file)
@@ -1,16 +1,19 @@
 <?php
 /**
- * Elgg file browser
+ * Elgg file plugin
  *
  * @package ElggFile
  */
 
+elgg_register_event_handler('init', 'system', 'file_init');
 
 /**
  * File plugin initialisation functions.
  */
 function file_init() {
-       global $CONFIG;
+
+       // register a library of helper functions
+       elgg_register_library('elgg:file', elgg_get_plugin_path() . 'file/lib/file.php');
 
        // Site navigation
        $item = new ElggMenuItem('file', elgg_echo('file'), 'pg/file/all');
@@ -20,7 +23,7 @@ function file_init() {
        elgg_extend_view('css/screen', 'file/css');
 
        // extend group main page
-       elgg_extend_view('groups/tool_latest', 'file/groupprofile_files');
+       elgg_extend_view('groups/tool_latest', 'file/group_module');
 
        // Register a page handler, so we can have nice URLs
        register_page_handler('file', 'file_page_handler');
@@ -40,11 +43,20 @@ function file_init() {
        // add the group files tool option
        add_group_tool_option('file', elgg_echo('groups:enablefiles'), true);
 
-       // Register entity type
+       // Register entity type for search
        register_entity_type('object', 'file');
 
+       // add a file link to owner blocks
        elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'file_owner_block_menu');
 
+       // Register actions
+       $action_path = elgg_get_plugin_path() . 'file/actions/file';
+       elgg_register_action("file/upload", "$action_path/upload.php");
+       elgg_register_action("file/delete", "$action_path/delete.php");
+       // temporary - see #2010
+       elgg_register_action("file/download", "$action_path/download.php");
+
+
        // embed support
        elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'file_embed_get_sections');
        elgg_register_plugin_hook_handler('embed_get_items', 'file', 'file_embed_get_items');
@@ -110,19 +122,18 @@ function file_page_handler($page) {
 }
 
 /**
-        * Returns a more meaningful message
       *
       * @param unknown_type $hook
       * @param unknown_type $entity_type
       * @param unknown_type $returnvalue
       * @param unknown_type $params
-*/
+ * Creates the notification message body
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
 function file_notify_message($hook, $entity_type, $returnvalue, $params) {
        $entity = $params['entity'];
        $to_entity = $params['to_entity'];
        $method = $params['method'];
-       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'file'))
-       {
+       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'file')) {
                $descr = $entity->description;
                $title = $entity->title;
                global $CONFIG;
@@ -168,9 +179,9 @@ function file_owner_block_menu($hook, $type, $return, $params) {
  * @param string $mimetype The MIME type
  * @return string The overall type
  */
-function get_general_file_type($mimetype) {
+function file_get_simple_type($mimetype) {
 
-       switch($mimetype) {
+       switch ($mimetype) {
                case "application/msword":
                        return "document";
                        break;
@@ -179,58 +190,81 @@ function get_general_file_type($mimetype) {
                        break;
        }
 
-       if (substr_count($mimetype,'text/'))
+       if (substr_count($mimetype, 'text/')) {
                return "document";
+       }
 
-       if (substr_count($mimetype,'audio/'))
+       if (substr_count($mimetype, 'audio/')) {
                return "audio";
+       }
 
-       if (substr_count($mimetype,'image/'))
+       if (substr_count($mimetype, 'image/')) {
                return "image";
+       }
 
-       if (substr_count($mimetype,'video/'))
+       if (substr_count($mimetype, 'video/')) {
                return "video";
+       }
 
-       if (substr_count($mimetype,'opendocument'))
+       if (substr_count($mimetype, 'opendocument')) {
                return "document";
+       }
 
        return "general";
 }
 
+// deprecated and will be removed
+function get_general_file_type($mimetype) {
+       elgg_deprecated_notice('Use file_get_simple_type() instead of get_general_file_type()', 1.8);
+       return file_get_simple_type($mimetype);
+}
+
 /**
- * Returns a list of filetypes to search specifically on
+ * Returns a list of filetypes
  *
- * @param int|array $owner_guid The GUID(s) of the owner(s) of the files
- * @param true|false $friends Whether we're looking at the owner or the owner's friends
+ * @param int       $container_guid The GUID of the container of the files
+ * @param bool      $friends        Whether we're looking at the container or the container's friends
  * @return string The typecloud
  */
-function get_filetype_cloud($owner_guid = "", $friends = false) {
+function file_get_type_cloud($container_guid = "", $friends = false) {
+
+       $container_guids = $container_guid;
 
        if ($friends) {
-               if ($friendslist = get_user_friends($user_guid, "", 999999, 0)) {
-                       $friendguids = array();
-                       foreach($friendslist as $friend) {
-                               $friendguids[] = $friend->getGUID();
+               // tags interface does not support pulling tags on friends' content so
+               // we need to grab all friends
+               $friend_entities = get_user_friends($container_guid, "", 999999, 0);
+               if ($friend_entities) {
+                       $friend_guids = array();
+                       foreach ($friend_entities as $friend) {
+                               $friend_guids[] = $friend->getGUID();
                        }
                }
-               $friendofguid = $owner_guid;
-               $owner_guid = $friendguids;
-       } else {
-               $friendofguid = false;
+               $container_guids = $friend_guids;
        }
 
        elgg_register_tag_metadata_name('simpletype');
        $options = array(
                'type' => 'object',
                'subtype' => 'file',
-               'owner_guid' => $owner_guid,
+               'container_guids' => $container_guids,
                'threshold' => 0,
                'limit' => 10,
                'tag_names' => array('simpletype')
        );
        $types = elgg_get_tags($options);
 
-       return elgg_view('file/typecloud',array('owner_guid' => $owner_guid, 'friend_guid' => $friendofguid, 'types' => $types));
+       $params = array(
+               'friends' => $friends,
+               'types' => $types,
+       );
+
+       return elgg_view('file/typecloud', $params);
+}
+
+function get_filetype_cloud($owner_guid = "", $friends = false) {
+       elgg_deprecated_notice('Use file_get_type_cloud instead of get_filetype_cloud', 1.8);
+       return file_get_type_cloud($owner_guid, $friends);
 }
 
 /**
@@ -298,7 +332,6 @@ function file_embed_get_upload_sections($hook, $type, $value, $params) {
        return $value;
 }
 
-
 /**
  * Populates the ->getUrl() method for file objects
  *
@@ -310,14 +343,3 @@ function file_url($entity) {
        $title = elgg_get_friendly_title($title);
        return "pg/file/view/" . $entity->getGUID() . "/" . $title;
 }
-
-// Make sure test_init is called on initialisation
-elgg_register_event_handler('init','system','file_init');
-
-// Register actions
-elgg_register_action("file/upload", $CONFIG->pluginspath . "file/actions/file/upload.php");
-elgg_register_action("file/save", $CONFIG->pluginspath . "file/actions/file/save.php");
-elgg_register_action("file/delete", $CONFIG->pluginspath. "file/actions/file/delete.php");
-
-// temporary - see #2010
-elgg_register_action("file/download", $CONFIG->pluginspath. "file/actions/file/download.php");
index ef0899f20595af113635adc07a377610faeddbca..f5fab81f4bc2e687378d5f24583684d6f584d8f2 100644 (file)
@@ -5,32 +5,35 @@
  * @package ElggFile
  */
 
+elgg_load_library('elgg:file');
+
 elgg_set_page_owner_guid(get_input('guid'));
 $owner = elgg_get_page_owner();
 
 gatekeeper();
 group_gatekeeper();
 
+$title = elgg_echo('file:new');
+
+// set up breadcrumbs
 elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
 if (elgg_instanceof($owner, 'user')) {
        elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username");
 } else {
        elgg_push_breadcrumb($owner->name, "pg/file/group/$owner->guid/owner");
 }
-elgg_push_breadcrumb(elgg_echo('file:new'));
-
-$container_guid = elgg_get_page_owner_guid();
-
-$title = elgg_echo('file:upload');
+elgg_push_breadcrumb($title);
 
-$content = elgg_view_title($title);
+// create form
+$form_vars = array('enctype' => 'multipart/form-data');
+$body_vars = file_prepare_form_vars();
+$content = elgg_view_form('file/upload', $form_vars, $body_vars);
 
-$content .= elgg_view("file/upload", array('container_guid' => $container_guid));
 $body = elgg_view_layout('content', array(
        'content' => $content,
        'title' => $title,
        'filter' => '',
-       'header' => '',
+       'buttons' => '',
 ));
 
 echo elgg_view_page($title, $body);
index d4d1a2c134e49d0b9ab0b9f63315af9d90e16878..53fa94e460b6dffd74879b71b73e1720181ca536 100644 (file)
 .file-gallery-item img {
        margin: 5px 0;
 }
-
-
-.files .entity-listing .entity-listing-info {
-       width:453px;
-}
-.files .entity-listing:hover {
-       background-color: white;
-}
-
-/* files - single entity view */
-.filerepo_title_owner_wrapper .filerepo_title,
-.filerepo_title_owner_wrapper .filerepo_owner,
-.filerepo_file .filerepo_maincontent {
-       margin-left: 70px !important;
-}
-.filerepo_owner_details {
-       margin:0;
-       padding:0;
-       line-height: 1.2em;
-}
-.filerepo_owner_details small {
-       color:#666666;
-}
-.filerepo_owner .elgg-user-icon {
-       margin: 3px 5px 5px 0;
-       float: left;
-}
-.filerepo_file .filerepo_icon {
-       width: 70px;
-       position: absolute;
-       margin:5px 0 10px 0;
-}
-.filerepo_file .filerepo_title {
-       margin:0;
-       padding:7px 4px 10px 0;
-       line-height: 1.2em;
-}
-.filerepo_file .filerepo_description {
-       margin:10px 0 0 0;
-}
-.filerepo_file .filerepo_description p {
-       padding:0 0 5px 0;
-       margin:0;
-}
-.filerepo_file .filerepo_specialcontent img {
-       padding:10px;
-       margin-bottom:10px;
-       -webkit-border-radius: 6px; 
-       -moz-border-radius: 6px;
-       background: #333333; 
-}
-
-
-/* files - gallery view */
-.entity_gallery_item .filerepo_gallery_item {
-       margin:10px 10px 0 0;
-       padding:5px;
-       text-align:center;
-       background-color: #eeeeee;
-       -webkit-border-radius: 6px; 
-       -moz-border-radius: 6px;
-       width:165px;
-}
-.entity_gallery_item .filerepo_gallery_item:hover {
-       background-color: #999999;
-}
-.filerepo_download,
-.filerepo_controls {
-       padding:0 0 1px 0;
-       margin:0 0 10px 0;
-}
-.entity_gallery .filerepo_title {
-       font-weight: bold;
-       line-height: 1.1em;
-       margin:0 0 10px 0;
-}
-.filerepo_gallery_item p {
-       margin:0;
-       padding:0;
-}
-.filerepo_gallery_item .filerepo_controls {
-       margin-top:10px;
-}
-.filerepo_gallery_item .filerepo_controls a {
-       padding-right:10px;
-       padding-left:10px;
-}
-.entity_gallery .filerepo_comments {
-       font-size:90%;
-}
-.filerepo_user_gallery_link {
-       float:right;
-       margin:5px 5px 5px 50px;
-}
-.filerepo_user_gallery_link a {
-       padding:2px 25px 5px 0;
-       background: transparent url(<?php echo elgg_get_site_url(); ?>mod/file/graphics/icon_gallery.gif) no-repeat right top;
-       display:block;
-}
-.filerepo_user_gallery_link a:hover {
-       background-position: right -40px;
-}
-
-
-
-
-
-
diff --git a/mod/file/views/default/file/group_module.php b/mod/file/views/default/file/group_module.php
new file mode 100644 (file)
index 0000000..babdcf6
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Group file module
+ */
+
+$group = elgg_get_page_owner();
+
+if ($group->file_enable == "no") {
+       return true;
+}
+
+$all_link = elgg_view('output/url', array(
+       'href' => "pg/file/group/$group->guid/owner",
+       'text' => elgg_echo('link:view:all'),
+));
+
+$header = "<span class=\"group-widget-viewall\">$all_link</span>";
+$header .= '<h3>' . elgg_echo('file:group') . '</h3>';
+
+
+elgg_push_context('widgets');
+$options = array(
+       'type' => 'object',
+       'subtype' => 'file',
+       'container_guid' => elgg_get_page_owner_guid(),
+       'limit' => 6,
+       'full_view' => false,
+       'pagination' => false,
+);
+$content = elgg_list_entities($options);
+elgg_pop_context();
+
+if (!$content) {
+       $content = '<p>' . elgg_echo('file:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+       'href' => "pg/file/new/$group->guid",
+       'text' => elgg_echo('file:new'),
+));
+$content .= "<span class='elgg-widget-more'>$new_link</span>";
+
+
+$params = array(
+       'header' => $header,
+       'body' => $content,
+);
+echo elgg_view('layout/objects/module', $params);
diff --git a/mod/file/views/default/file/groupprofile_files.php b/mod/file/views/default/file/groupprofile_files.php
deleted file mode 100644 (file)
index 5cbf75b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-    // Files on group profile page
-
-    //check to make sure group files is activated
-    if($vars['entity']->file_enable != 'no'){
-
-?>
-<div class="group_tool_widget files">
-<h3><?php echo elgg_echo("file:group"); ?></h3>
-
-<?php
-
-       //the number of files to display
-       $number = (int) $vars['entity']->num_display;
-       if (!$number)
-               $number = 6;
-
-       //get the group's files
-       $files = elgg_get_entities(array('type' => 'object',
-                                                                       'subtype' => 'file',
-                                                                       'container_guid' => $vars['entity']->guid,
-                                                                       'limit' => $number
-       ));
-
-       //if there are some files, go get them
-       if ($files) {
-
-            //display in list mode
-            foreach($files as $f){
-
-                $mime = $f->mimetype;
-                echo "<div class='entity-listing clearfix'>";
-               echo "<div class='entity-listing-icon'><a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a></div>";
-               echo "<div class='entity-listing-info'>";
-               echo "<p class='entity-title'>" . $f->title . "</p>";
-               echo "<p class='entity-subtext'>" . elgg_view_friendly_time($f->time_created) . "</p>";
-                       echo "</div></div>";
-
-               }
-
-
-        //get a link to the users files
-        $users_file_url = elgg_get_site_url() . "pg/file/group/" . elgg_get_page_owner()->guid;
-
-        echo "<p><a href=\"{$users_file_url}\">" . elgg_echo('file:more') . "</a></p>";
-
-       } else {
-
-               echo "<p class='margin-top'>" . elgg_echo("file:none") . "</p>";
-
-       }
-
-?>
-</div>
-
-<?php
-       }//end of activate check statement
-?>
\ No newline at end of file
index 63756a95272fc97907f609aef536c5f2c6892b94..391afd0c8d900f9d397b1ea939ebb93c50240744 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 $mime = $vars['mimetype'];
-$simple_type = get_general_file_type($mime);
+$simple_type = file_get_simple_type($mime);
 
 // is this request for an image thumbnail
 $thumbnail = elgg_get_array_value('thumbnail', $vars, false);
index bb322d4d7b6e8db0836e63c0cc9d372ef1efca7c..4a59d8a7c47e0c7491ec7833ea4cc59541634160 100644 (file)
@@ -1,59 +1,50 @@
 <?php
+/**
+ * Type cloud
+ */
 
-       $types = $vars['types'];
+function file_type_cloud_get_url($type, $friends) {
+       $url = elgg_get_site_url() . "mod/file/search.php?subtype=file";
 
-       if (is_array($vars['types']) && sizeof($vars['types'])) {
+       if ($type->tag != "all") {
+               $url .= "&md_type=simpletype&tag=" . urlencode($type->tag);
+       }
 
-?>
-<ul>
-<?php
+       if ($friends) {
+               $url .= "&friends=$friends";
+       } 
 
-       $all = new stdClass;
-       $all->tag = "all";
-       $vars['types'][] = $all;
-       $vars['types'] = array_reverse($vars['types']);
-       foreach($vars['types'] as $type) {
-
-               $tag = $type->tag;
-               if ($tag != "all") {
-                       $label = elgg_echo("file:type:" . $tag);
-               } else {
-                       $label = elgg_echo('all');
-               }
-
-               $url = elgg_get_site_url() . "mod/file/search.php?subtype=file";
-               if ($tag != "all")
-                       $url .= "&md_type=simpletype&tag=" . urlencode($tag);
-               if (isset($vars['friend_guid']) && $vars['friend_guid'] != false) {
-                       $url .= "&friends_guid={$vars['friend_guid']}";
-               } else if ($vars['owner_guid'] != "") {
-                       if (is_array($vars['owner_guid'])) {
-                               $owner_guid = implode(",",$vars['owner_guid']);
-                       } else {
-                               $owner_guid = $vars['owner_guid'];
-                       }
-                       $url .= "&owner_guid={$owner_guid}";
-               }
-               if ($tag == "image")
-                       $url .= "&listtype=gallery";
+       if ($type->tag == "image") {
+               $url .= "&listtype=gallery";
+       }
 
+       if (elgg_get_page_owner_guid()) {
                $url .= "&page_owner=" . elgg_get_page_owner_guid();
+       }
 
-               $inputtag = get_input('tag');
-               if ($inputtag == $tag || (empty($inputtag) && $tag == "all")) {
-                       $class = " class=\"selected\" ";
-               } else {
-                       $class = "";
-               }
+       return $url;
+}
 
-               add_submenu_item($label, $url, 'filetypes');
-       }
 
-?>
-</ul>
+$types = elgg_get_array_value('types', $vars, array());
+if (!$types) {
+       return true;
+}
 
-<?php
+$friends = elgg_get_array_value('friends', $vars, false);
 
-       }
+$all = new stdClass;
+$all->tag = "all";
+elgg_register_menu_item('page', array(
+       'name' => 'file:all',
+       'title' => elgg_echo('all'),
+       'url' =>  file_type_cloud_get_url($all, $friends),
+));
 
-?>
\ No newline at end of file
+foreach ($types as $type) {
+       elgg_register_menu_item('page', array(
+               'name' => "file:$type->tag",
+               'title' => elgg_echo("file:type:$type->tag"),
+               'url' =>  file_type_cloud_get_url($type, $friends),
+       ));
+}
diff --git a/mod/file/views/default/file/upload.php b/mod/file/views/default/file/upload.php
deleted file mode 100644 (file)
index 041bd92..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * Elgg file browser uploader
- *
- * @package ElggFile
- */
-
-global $CONFIG;
-
-if (isset($vars['entity'])) {
-       $action_type = "update";
-       $action = "file/upload";
-       $title = $vars['entity']->title;
-       $description = $vars['entity']->description;
-       $tags = $vars['entity']->tags;
-       $access_id = $vars['entity']->access_id;
-       $container_guid = $vars['entity']->container_guid;
-} else  {
-       $action_type = "new";
-       $action = "file/upload";
-       $title = isset($_SESSION['uploadtitle']) ? $_SESSION['uploadtitle'] : '';
-       $description = isset($_SESSION['uploaddesc']) ? $_SESSION['uploaddesc'] : '';
-       $tags = isset($_SESSION['uploadtags']) ? $_SESSION['uploadtags'] : '';
-       if (defined('ACCESS_DEFAULT')) {
-               $access_id = ACCESS_DEFAULT;
-       } else {
-               $access_id = 0;
-       }
-       $access_id = isset($_SESSION['uploadaccessid']) ? $_SESSION['uploadaccessid'] : $access_id;
-       $container_guid = elgg_get_page_owner_guid();
-}
-
-// make sure session cache is cleared
-unset($_SESSION['uploadtitle']);
-unset($_SESSION['uploaddesc']);
-unset($_SESSION['uploadtags']);
-unset($_SESSION['uploadaccessid']);
-       
-       
-?>
-<form action="<?php echo elgg_get_site_url(); ?>action/<?php echo $action; ?>" enctype="multipart/form-data" method="post" class="margin-top">
-<p>
-       <label>
-<?php
-       echo elgg_view('input/securitytoken');
-       if ($action_type == "new") {
-               echo elgg_echo("file:file");
-       } else {
-               echo elgg_echo("file:replace");
-       }
-?>
-<br />
-<?php
-
-       echo elgg_view("input/file",array('internalname' => 'upload'));
-                       
-?>
-       </label>
-</p>
-<p>
-       <label><?php echo elgg_echo("title"); ?><br />
-<?php
-
-       echo elgg_view("input/text", array(
-                                                                       "internalname" => "title",
-                                                                       "value" => $title,
-                                                                                                       ));
-                       
-?>
-       </label>
-</p>
-<p class="longtext_inputarea">
-       <label><?php echo elgg_echo("description"); ?></label>
-<?php
-
-       echo elgg_view("input/longtext",array(
-                                                                       "internalname" => "description",
-                                                                       "value" => $description,
-                                                                                                       ));
-?>
-</p>
-<p>
-       <label><?php echo elgg_echo("tags"); ?><br />
-<?php
-
-       echo elgg_view("input/tags", array(
-                                                                       "internalname" => "tags",
-                                                                       "value" => $tags,
-                                                                                                       ));
-                       
-?>
-       </label>
-</p>
-<?php
-
-       $categories = elgg_view('categories',$vars);
-       if (!empty($categories)) {
-?>
-
-               <p>
-                       <?php echo $categories; ?>
-               </p>
-
-<?php
-               }
-
-?>
-<p>
-       <label>
-               <?php echo elgg_echo('access'); ?><br />
-               <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>
-       </label>
-</p>
-       
-<p>
-<?php
-
-       echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$container_guid}\" />";
-       
-       if (isset($vars['entity'])) {
-               echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />";
-       }
-       
-?>
-       <input type="submit" value="<?php echo elgg_echo("save"); ?>" />
-</p>
-
-</form>
\ No newline at end of file
diff --git a/mod/file/views/default/forms/file/upload.php b/mod/file/views/default/forms/file/upload.php
new file mode 100644 (file)
index 0000000..f3012ea
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Elgg file upload/save form
+ *
+ * @package ElggFile
+ */
+
+// once elgg_view stops throwing all sorts of junk into $vars, we can use 
+$title = elgg_get_array_value('title', $vars, '');
+$desc = elgg_get_array_value('description', $vars, '');
+$tags = elgg_get_array_value('tags', $vars, '');
+$access_id = elgg_get_array_value('access_id', $vars, ACCESS_DEFAULT);
+$container_guid = elgg_get_array_value('container_guid', $vars);
+$guid = elgg_get_array_value('guid', $vars, null);
+
+if ($guid) {
+       $file_label = elgg_echo("file:replace");
+} else {
+       $file_label = elgg_echo("file:file");
+}
+
+?>
+<p>
+       <label><?php echo $file_label; ?></label><br />
+       <?php echo elgg_view('input/file', array('internalname' => 'upload')); ?>
+</p>
+<p>
+       <label><?php echo elgg_echo('title'); ?></label><br />
+       <?php echo elgg_view('input/text', array('internalname' => 'title', 'value' => $title)); ?>
+</p>
+<p>
+       <label><?php echo elgg_echo('description'); ?></label>
+       <?php echo elgg_view('input/longtext', array('internalname' => 'description', 'value' => $desc)); ?>
+</p>
+<p>
+       <label><?php echo elgg_echo('tags'); ?></label>
+       <?php echo elgg_view('input/tags', array('internalname' => 'tags', 'value' => $tags)); ?>
+</p>
+<?php
+
+$categories = elgg_view('categories', $vars);
+if ($categories) {
+       echo "<p>$categories</p>";
+}
+
+?>
+<p>
+       <label><?php echo elgg_echo('access'); ?></label><br />
+       <?php echo elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id)); ?>
+</p>
+<p>
+<?php
+
+echo elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $container_guid));
+       
+if ($guid) {
+       echo elgg_view('input/hidden', array('internalname' => 'file_guid', 'value' => $guid));
+}
+
+echo elgg_view('input/submit', array('value' => elgg_echo("save")));
+
+?>
+</p>
index 130b5e3ded6235b2a6f9d17b3ba9cc24b24856c1..d2cd246ae2c608d81acc89f03debe20d26defe56 100644 (file)
@@ -6,65 +6,27 @@
  */
 
 
-$owner_guid = $vars['entity']->owner_guid;
-$number = $vars['entity']->num_display;
+$num = $vars['entity']->num_display;
 
-//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
 $options = array(
        'type' => 'object',
        'subtype' => 'file',
-       'limit' => $number,
-       'container_guid' => $owner_guid
+       'container_guid' => $vars['entity']->owner_guid,
+       'limit' => $num,
+       'full_view' => FALSE,
+       'pagination' => FALSE,
 );
-$files = elgg_get_entities($options);
-
-//if there are some files, go get them
-if ($files) {
-
-       echo "<div id='filerepo_widget_layout'>";
-
-       if ($view == "gallery") {
-
-               echo "<div class='filerepo_widget_galleryview'>";
+$content = elgg_list_entities($options);
 
-               //display in gallery mode
-               foreach ($files as $f) {
+echo $content;
 
-                       $mime = $f->mimetype;
-                       echo "<a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a>";
-               }
-
-               echo "</div>";
-       } else {
-
-               //display in list mode
-               foreach ($files as $f) {
-
-                       $mime = $f->mimetype;
-                       echo "<div class='filerepo_widget_singleitem clearfix'>";
-                       echo "<div class='filerepo_listview_icon'><a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a></div>";
-                       echo "<div class='filerepo_widget-content'>";
-                       echo "<div class='filerepo_listview_title'><p class='filerepo_title'>" . $f->title . "</p></div>";
-                       echo "<div class='filerepo_listview_date'><p class='filerepo_timestamp'><small>" . elgg_view_friendly_time($f->time_created) . "</small></p></div>";
-                       echo "</div></div>";
-               }
-       }
-
-
-       //get a link to the users files
-       $users_file_url = elgg_get_site_url() . "pg/file/" . get_user($f->owner_guid)->username;
-
-       echo "<div class='filerepo_widget_singleitem_more'><a href=\"{$users_file_url}\">" . elgg_echo('file:more') . "</a></div>";
-       echo "</div>";
+if ($content) {
+       $url = "pg/file/owner/" . elgg_get_page_owner()->username;
+       $more_link = elgg_view('output/url', array(
+               'href' => $url,
+               'text' => elgg_echo('file:more'),
+       ));
+       echo "<span class=\"elgg-widget-more\">$more_link</span>";
 } else {
-
-       echo "<p class='margin-top'>" . elgg_echo("file:none") . "</p>";
+       echo elgg_echo('file:none');
 }
index 0ee794dca0cd0f0c4574bd3e57d880b5d8eebbfd..695d16afc6aacbbcc2a8a15fa7c9d54c45ecfa14 100644 (file)
@@ -5,32 +5,21 @@
  * @package ElggFile
  */
 
+
 // set default value
 if (!isset($vars['entity']->num_display)) {
        $vars['entity']->num_display = 4;
 }
-?>
-<p>
-       <?php echo elgg_echo("file:num_files"); ?>:
-       <select name="params[num_display]">
-<?php
-$options = array(1,2,3,4,5,6,7,8,9,10,15,20);
-foreach ($options as $option)  {
-       $selected = '';
-       if ($vars['entity']->num_display == $option) {
-               $selected = "selected='selected'";
-       }
 
-       echo "  <option value='{$option}' $selected >{$option}</option>\n";
-}
-?>
-       </select>
-</p>
+$params = array(
+       'internalname' => 'params[num_display]',
+       'value' => $vars['entity']->num_display,
+       'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20),
+);
+$dropdown = elgg_view('input/pulldown', $params);
 
+?>
 <p>
-    <?php echo elgg_echo("file:gallery_list"); ?>?
-    <select name="params[gallery_list]">
-        <option value="1" <?php if($vars['entity']->gallery_list == 1) echo "SELECTED"; ?>><?php echo elgg_echo("file:list"); ?></option>
-           <option value="2" <?php if($vars['entity']->gallery_list == 2) echo "SELECTED"; ?>><?php echo elgg_echo("file:gallery"); ?></option>
-    </select>
-</p>
\ No newline at end of file
+       <?php echo elgg_echo('file:num_files'); ?>:
+       <?php echo $dropdown; ?>
+</p>
index 1b8f5f828fc472c3313bc93390fac2bc258cdf26..a55dcb452d4b4dd2d776a607815c92412ffab005 100644 (file)
@@ -20,10 +20,13 @@ $content = elgg_list_entities(array(
 ));
 elgg_pop_context();
 
+$sidebar = file_get_type_cloud();
+
 $body = elgg_view_layout('content', array(
        'filter_context' => 'all',
        'content' => $content,
        'title' => $title,
+       'sidebar' => $sidebar,
 ));
 
 echo elgg_view_page($title, $body);
index da80cc7a7c6fa65734258371d42f7b61cd5fa881..be4d152f83e77430594f549b8c4320ae2087a886 100644 (file)
        width: 350px;
 }
 
+#group_tools_latest > .elgg-module:nth-child(odd) {
+       margin-right: 30px;
+}
+
 #group_tools_latest > .elgg-module .elgg-head {
        padding: 5px 5px 3px;
        background-color: #e4e4e4;
        border-bottom: 1px solid #cccccc;
        -moz-border-radius: 4px 4px 0 0;
+       -webkit-border-radius: 4px 4px 0 0;
 }
 
 #group_tools_latest > .elgg-module .elgg-head h3 {
index 6d575b9ae57bd34cf00f09250b6c72d644c56902..28facc26c7dc452f9214bbde8e20a0258662ea83 100644 (file)
@@ -24,12 +24,6 @@ if ($encode) {
        $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
 }
 
-if (isset($vars['class']) && $vars['class']) {
-       $class = 'class="' . $vars['class'] . '"';
-} else {
-       $class = '';
-}
-
 $vars['onclick'] = "return confirm('" . addslashes($confirm) . "')";
 
 unset($vars['encode_text']);