aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-04-16 08:25:21 +0000
committerkevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-04-16 08:25:21 +0000
commit0fb942ec33afc0ca970a028931fa4692582561cb (patch)
tree809ad7562639a3467a9f70f8e593d6e4202913a1
parent9efb09230050c6756a8acdecfa135a13244b1d2d (diff)
downloadelgg-0fb942ec33afc0ca970a028931fa4692582561cb.tar.gz
elgg-0fb942ec33afc0ca970a028931fa4692582561cb.tar.bz2
Added file_get_general_file_type() function
git-svn-id: https://code.elgg.org/elgg/trunk@3213 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/filestore.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php
index 67330c4e5..ea96bd5c9 100644
--- a/engine/lib/filestore.php
+++ b/engine/lib/filestore.php
@@ -879,6 +879,44 @@
return false;
}
+ /**
+ * Returns an overall file type from the mimetype
+ *
+ * @param string $mimetype The MIME type
+ * @return string The overall type
+ */
+ function file_get_general_file_type($mimetype) {
+
+ switch($mimetype) {
+
+ case "application/msword":
+ return "document";
+ break;
+ case "application/pdf":
+ return "document";
+ break;
+
+ }
+
+ if (substr_count($mimetype,'text/'))
+ return "document";
+
+ if (substr_count($mimetype,'audio/'))
+ return "audio";
+
+ if (substr_count($mimetype,'image/'))
+ return "image";
+
+ if (substr_count($mimetype,'video/'))
+ return "video";
+
+ if (substr_count($mimetype,'opendocument'))
+ return "document";
+
+ return "general";
+
+ }
+
function file_handle_upload($prefix,$subtype,$plugin) {
$desc = get_input("description");
$tags = get_input("tags");
@@ -965,7 +1003,7 @@
// Save tags
$file->tags = $tags;
- $file->simpletype = get_general_file_type($uploaded['type']);
+ $file->simpletype = file_get_general_file_type($uploaded['type']);
$file->folder = $folder;
$result = $file->save();