aboutsummaryrefslogtreecommitdiff
path: root/mod/file
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file')
-rw-r--r--mod/file/actions/file/delete.php96
-rw-r--r--mod/file/actions/file/download.php42
-rw-r--r--mod/file/actions/file/save.php48
-rw-r--r--mod/file/actions/file/upload.php377
-rw-r--r--mod/file/classes/FilePluginFile.php15
-rw-r--r--mod/file/edit.php24
-rw-r--r--mod/file/friends.php24
-rw-r--r--mod/file/index.php18
-rw-r--r--mod/file/languages/en.php3
-rw-r--r--mod/file/lib/file.php42
-rw-r--r--mod/file/search.php124
-rw-r--r--mod/file/start.php114
-rw-r--r--mod/file/upload.php19
-rw-r--r--mod/file/views/default/file/css.php108
-rw-r--r--mod/file/views/default/file/group_module.php48
-rw-r--r--mod/file/views/default/file/groupprofile_files.php59
-rw-r--r--mod/file/views/default/file/icon.php2
-rw-r--r--mod/file/views/default/file/typecloud.php83
-rw-r--r--mod/file/views/default/file/upload.php128
-rw-r--r--mod/file/views/default/forms/file/upload.php63
-rw-r--r--mod/file/views/default/widgets/filerepo/content.php68
-rw-r--r--mod/file/views/default/widgets/filerepo/edit.php33
-rw-r--r--mod/file/world.php3
23 files changed, 634 insertions, 907 deletions
diff --git a/mod/file/actions/file/delete.php b/mod/file/actions/file/delete.php
index 9357d4955..fe03e5077 100644
--- a/mod/file/actions/file/delete.php
+++ b/mod/file/actions/file/delete.php
@@ -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");
+}
diff --git a/mod/file/actions/file/download.php b/mod/file/actions/file/download.php
index 210735b74..6768bd4b1 100644
--- a/mod/file/actions/file/download.php
+++ b/mod/file/actions/file/download.php
@@ -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
index 17a9b16fb..000000000
--- a/mod/file/actions/file/save.php
+++ /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
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php
index 081b6a312..5ce98c101 100644
--- a/mod/file/actions/file/upload.php
+++ b/mod/file/actions/file/upload.php
@@ -1,205 +1,200 @@
<?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());
+}
diff --git a/mod/file/classes/FilePluginFile.php b/mod/file/classes/FilePluginFile.php
index 7397bfa4b..edf914231 100644
--- a/mod/file/classes/FilePluginFile.php
+++ b/mod/file/classes/FilePluginFile.php
@@ -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();
+ }
}
diff --git a/mod/file/edit.php b/mod/file/edit.php
index da22cacdf..aa4b60a83 100644
--- a/mod/file/edit.php
+++ b/mod/file/edit.php
@@ -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);
diff --git a/mod/file/friends.php b/mod/file/friends.php
index 201f86f62..795aa21ce 100644
--- a/mod/file/friends.php
+++ b/mod/file/friends.php
@@ -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);
diff --git a/mod/file/index.php b/mod/file/index.php
index bdda62786..940f9c30f 100644
--- a/mod/file/index.php
+++ b/mod/file/index.php
@@ -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);
diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php
index f06124031..14de64ed5 100644
--- a/mod/file/languages/en.php
+++ b/mod/file/languages/en.php
@@ -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
index 000000000..6ca49e95b
--- /dev/null
+++ b/mod/file/lib/file.php
@@ -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;
+}
diff --git a/mod/file/search.php b/mod/file/search.php
index 0e541c276..157b5b8b8 100644
--- a/mod/file/search.php
+++ b/mod/file/search.php
@@ -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
diff --git a/mod/file/start.php b/mod/file/start.php
index d58940f40..46503b3a7 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -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");
diff --git a/mod/file/upload.php b/mod/file/upload.php
index ef0899f20..f5fab81f4 100644
--- a/mod/file/upload.php
+++ b/mod/file/upload.php
@@ -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);
diff --git a/mod/file/views/default/file/css.php b/mod/file/views/default/file/css.php
index d4d1a2c13..53fa94e46 100644
--- a/mod/file/views/default/file/css.php
+++ b/mod/file/views/default/file/css.php
@@ -27,111 +27,3 @@
.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
index 000000000..babdcf677
--- /dev/null
+++ b/mod/file/views/default/file/group_module.php
@@ -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
index 5cbf75bce..000000000
--- a/mod/file/views/default/file/groupprofile_files.php
+++ /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
diff --git a/mod/file/views/default/file/icon.php b/mod/file/views/default/file/icon.php
index 63756a952..391afd0c8 100644
--- a/mod/file/views/default/file/icon.php
+++ b/mod/file/views/default/file/icon.php
@@ -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);
diff --git a/mod/file/views/default/file/typecloud.php b/mod/file/views/default/file/typecloud.php
index bb322d4d7..4a59d8a7c 100644
--- a/mod/file/views/default/file/typecloud.php
+++ b/mod/file/views/default/file/typecloud.php
@@ -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
index 041bd9227..000000000
--- a/mod/file/views/default/file/upload.php
+++ /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
index 000000000..f3012ea7a
--- /dev/null
+++ b/mod/file/views/default/forms/file/upload.php
@@ -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>
diff --git a/mod/file/views/default/widgets/filerepo/content.php b/mod/file/views/default/widgets/filerepo/content.php
index 130b5e3de..d2cd246ae 100644
--- a/mod/file/views/default/widgets/filerepo/content.php
+++ b/mod/file/views/default/widgets/filerepo/content.php
@@ -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');
}
diff --git a/mod/file/views/default/widgets/filerepo/edit.php b/mod/file/views/default/widgets/filerepo/edit.php
index 0ee794dca..695d16afc 100644
--- a/mod/file/views/default/widgets/filerepo/edit.php
+++ b/mod/file/views/default/widgets/filerepo/edit.php
@@ -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>
diff --git a/mod/file/world.php b/mod/file/world.php
index 1b8f5f828..a55dcb452 100644
--- a/mod/file/world.php
+++ b/mod/file/world.php
@@ -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);