aboutsummaryrefslogtreecommitdiff
path: root/mod/file
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file')
-rw-r--r--mod/file/actions/file/upload.php7
-rw-r--r--mod/file/languages/en.php2
-rw-r--r--mod/file/pages/file/search.php7
-rw-r--r--mod/file/start.php19
-rw-r--r--mod/file/views/default/embed/file/content.php61
-rw-r--r--mod/file/views/default/embed/file_upload/content.php13
-rw-r--r--mod/file/views/default/icon/object/file.php15
7 files changed, 42 insertions, 82 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 569657fd4..402a28933 100644
--- a/mod/file/pages/file/search.php
+++ b/mod/file/pages/file/search.php
@@ -5,7 +5,12 @@
* @package ElggFile
*/
-$page_owner_guid = (int)get_input('page_owner', null);
+$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 749d7a519..843ae0794 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -61,19 +61,26 @@ function file_init() {
$item = ElggMenuItem::factory(array(
'name' => 'file',
'text' => elgg_echo('file'),
- 'href' => '#',
- 'section' => 'select'
+ 'priority' => 10,
+ 'data' => array(
+ 'options' => array(
+ 'type' => 'object',
+ 'subtype' => 'file',
+ ),
+ ),
));
- elgg_register_menu_item('embed:sections', $item);
+ elgg_register_menu_item('embed', $item);
$item = ElggMenuItem::factory(array(
'name' => 'file_upload',
'text' => elgg_echo('file:upload'),
- 'href' => '#',
- 'section' => 'upload'
+ 'priority' => 100,
+ 'data' => array(
+ 'view' => 'embed/file_upload/content',
+ ),
));
- elgg_register_menu_item('embed:sections', $item);
+ elgg_register_menu_item('embed', $item);
}
/**
diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php
deleted file mode 100644
index 865a158a7..000000000
--- a/mod/file/views/default/embed/file/content.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * List files available for upload
- */
-
-$active_section = elgg_extract('active_section', $vars);
-
-$options = array(
- 'owner_guid' => elgg_get_logged_in_user_guid(),
- 'type_subtype_pair' => array('object' => 'file'),
- 'count' => true
-);
-
-$count = elgg_get_entities($options);
-
-if ($count) {
- echo "<div class='embed_modal_$active_section'>";
-
- unset($options['count']);
- $items = elgg_get_entities($options);
-
- foreach ($items as $item) {
-
- // different entity types have different title attribute names.
- $title = isset($item->name) ? $item->name : $item->title;
- // don't let it be too long
- $title = elgg_get_excerpt($title);
-
- $author_text = elgg_echo('byline', array($owner->name));
- $date = elgg_view_friendly_time($item->time_created);
-
- $subtitle = "$author_text $date";
-
- $icon = "<img src=\"{$item->getIconURL($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8');
-
- $embed_code = elgg_view('output/url', array(
- 'href' => $item->getURL(),
- 'title' => $title,
- 'text' => $icon,
- 'encode_text' => FALSE
- ));
-
- $item_icon = elgg_view_entity_icon($item, $icon_size);
-
- $params = array(
- 'title' => $title,
- 'entity' => $item,
- 'subtitle' => $subtitle,
- 'tags' => FALSE,
- );
- $list_body = elgg_view('object/elements/summary', $params);
-
- // @todo JS 1.8: is this approach better than inline js?
- echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>';
- echo "<script type=\"text/javascript\">
- $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . ");
- </script>";
- }
-
- echo '</div>';
-} \ 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
index 13c18f745..4d3db0d97 100644
--- a/mod/file/views/default/embed/file_upload/content.php
+++ b/mod/file/views/default/embed/file_upload/content.php
@@ -5,11 +5,12 @@
$form_vars = array(
'enctype' => 'multipart/form-data',
- 'class' => 'elgg-form',
+ 'class' => 'elgg-form-embed',
);
-$upload_content = elgg_view_form('file/upload', $form_vars);
+echo elgg_view_form('file/upload', $form_vars);
-echo "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>";
-echo "<div class='embed-upload'>";
-echo $upload_content;
-echo "</div>"; \ No newline at end of file
+// 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;
}