aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-31 14:47:38 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-31 14:47:38 +0000
commit24ef7261d523155ee1c58e8297516e726b4ce80b (patch)
treedfdb6b1ef7be64237e19b70d7954f149789a72f7 /mod
parentb4bd662414f2d49f238bf0fabf05878d9d967877 (diff)
downloadelgg-24ef7261d523155ee1c58e8297516e726b4ce80b.tar.gz
elgg-24ef7261d523155ee1c58e8297516e726b4ce80b.tar.bz2
a little standardization of the file plugin code
git-svn-id: http://code.elgg.org/elgg/trunk@7789 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r--mod/file/download.php73
-rw-r--r--mod/file/index.php2
-rw-r--r--mod/file/search.php201
-rw-r--r--mod/file/thumbnail.php7
-rw-r--r--mod/file/views/default/file/upload.php66
-rw-r--r--mod/file/views/default/widgets/filerepo/content.php1
-rw-r--r--mod/file/views/rss/object/file.php41
7 files changed, 190 insertions, 201 deletions
diff --git a/mod/file/download.php b/mod/file/download.php
index 55c5dc697..d7625901e 100644
--- a/mod/file/download.php
+++ b/mod/file/download.php
@@ -1,41 +1,42 @@
<?php
- /**
- * Elgg file download.
- *
- * @package ElggFile
- */
+/**
+ * Elgg file download.
+ *
+ * @package ElggFile
+ */
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+// Get the guid
+$file_guid = get_input("file_guid");
- // 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\"");
+// Get the file
+$file = get_entity($file_guid);
- $contents = $file->grabFile();
- $splitString = str_split($contents, 8192);
- foreach($splitString as $chunk)
- echo $chunk;
- exit;
+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 {
- register_error(elgg_echo("file:downloadfailed"));
- forward();
- } \ No newline at end of file
+ header("Content-Disposition: attachment; filename=\"$filename\"");
+ }
+
+ $contents = $file->grabFile();
+ $splitString = str_split($contents, 8192);
+ foreach ($splitString as $chunk) {
+ echo $chunk;
+ }
+ exit;
+} else {
+ register_error(elgg_echo("file:downloadfailed"));
+ forward();
+} \ No newline at end of file
diff --git a/mod/file/index.php b/mod/file/index.php
index b55f5c835..3706f65b3 100644
--- a/mod/file/index.php
+++ b/mod/file/index.php
@@ -1,6 +1,6 @@
<?php
/**
- * Elgg file browser
+ * Individual's or group's files
*
* @package ElggFile
*/
diff --git a/mod/file/search.php b/mod/file/search.php
index 6e63f55f0..0e541c276 100644
--- a/mod/file/search.php
+++ b/mod/file/search.php
@@ -1,103 +1,100 @@
<?php
-
- /**
- * Elgg file search
- *
- * @package ElggFile
-
- */
-
- // Load Elgg engine
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-
- // Get input
- $md_type = 'simpletype';
- $tag = get_input('tag');
- $listtype = get_input('listtype');
-
- $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();
- } else {
- $owner_guid = array();
- }
- } else {
- $owner_guid = get_input('owner_guid',0);
- if (substr_count($owner_guid,',')) {
- $owner_guid = explode(",",$owner_guid);
- }
- }
- $page_owner = get_input('page_owner',0);
- if ($page_owner) {
- set_page_owner($page_owner);
- } else {
- if ($friends) {
- set_page_owner($friends);
- } else {
- if ($owner_guid > 0 && !is_array($owner_guid))
- set_page_owner($owner_guid);
- }
- }
-
- 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'));
- } 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'));
- }
- }
- if ($friends) {
- $area1 = get_filetype_cloud($friends,true);
- } else if ($owner_guid) {
- $area1 = get_filetype_cloud($owner_guid);
- } else {
- $area1 = get_filetype_cloud();
- }
-
- 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);
- } else {
- $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset));
- }
-
- elgg_pop_context();
-
- $content = "<div class='files'>".$area1.$area2."</div>";
-
- $body = elgg_view_layout('one_column_with_sidebar', array('content' => $content));
-
- echo elgg_view_page($title, $body);
-
-?> \ No newline at end of file
+/**
+ * List files by type
+ *
+ * @package ElggFile
+
+ */
+// Load Elgg engine
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+
+// Get input
+$md_type = 'simpletype';
+$tag = get_input('tag');
+$listtype = get_input('listtype');
+
+$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();
+ } else {
+ $owner_guid = array();
+ }
+} else {
+ $owner_guid = get_input('owner_guid', 0);
+ if (substr_count($owner_guid, ',')) {
+ $owner_guid = explode(",", $owner_guid);
+ }
+}
+$page_owner = get_input('page_owner', 0);
+if ($page_owner) {
+ set_page_owner($page_owner);
+} else {
+ if ($friends) {
+ set_page_owner($friends);
+ } else {
+ if ($owner_guid > 0 && !is_array($owner_guid))
+ set_page_owner($owner_guid);
+ }
+}
+
+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'));
+} 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'));
+ }
+}
+if ($friends) {
+ $area1 = get_filetype_cloud($friends, true);
+} else if ($owner_guid) {
+ $area1 = get_filetype_cloud($owner_guid);
+} else {
+ $area1 = get_filetype_cloud();
+}
+
+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);
+} else {
+ $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset));
+}
+
+elgg_pop_context();
+
+$content = "<div class='files'>" . $area1 . $area2 . "</div>";
+
+$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content));
+
+echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/file/thumbnail.php b/mod/file/thumbnail.php
index 987153aeb..4da560a6c 100644
--- a/mod/file/thumbnail.php
+++ b/mod/file/thumbnail.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Elgg file thumbnail
*
@@ -10,10 +9,10 @@
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
// Get file GUID
-$file_guid = (int) get_input('file_guid',0);
+$file_guid = (int) get_input('file_guid', 0);
// Get file thumbnail size
-$size = get_input('size','small');
+$size = get_input('size', 'small');
// Get file entity
if ($file = get_entity($file_guid)) {
@@ -62,5 +61,3 @@ if ($file = get_entity($file_guid)) {
}
}
-
-?> \ No newline at end of file
diff --git a/mod/file/views/default/file/upload.php b/mod/file/views/default/file/upload.php
index 0ef99348c..041bd9227 100644
--- a/mod/file/views/default/file/upload.php
+++ b/mod/file/views/default/file/upload.php
@@ -1,40 +1,40 @@
<?php
- /**
- * Elgg file browser uploader
- *
- * @package ElggFile
- */
+/**
+ * Elgg file browser uploader
+ *
+ * @package ElggFile
+ */
- global $CONFIG;
+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();
+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;
}
-
- // make sure session cache is cleared
- unset($_SESSION['uploadtitle']);
- unset($_SESSION['uploaddesc']);
- unset($_SESSION['uploadtags']);
- unset($_SESSION['uploadaccessid']);
+ $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']);
?>
diff --git a/mod/file/views/default/widgets/filerepo/content.php b/mod/file/views/default/widgets/filerepo/content.php
index ee7bbe3cc..130b5e3de 100644
--- a/mod/file/views/default/widgets/filerepo/content.php
+++ b/mod/file/views/default/widgets/filerepo/content.php
@@ -68,4 +68,3 @@ if ($files) {
echo "<p class='margin-top'>" . elgg_echo("file:none") . "</p>";
}
-?> \ No newline at end of file
diff --git a/mod/file/views/rss/object/file.php b/mod/file/views/rss/object/file.php
index 52d26382f..a0660d6c8 100644
--- a/mod/file/views/rss/object/file.php
+++ b/mod/file/views/rss/object/file.php
@@ -1,26 +1,21 @@
<?php
-
- /**
- * Elgg RSS file object view
- *
- * @package ElggFile
- * @subpackage Core
- */
-
- $title = $vars['entity']->title;
- if (empty($title)) {
- $title = substr($vars['entity']->description,0,32);
- if (strlen($vars['entity']->description) > 32)
- $title .= " ...";
- }
-
+/**
+ * Elgg RSS file object view
+ *
+ * @package ElggFile
+ * @subpackage Core
+ */
+$title = $vars['entity']->title;
+if (empty($title)) {
+ $title = elgg_get_excerpt($vars['entity']->description, 32);
+}
?>
- <item>
- <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid>
- <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
- <link><?php echo $vars['entity']->getURL(); ?></link>
- <title><![CDATA[<?php echo $title; ?>]]></title>
- <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
- <enclosure url="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" length="<?php echo $vars['entity']->size(); ?>" type="<?php echo $vars['entity']->getMimeType(); ?>" />
- </item>
+<item>
+ <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid>
+ <pubDate><?php echo date("r", $vars['entity']->time_created) ?></pubDate>
+ <link><?php echo $vars['entity']->getURL(); ?></link>
+ <title><![CDATA[<?php echo $title; ?>]]></title>
+ <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
+ <enclosure url="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" length="<?php echo $vars['entity']->size(); ?>" type="<?php echo $vars['entity']->getMimeType(); ?>" />
+</item>