diff options
Diffstat (limited to 'mod/file')
-rw-r--r-- | mod/file/download.php | 29 | ||||
-rw-r--r-- | mod/file/languages/en.php | 5 | ||||
-rw-r--r-- | mod/file/manifest.xml | 2 | ||||
-rw-r--r-- | mod/file/pages/file/download.php | 38 | ||||
-rw-r--r-- | mod/file/pages/file/view.php | 2 | ||||
-rw-r--r-- | mod/file/pages/file/world.php | 3 | ||||
-rw-r--r-- | mod/file/start.php | 59 | ||||
-rw-r--r-- | mod/file/views/default/icon/object/file.php | 11 | ||||
-rw-r--r-- | mod/file/views/default/object/file.php | 1 | ||||
-rw-r--r-- | mod/file/views/rss/file/enclosure.php | 16 | ||||
-rw-r--r-- | mod/file/views/rss/object/file.php | 21 |
11 files changed, 125 insertions, 62 deletions
diff --git a/mod/file/download.php b/mod/file/download.php index 8e0287a1e..b2acdffec 100644 --- a/mod/file/download.php +++ b/mod/file/download.php @@ -9,31 +9,4 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); // Get the guid $file_guid = get_input("file_guid"); -// Get the file -$file = get_entity($file_guid); -if (!$file) { - register_error(elgg_echo("file:downloadfailed")); - forward(); -} - -$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\""); -} - -ob_clean(); -flush(); -readfile($file->getFilenameOnFilestore()); -exit; +forward("file/download/$file_guid"); diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index 96fbd1c48..278076927 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -35,6 +35,9 @@ $english = array( 'file:desc' => "Description", 'file:tags' => "Tags", + 'file:list:list' => 'Switch to the list view', + 'file:list:gallery' => 'Switch to the gallery view', + 'file:types' => "Uploaded file types", 'file:type:' => 'Files', @@ -95,7 +98,7 @@ $english = array( * Error messages */ - 'file:none' => "No files uploaded.", + 'file:none' => "No files.", 'file:uploadfailed' => "Sorry; we could not save your file.", 'file:downloadfailed' => "Sorry; this file is not available at this time.", 'file:deletefailed' => "Your file could not be deleted at this time.", diff --git a/mod/file/manifest.xml b/mod/file/manifest.xml index 85ff76b41..26282a8e3 100644 --- a/mod/file/manifest.xml +++ b/mod/file/manifest.xml @@ -9,7 +9,7 @@ <description>File browser plugin</description> <website>http://www.elgg.org/</website> <copyright>See COPYRIGHT.txt</copyright> - <license>GNU Public License version 2</license> + <license>GNU General Public License version 2</license> <requires> <type>elgg_release</type> <version>1.8</version> diff --git a/mod/file/pages/file/download.php b/mod/file/pages/file/download.php new file mode 100644 index 000000000..00e6d500e --- /dev/null +++ b/mod/file/pages/file/download.php @@ -0,0 +1,38 @@ +<?php +/** + * Elgg file download. + * + * @package ElggFile + */ + +// Get the guid +$file_guid = get_input("guid"); + +// Get the file +$file = get_entity($file_guid); +if (!$file) { + register_error(elgg_echo("file:downloadfailed")); + forward(); +} + +$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\""); +} + +ob_clean(); +flush(); +readfile($file->getFilenameOnFilestore()); +exit; diff --git a/mod/file/pages/file/view.php b/mod/file/pages/file/view.php index 50c55a74f..a571c9d68 100644 --- a/mod/file/pages/file/view.php +++ b/mod/file/pages/file/view.php @@ -28,7 +28,7 @@ $content .= elgg_view_comments($file); elgg_register_menu_item('title', array( 'name' => 'download', 'text' => elgg_echo('file:download'), - 'href' => "mod/file/download.php?file_guid=$file->guid", + 'href' => "file/download/$file->guid", 'link_class' => 'elgg-button elgg-button-action', )); diff --git a/mod/file/pages/file/world.php b/mod/file/pages/file/world.php index e438ca2f0..770dfd6e8 100644 --- a/mod/file/pages/file/world.php +++ b/mod/file/pages/file/world.php @@ -19,6 +19,9 @@ $content = elgg_list_entities(array( 'limit' => $limit, 'full_view' => FALSE )); +if (!$content) { + $content = elgg_echo('file:none'); +} $sidebar = file_get_type_cloud(); $sidebar = elgg_view('file/sidebar'); diff --git a/mod/file/start.php b/mod/file/start.php index 843ae0794..e15a9ad61 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -22,6 +22,9 @@ function file_init() { // Extend CSS elgg_extend_view('css/elgg', 'file/css'); + // add enclosure to rss item + elgg_extend_view('extensions/item', 'file/enclosure'); + // extend group main page elgg_extend_view('groups/tool_latest', 'file/group_module'); @@ -93,11 +96,12 @@ function file_init() { * New file: file/add/<guid> * Edit file: file/edit/<guid> * Group files: file/group/<guid>/all + * Download: file/download/<guid> * * Title is ignored * * @param array $page - * @return NULL + * @return bool */ function file_page_handler($page) { @@ -110,9 +114,11 @@ function file_page_handler($page) { $page_type = $page[0]; switch ($page_type) { case 'owner': + file_register_toggle(); include "$file_dir/owner.php"; break; case 'friends': + file_register_toggle(); include "$file_dir/friends.php"; break; case 'view': @@ -127,25 +133,64 @@ function file_page_handler($page) { include "$file_dir/edit.php"; break; case 'search': + file_register_toggle(); include "$file_dir/search.php"; break; case 'group': + file_register_toggle(); include "$file_dir/owner.php"; break; case 'all': - default: + file_register_toggle(); include "$file_dir/world.php"; break; + case 'download': + set_input('guid', $page[1]); + include "$file_dir/download.php"; + break; + default: + return false; + } + return true; +} + +/** + * Adds a toggle to extra menu for switching between list and gallery views + */ +function file_register_toggle() { + $url = elgg_http_remove_url_query_element(current_page_url(), 'list_type'); + + if (get_input('list_type', 'list') == 'list') { + $list_type = "gallery"; + $icon = elgg_view_icon('grid'); + } else { + $list_type = "list"; + $icon = elgg_view_icon('list'); } + + if (substr_count($url, '?')) { + $url .= "&list_type=" . $list_type; + } else { + $url .= "?list_type=" . $list_type; + } + + + elgg_register_menu_item('extras', array( + 'name' => 'file_list', + 'text' => $icon, + 'href' => $url, + 'title' => elgg_echo("file:list:$list_type"), + 'priority' => 1000, + )); } /** * Creates the notification message body * - * @param unknown_type $hook - * @param unknown_type $entity_type - * @param unknown_type $returnvalue - * @param unknown_type $params + * @param string $hook + * @param string $entity_type + * @param string $returnvalue + * @param array $params */ function file_notify_message($hook, $entity_type, $returnvalue, $params) { $entity = $params['entity']; @@ -344,7 +389,7 @@ function file_icon_url_override($hook, $type, $returnvalue, $params) { if ($size == 'large') { $ext = '_lrg'; } else { - $exit = ''; + $ext = ''; } $url = "mod/file/graphics/icons/{$type}{$ext}.gif"; diff --git a/mod/file/views/default/icon/object/file.php b/mod/file/views/default/icon/object/file.php index ff729da94..a3190310b 100644 --- a/mod/file/views/default/icon/object/file.php +++ b/mod/file/views/default/icon/object/file.php @@ -5,7 +5,8 @@ * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method * @uses $vars['size'] topbar, tiny, small, medium (default), large, master * @uses $vars['href'] Optional override for link - * @uses $vars['link_class'] Optional CSS class added to img + * @uses $vars['img_class'] Optional CSS class added to img + * @uses $vars['link_class'] Optional CSS class added to link */ $entity = $vars['entity']; @@ -17,6 +18,7 @@ if (!in_array($vars['size'], $sizes)) { } $title = $entity->title; +$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false); $url = $entity->getURL(); if (isset($vars['href'])) { @@ -24,8 +26,13 @@ if (isset($vars['href'])) { } $class = ''; +if (isset($vars['img_class'])) { + $class = $vars['img_class']; +} if ($entity->thumbnail) { - $class = 'class="elgg-photo"'; + $class = "class=\"elgg-photo $class\""; +} else if ($class) { + $class = "class=\"$class\""; } $img_src = $entity->getIconURL($vars['size']); diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php index 81421133f..1db9863c9 100644 --- a/mod/file/views/default/object/file.php +++ b/mod/file/views/default/object/file.php @@ -69,7 +69,6 @@ if ($full && !elgg_in_context('gallery')) { $params = array( 'entity' => $file, - 'title' => false, 'metadata' => $metadata, 'subtitle' => $subtitle, 'tags' => $tags, diff --git a/mod/file/views/rss/file/enclosure.php b/mod/file/views/rss/file/enclosure.php new file mode 100644 index 000000000..fb4a899d9 --- /dev/null +++ b/mod/file/views/rss/file/enclosure.php @@ -0,0 +1,16 @@ +<?php +/** + * Link to download the file + * + * @uses $vars['entity'] + */ + +if (elgg_instanceof($vars['entity'], 'object', 'file')) { + $download_url = elgg_get_site_url() . 'file/download/' . $vars['entity']->getGUID(); + $size = $vars['entity']->size(); + $mime_type = $vars['entity']->getMimeType(); + echo <<<END + + <enclosure url="$download_url" length="$size" type="$mime_type" />"; +END; +} diff --git a/mod/file/views/rss/object/file.php b/mod/file/views/rss/object/file.php deleted file mode 100644 index a0660d6c8..000000000 --- a/mod/file/views/rss/object/file.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * 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> |