aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/file/start.php100
-rw-r--r--mod/file/views/default/file/icon.php37
-rw-r--r--mod/file/views/default/file/icon/application/default.php8
-rw-r--r--mod/file/views/default/file/icon/application/excel.php8
-rw-r--r--mod/file/views/default/file/icon/application/msword.php8
-rw-r--r--mod/file/views/default/file/icon/application/pdf.php8
-rw-r--r--mod/file/views/default/file/icon/application/powerpoint.php8
-rw-r--r--mod/file/views/default/file/icon/application/vnd.ms-excel.php6
-rw-r--r--mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php6
-rw-r--r--mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php8
-rw-r--r--mod/file/views/default/file/icon/application/x-gzip.php6
-rw-r--r--mod/file/views/default/file/icon/application/x-rar-compressed.php6
-rw-r--r--mod/file/views/default/file/icon/application/x-stuffit.php6
-rw-r--r--mod/file/views/default/file/icon/application/zip.php6
-rw-r--r--mod/file/views/default/file/icon/archive.php8
-rw-r--r--mod/file/views/default/file/icon/audio.php8
-rw-r--r--mod/file/views/default/file/icon/audio/default.php6
-rw-r--r--mod/file/views/default/file/icon/default.php16
-rw-r--r--mod/file/views/default/file/icon/document.php8
-rw-r--r--mod/file/views/default/file/icon/text/default.php6
-rw-r--r--mod/file/views/default/file/icon/text/directory.php8
-rw-r--r--mod/file/views/default/file/icon/text/v-card.php6
-rw-r--r--mod/file/views/default/file/icon/video.php8
-rw-r--r--mod/file/views/default/file/icon/video/default.php6
-rw-r--r--mod/file/views/default/object/file.php9
25 files changed, 86 insertions, 224 deletions
diff --git a/mod/file/start.php b/mod/file/start.php
index 4eb67cd32..360f64d1f 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -31,8 +31,9 @@ function file_init() {
// Add a new file widget
elgg_register_widget_type('filerepo', elgg_echo("file"), elgg_echo("file:widget:description"));
- // Register a URL handler for files
- register_entity_url_handler('file_url', 'object', 'file');
+ // Register URL handlers for files
+ register_entity_url_handler('file_url_override', 'object', 'file');
+ elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'file_icon_url_override');
// Register granular notification for this object type
register_notification_object('object', 'file', elgg_echo('file:newupload'));
@@ -144,8 +145,8 @@ function file_notify_message($hook, $entity_type, $returnvalue, $params) {
}
/**
-* Add a menu item to the user ownerblock
-*/
+ * Add a menu item to the user ownerblock
+ */
function file_owner_block_menu($hook, $type, $return, $params) {
if (elgg_instanceof($params['entity'], 'user')) {
$url = "pg/file/owner/{$params['entity']->username}";
@@ -257,6 +258,85 @@ function get_filetype_cloud($owner_guid = "", $friends = false) {
}
/**
+ * Populates the ->getUrl() method for file objects
+ *
+ * @param ElggEntity $entity File entity
+ * @return string File URL
+ */
+function file_url_override($entity) {
+ $title = $entity->title;
+ $title = elgg_get_friendly_title($title);
+ return "pg/file/view/" . $entity->getGUID() . "/" . $title;
+}
+
+/**
+ * Override the default entity icon for files
+ *
+ * Plugins can override or extend the icons using the plugin hook: 'file:icon:url', 'override'
+ *
+ * @return string Relative URL
+ */
+function file_icon_url_override($hook, $type, $returnvalue, $params) {
+ $file = $params['entity'];
+ $size = $params['size'];
+ if (elgg_instanceof($file, 'object', 'file')) {
+
+ // thumbnails get first priority
+ if ($file->thumbnail) {
+ return "mod/file/thumbnail.php?file_guid=$file->guid&size=$size";
+ }
+
+ $mapping = array(
+ 'application/excel' => 'excel',
+ 'application/msword' => 'word',
+ 'application/pdf' => 'pdf',
+ 'application/powerpoint' => 'ppt',
+ 'application/vnd.ms-excel' => 'excel',
+ 'application/vnd.ms-powerpoint' => 'ppt',
+ 'application/vnd.oasis.opendocument.text' => 'openoffice',
+ 'application/x-gzip' => 'archive',
+ 'application/x-rar-compressed' => 'archive',
+ 'application/x-stuffit' => 'archive',
+ 'application/zip' => 'archive',
+
+ 'text/directory' => 'vcard',
+ 'text/v-card' => 'vcard',
+
+ 'application' => 'application',
+ 'audio' => 'music',
+ 'text' => 'text',
+ 'video' => 'video',
+ );
+
+ $mime = $file->mimetype;
+ if ($mime) {
+ $base_type = substr($mime, 0, strpos($mime, '/'));
+ } else {
+ $mime = 'none';
+ $base_type = 'none';
+ }
+
+ if (isset($mapping[$mime])) {
+ $type = $mapping[$mime];
+ } elseif (isset($mapping[$base_type])) {
+ $type = $mapping[$base_type];
+ } else {
+ $type = 'general';
+ }
+
+ if ($size == 'large') {
+ $ext = '_lrg';
+ } else {
+ $exit = '';
+ }
+
+ $url = "mod/file/graphics/icons/{$type}{$ext}.gif";
+ $url = elgg_trigger_plugin_hook('file:icon:url', 'override', $params, $url);
+ return $url;
+ }
+}
+
+/**
* Register file as an embed type.
*
* @param unknown_type $hook
@@ -320,15 +400,3 @@ function file_embed_get_upload_sections($hook, $type, $value, $params) {
return $value;
}
-
-/**
- * Populates the ->getUrl() method for file objects
- *
- * @param ElggEntity $entity File entity
- * @return string File URL
- */
-function file_url($entity) {
- $title = $entity->title;
- $title = elgg_get_friendly_title($title);
- return "pg/file/view/" . $entity->getGUID() . "/" . $title;
-}
diff --git a/mod/file/views/default/file/icon.php b/mod/file/views/default/file/icon.php
deleted file mode 100644
index 391afd0c8..000000000
--- a/mod/file/views/default/file/icon.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * Elgg file icons.
- * Displays an icon, depending on its mime type, for a file.
- * Optionally you can specify a size.
- *
- * @package ElggFile
- *
- * @uses $vars['size']
- * @uses $vars['mimetype']
- * @uses $vars['thumbnail']
- * @uses $vars['file_guid']
- */
-
-$mime = $vars['mimetype'];
-$simple_type = file_get_simple_type($mime);
-
-// is this request for an image thumbnail
-$thumbnail = elgg_get_array_value('thumbnail', $vars, false);
-
-// default size is small for thumbnails
-$size = elgg_get_array_value('size', $vars, 'small');
-
-if ($simple_type == 'image' && $thumbnail) {
- $icon = "<img src=\"" . elgg_get_site_url() . "mod/file/thumbnail.php?file_guid={$vars['file_guid']}&size={$size}\" />";
-} else {
- $base_type = substr($mime, 0, strpos($mime, '/'));
- if ($mime && elgg_view_exists("file/icon/$mime")) {
- $icon = elgg_view("file/icon/{$mime}", $vars);
- } else if ($mime && elgg_view_exists("file/icon/$base_type/default")) {
- $icon = elgg_view("file/icon/$base_type/default", $vars);
- } else {
- $icon = elgg_view('file/icon/default', $vars);
- }
-}
-
-echo $icon;
diff --git a/mod/file/views/default/file/icon/application/default.php b/mod/file/views/default/file/icon/application/default.php
deleted file mode 100644
index 6a7c7e13c..000000000
--- a/mod/file/views/default/file/icon/application/default.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Default application icon
- */
-
-$vars['type'] = 'application';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/excel.php b/mod/file/views/default/file/icon/application/excel.php
deleted file mode 100644
index f5cfffb54..000000000
--- a/mod/file/views/default/file/icon/application/excel.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Excel icon
- */
-
-$vars['type'] = 'excel';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/msword.php b/mod/file/views/default/file/icon/application/msword.php
deleted file mode 100644
index edb7b3694..000000000
--- a/mod/file/views/default/file/icon/application/msword.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Word icon
- */
-
-$vars['type'] = 'word';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/pdf.php b/mod/file/views/default/file/icon/application/pdf.php
deleted file mode 100644
index 2b32c5825..000000000
--- a/mod/file/views/default/file/icon/application/pdf.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * PDF icon
- */
-
-$vars['type'] = 'pdf';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/powerpoint.php b/mod/file/views/default/file/icon/application/powerpoint.php
deleted file mode 100644
index fba3af016..000000000
--- a/mod/file/views/default/file/icon/application/powerpoint.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Powerpoint icon
- */
-
-$vars['type'] = 'ppt';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/vnd.ms-excel.php b/mod/file/views/default/file/icon/application/vnd.ms-excel.php
deleted file mode 100644
index fe5b22ff0..000000000
--- a/mod/file/views/default/file/icon/application/vnd.ms-excel.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Excel icon
- */
-
-echo elgg_view('file/icon/application/excel', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php b/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php
deleted file mode 100644
index d6425be90..000000000
--- a/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Powerpoint icon
- */
-
-echo elgg_view('file/icon/application/powerpoint', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php b/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php
deleted file mode 100644
index 82199922d..000000000
--- a/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Open Office icon
- */
-
-$vars['type'] = 'openoffice';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/application/x-gzip.php b/mod/file/views/default/file/icon/application/x-gzip.php
deleted file mode 100644
index f90d28376..000000000
--- a/mod/file/views/default/file/icon/application/x-gzip.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * GZip icon
- */
-
-echo elgg_view('file/icon/archive', $vars);
diff --git a/mod/file/views/default/file/icon/application/x-rar-compressed.php b/mod/file/views/default/file/icon/application/x-rar-compressed.php
deleted file mode 100644
index 3cc09b6d9..000000000
--- a/mod/file/views/default/file/icon/application/x-rar-compressed.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Rar icon
- */
-
-echo elgg_view('file/icon/archive', $vars);
diff --git a/mod/file/views/default/file/icon/application/x-stuffit.php b/mod/file/views/default/file/icon/application/x-stuffit.php
deleted file mode 100644
index 7491e77a9..000000000
--- a/mod/file/views/default/file/icon/application/x-stuffit.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Stuffit icon
- */
-
-echo elgg_view('file/icon/archive', $vars);
diff --git a/mod/file/views/default/file/icon/application/zip.php b/mod/file/views/default/file/icon/application/zip.php
deleted file mode 100644
index c0bb01a47..000000000
--- a/mod/file/views/default/file/icon/application/zip.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Zip icon
- */
-
-echo elgg_view('file/icon/archive', $vars);
diff --git a/mod/file/views/default/file/icon/archive.php b/mod/file/views/default/file/icon/archive.php
deleted file mode 100644
index 552f7f218..000000000
--- a/mod/file/views/default/file/icon/archive.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Archive icon
- */
-
-$vars['type'] = 'archive';
-
-echo elgg_view('file/icon/default', $vars);
diff --git a/mod/file/views/default/file/icon/audio.php b/mod/file/views/default/file/icon/audio.php
deleted file mode 100644
index 9a42be9ac..000000000
--- a/mod/file/views/default/file/icon/audio.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Audio icon
- */
-
-$vars['type'] = 'music';
-
-echo elgg_view('file/icon/default', $vars);
diff --git a/mod/file/views/default/file/icon/audio/default.php b/mod/file/views/default/file/icon/audio/default.php
deleted file mode 100644
index 60e03b6c4..000000000
--- a/mod/file/views/default/file/icon/audio/default.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Audio default icon
- */
-
-echo elgg_view('file/icon/audio', $vars);
diff --git a/mod/file/views/default/file/icon/default.php b/mod/file/views/default/file/icon/default.php
deleted file mode 100644
index c4fc8e2a7..000000000
--- a/mod/file/views/default/file/icon/default.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Default file icon
- */
-
-$type = elgg_get_array_value('type', $vars, 'general');
-
-$size = elgg_get_array_value('size', $vars, '');
-if ($size == 'large') {
- $ext = '_lrg';
-} else {
- $ext = '';
-}
-
-$src = elgg_get_site_url() . "mod/file/graphics/icons/{$type}{$ext}.gif";
-echo "<img src=\"$src\" />";
diff --git a/mod/file/views/default/file/icon/document.php b/mod/file/views/default/file/icon/document.php
deleted file mode 100644
index 55a71394e..000000000
--- a/mod/file/views/default/file/icon/document.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Document icon
- */
-
-$vars['type'] = 'text';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/text/default.php b/mod/file/views/default/file/icon/text/default.php
deleted file mode 100644
index f6b42b587..000000000
--- a/mod/file/views/default/file/icon/text/default.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Document default icon
- */
-
-echo elgg_view('file/icon/document', $vars);
diff --git a/mod/file/views/default/file/icon/text/directory.php b/mod/file/views/default/file/icon/text/directory.php
deleted file mode 100644
index f221100cd..000000000
--- a/mod/file/views/default/file/icon/text/directory.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Directory default icon
- */
-
-$vars['type'] = 'vcard';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/text/v-card.php b/mod/file/views/default/file/icon/text/v-card.php
deleted file mode 100644
index 3554f37c1..000000000
--- a/mod/file/views/default/file/icon/text/v-card.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * V-card icon
- */
-
-echo elgg_view('file/icon/text/directory', $vars);
diff --git a/mod/file/views/default/file/icon/video.php b/mod/file/views/default/file/icon/video.php
deleted file mode 100644
index ff6b7e68f..000000000
--- a/mod/file/views/default/file/icon/video.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Video icon
- */
-
-$vars['type'] = 'video';
-
-echo elgg_view('file/icon/default', $vars); \ No newline at end of file
diff --git a/mod/file/views/default/file/icon/video/default.php b/mod/file/views/default/file/icon/video/default.php
deleted file mode 100644
index a33940ebf..000000000
--- a/mod/file/views/default/file/icon/video/default.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Video default icon
- */
-
-echo elgg_view('file/icon/video', $vars);
diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php
index 5fcd2a023..cbe19f3c6 100644
--- a/mod/file/views/default/object/file.php
+++ b/mod/file/views/default/object/file.php
@@ -27,12 +27,7 @@ $owner_link = elgg_view('output/url', array(
));
$author_text = elgg_echo('blog:author_by_line', array($owner_link));
-$file_icon = elgg_view('file/icon', array(
- 'mimetype' => $mime,
- 'thumbnail' => $file->thumbnail,
- 'file_guid' => $file->guid,
- 'size' => 'small'
-));
+$file_icon = elgg_view_entity_icon($file, 'small');
$tags = elgg_view('output/tags', array('tags' => $file->tags));
$date = elgg_view_friendly_time($file->time_created);
@@ -102,7 +97,7 @@ HTML;
} elseif (elgg_in_context('gallery')) {
echo '<div class="file-gallery-item">';
echo "<h3>" . $file->title . "</h3>";
- echo "<a href=\"{$file->getURL()}\"><img src=\"".elgg_get_site_url()."mod/file/thumbnail.php?size=medium&file_guid={$vars['entity']->getGUID()}\" /></a>";
+ echo elgg_view_entity_icon($file, 'medium');
echo "<p class='subtitle'>$owner_link $date</p>";
echo '</div>';
} else {