diff options
Diffstat (limited to 'mod/file')
-rw-r--r-- | mod/file/actions/file/upload.php | 7 | ||||
-rw-r--r-- | mod/file/languages/en.php | 2 | ||||
-rw-r--r-- | mod/file/pages/file/search.php | 5 | ||||
-rw-r--r-- | mod/file/start.php | 94 | ||||
-rw-r--r-- | mod/file/views/default/embed/file_upload/content.php | 16 | ||||
-rw-r--r-- | mod/file/views/default/icon/object/file.php | 15 |
6 files changed, 61 insertions, 78 deletions
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php index 88a01745d..ee2889b4c 100644 --- a/mod/file/actions/file/upload.php +++ b/mod/file/actions/file/upload.php @@ -90,10 +90,11 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) { $filestorename = elgg_strtolower(time().$_FILES['upload']['name']); } - $file->setFilename($prefix.$filestorename); - $file->setMimeType($_FILES['upload']['type']); + $mime_type = $file->detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']); + $file->setFilename($prefix . $filestorename); + $file->setMimeType($mime_type); $file->originalfilename = $_FILES['upload']['name']; - $file->simpletype = file_get_simple_type($_FILES['upload']['type']); + $file->simpletype = file_get_simple_type($mime_type); // Open the file to guarantee the directory exists $file->open("write"); diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index 72b198d54..aa30084a9 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -75,6 +75,8 @@ $english = array( 'item:object:file' => 'Files', + 'file:newupload' => 'A new file has been uploaded', + /** * Embed media **/ diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php index 3e85d45db..402a28933 100644 --- a/mod/file/pages/file/search.php +++ b/mod/file/pages/file/search.php @@ -6,6 +6,11 @@ */ $page_owner_guid = get_input('page_owner', null); + +if ($page_owner_guid !== null) { + $page_owner_guid = sanitise_int($page_owner_guid); +} + if ($page_owner_guid) { elgg_set_page_owner_guid($page_owner_guid); } diff --git a/mod/file/start.php b/mod/file/start.php index b94dc309a..843ae0794 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -57,11 +57,30 @@ function file_init() { // 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'); - elgg_register_plugin_hook_handler('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections'); + $item = ElggMenuItem::factory(array( + 'name' => 'file', + 'text' => elgg_echo('file'), + 'priority' => 10, + 'data' => array( + 'options' => array( + 'type' => 'object', + 'subtype' => 'file', + ), + ), + )); + elgg_register_menu_item('embed', $item); + + $item = ElggMenuItem::factory(array( + 'name' => 'file_upload', + 'text' => elgg_echo('file:upload'), + 'priority' => 100, + 'data' => array( + 'view' => 'embed/file_upload/content', + ), + )); + + elgg_register_menu_item('embed', $item); } /** @@ -332,69 +351,4 @@ function file_icon_url_override($hook, $type, $returnvalue, $params) { $url = elgg_trigger_plugin_hook('file:icon:url', 'override', $params, $url); return $url; } -} - -/** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'layout' => 'list', - 'icon_size' => 'small', - ); - - return $value; -} - -/** - * Return a list of files for embedding - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_items($hook, $type, $value, $params) { - $options = array( - 'owner_guid' => elgg_get_logged_in_user_guid(), - 'type_subtype_pair' => array('object' => 'file'), - 'count' => TRUE - ); - - if ($count = elgg_get_entities($options)) { - $value['count'] += $count; - - unset($options['count']); - $options['offset'] = $params['offset']; - $options['limit'] = $params['limit']; - - $items = elgg_get_entities($options); - - $value['items'] = array_merge($items, $value['items']); - } - - return $value; -} - -/** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_upload_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'view' => 'file/embed_upload' - ); - - return $value; -} +}
\ No newline at end of file diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php new file mode 100644 index 000000000..4d3db0d97 --- /dev/null +++ b/mod/file/views/default/embed/file_upload/content.php @@ -0,0 +1,16 @@ +<?php +/** + * Upload a file through the embed interface + */ + +$form_vars = array( + 'enctype' => 'multipart/form-data', + 'class' => 'elgg-form-embed', +); +echo elgg_view_form('file/upload', $form_vars); + +// the tab we want to be forwarded to after upload is complete +echo elgg_view('input/hidden', array( + 'name' => 'embed_forward', + 'value' => 'file', +));
\ No newline at end of file diff --git a/mod/file/views/default/icon/object/file.php b/mod/file/views/default/icon/object/file.php index 6357d418f..7feba7af3 100644 --- a/mod/file/views/default/icon/object/file.php +++ b/mod/file/views/default/icon/object/file.php @@ -2,9 +2,10 @@ /** * File icon view * - * @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['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 */ $entity = $vars['entity']; @@ -32,10 +33,14 @@ $img_src = elgg_format_url($img_src); $img = "<img $class src=\"$img_src\" alt=\"$title\" />"; if ($url) { - echo elgg_view('output/url', array( + $params = array( 'href' => $url, 'text' => $img, - )); + ); + if (isset($vars['link_class'])) { + $params['class'] = $vars['link_class']; + } + echo elgg_view('output/url', $params); } else { echo $img; } |