diff options
Diffstat (limited to 'mod/file')
-rw-r--r-- | mod/file/actions/file/upload.php | 56 | ||||
-rw-r--r-- | mod/file/download.php | 9 | ||||
-rw-r--r-- | mod/file/languages/en.php | 9 | ||||
-rw-r--r-- | mod/file/pages/file/edit.php | 1 | ||||
-rw-r--r-- | mod/file/pages/file/friends.php | 3 | ||||
-rw-r--r-- | mod/file/pages/file/owner.php | 10 | ||||
-rw-r--r-- | mod/file/pages/file/search.php | 19 | ||||
-rw-r--r-- | mod/file/pages/file/upload.php | 1 | ||||
-rw-r--r-- | mod/file/pages/file/view.php | 10 | ||||
-rw-r--r-- | mod/file/pages/file/world.php | 2 | ||||
-rw-r--r-- | mod/file/views/default/file/embed_upload.php | 8 | ||||
-rw-r--r-- | mod/file/views/default/file/group_module.php | 22 | ||||
-rw-r--r-- | mod/file/views/default/file/typecloud.php | 2 | ||||
-rw-r--r-- | mod/file/views/default/forms/file/upload.php | 15 | ||||
-rw-r--r-- | mod/file/views/default/object/file.php | 10 | ||||
-rw-r--r-- | mod/file/views/default/river/object/file/create.php | 30 |
16 files changed, 69 insertions, 138 deletions
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php index 5d5c28bee..88a01745d 100644 --- a/mod/file/actions/file/upload.php +++ b/mod/file/actions/file/upload.php @@ -13,8 +13,6 @@ $container_guid = (int) get_input('container_guid', 0); $guid = (int) get_input('file_guid'); $tags = get_input("tags"); -$ajax = get_input('ajax', FALSE); - if ($container_guid == 0) { $container_guid = elgg_get_logged_in_user_guid(); } @@ -33,17 +31,8 @@ if ($new_file) { if (empty($_FILES['upload']['name'])) { $error = elgg_echo('file:nofile'); - - if ($ajax) { - echo json_encode(array( - 'status' => 'error', - 'message' => $error - )); - exit; - } else { - register_error($error); - forward(REFERER); - } + register_error($error); + forward(REFERER); } $file = new FilePluginFile(); @@ -106,9 +95,10 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) { $file->originalfilename = $_FILES['upload']['name']; $file->simpletype = file_get_simple_type($_FILES['upload']['type']); + // Open the file to guarantee the directory exists $file->open("write"); - $file->write(get_uploaded_file('upload')); $file->close(); + move_uploaded_file($_FILES['upload']['tmp_name'], $file->getFilenameOnFilestore()); $guid = $file->save(); @@ -158,44 +148,22 @@ elgg_clear_sticky_form('file'); // handle results differently for new files and file updates -// ajax is only for new files from embed right now. if ($new_file) { if ($guid) { $message = elgg_echo("file:saved"); - if ($ajax) { - echo json_encode(array( - 'status' => 'success', - 'message' => $message - )); - exit; - - } else { - system_message($message); - add_to_river('river/object/file/create', 'create', elgg_get_logged_in_user_guid(), $file->guid); - } + system_message($message); + add_to_river('river/object/file/create', 'create', elgg_get_logged_in_user_guid(), $file->guid); } else { // failed to save file object - nothing we can do about this $error = elgg_echo("file:uploadfailed"); - - if ($ajax) { - echo json_encode(array( - 'status' => 'error', - 'message' => $error - )); - exit; - - } else { - register_error($error); - } + register_error($error); } - if (!$ajax) { - $container = get_entity($container_guid); - if (elgg_instanceof($container, 'group')) { - forward("file/group/$container->guid/all"); - } else { - forward("file/owner/$container->username"); - } + $container = get_entity($container_guid); + if (elgg_instanceof($container, 'group')) { + forward("file/group/$container->guid/all"); + } else { + forward("file/owner/$container->username"); } } else { diff --git a/mod/file/download.php b/mod/file/download.php index a386d490f..8e0287a1e 100644 --- a/mod/file/download.php +++ b/mod/file/download.php @@ -33,8 +33,7 @@ if (strpos($mime, "image/") !== false) { header("Content-Disposition: attachment; filename=\"$filename\""); } -$contents = $file->grabFile(); -$splitString = str_split($contents, 8192); -foreach ($splitString as $chunk) { - echo $chunk; -} +ob_clean(); +flush(); +readfile($file->getFilenameOnFilestore()); +exit; diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index 7ced3f112..72b198d54 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -11,11 +11,8 @@ $english = array( * Menu items and titles */ 'file' => "Files", - 'files' => "My Files", - 'file:yours' => "Your files", - 'file:yours:friends' => "Your friends' files", 'file:user' => "%s's files", - 'file:friends' => "%s's friends' files", + 'file:friends' => "Friends' files", 'file:all' => "All site files", 'file:edit' => "Edit file", 'file:more' => "More files", @@ -73,8 +70,8 @@ $english = array( 'file:display:number' => "Number of files to display", - 'file:river:create' => 'uploaded the file', - 'river:commented:object:file' => 'the file', + 'river:create:object:file' => '%s uploaded the file %s', + 'river:comment:object:file' => '%s commented on the file %s', 'item:object:file' => 'Files', diff --git a/mod/file/pages/file/edit.php b/mod/file/pages/file/edit.php index 66529af0b..b396c6e9b 100644 --- a/mod/file/pages/file/edit.php +++ b/mod/file/pages/file/edit.php @@ -35,7 +35,6 @@ $body = elgg_view_layout('content', array( 'content' => $content, 'title' => $title, 'filter' => '', - 'buttons' => '', )); echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/friends.php b/mod/file/pages/file/friends.php index 65fc66f62..0b351efaf 100644 --- a/mod/file/pages/file/friends.php +++ b/mod/file/pages/file/friends.php @@ -11,8 +11,9 @@ elgg_push_breadcrumb(elgg_echo('file'), "file/all"); elgg_push_breadcrumb($owner->name, "file/owner/$owner->username"); elgg_push_breadcrumb(elgg_echo('friends')); +elgg_register_title_button(); -$title = elgg_echo("file:friends", array($owner->name)); +$title = elgg_echo("file:friends"); // offset is grabbed in list_user_friends_objects $content = list_user_friends_objects($owner->guid, 'file', 10, false); diff --git a/mod/file/pages/file/owner.php b/mod/file/pages/file/owner.php index 69ec30425..4e2ec89d4 100644 --- a/mod/file/pages/file/owner.php +++ b/mod/file/pages/file/owner.php @@ -13,24 +13,24 @@ $owner = elgg_get_page_owner_entity(); elgg_push_breadcrumb(elgg_echo('file'), "file/all"); elgg_push_breadcrumb($owner->name); +elgg_register_title_button(); + $params = array(); if ($owner->guid == elgg_get_logged_in_user_guid()) { // user looking at own files - $title = elgg_echo('file:yours'); $params['filter_context'] = 'mine'; } else if (elgg_instanceof($owner, 'user')) { // someone else's files - $title = elgg_echo("file:user", array($owner->name)); - // do not show button or select a tab when viewing someone else's posts + // do not show select a tab when viewing someone else's posts $params['filter_context'] = 'none'; - $params['buttons'] = ''; } else { // group files - $title = elgg_echo("file:user", array($owner->name)); $params['filter'] = ''; } +$title = elgg_echo("file:user", array($owner->name)); + // List files $content = elgg_list_entities(array( 'types' => 'object', diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php index 77c92f444..3e85d45db 100644 --- a/mod/file/pages/file/search.php +++ b/mod/file/pages/file/search.php @@ -15,10 +15,10 @@ group_gatekeeper(); // Get input $md_type = 'simpletype'; -$tag = get_input('tag'); +// avoid reflected XSS attacks by only allowing alnum characters +$file_type = preg_replace('[\W]', '', get_input('tag')); $listtype = get_input('listtype'); -$friends = get_input('friends', false); - +$friends = (bool)get_input('friends', false); // breadcrumbs elgg_push_breadcrumb(elgg_echo('file'), "file/all"); @@ -32,8 +32,8 @@ if ($owner) { if ($friends && $owner) { elgg_push_breadcrumb(elgg_echo('friends'), "file/friends/$owner->username"); } -if ($tag) { - elgg_push_breadcrumb(elgg_echo("file:type:$tag")); +if ($file_type) { + elgg_push_breadcrumb(elgg_echo("file:type:$file_type")); } else { elgg_push_breadcrumb(elgg_echo('all')); } @@ -41,10 +41,10 @@ if ($tag) { // title if (!$owner) { // world files - $title = elgg_echo('all') . ' ' . elgg_echo("file:type:$tag"); + $title = elgg_echo('all') . ' ' . elgg_echo("file:type:$file_type"); } else { $friend_string = $friends ? elgg_echo('file:title:friends') : ''; - $type_string = elgg_echo("file:type:$tag"); + $type_string = elgg_echo("file:type:$file_type"); $title = elgg_echo('file:list:title', array($owner->name, $friend_string, $type_string)); } @@ -76,9 +76,9 @@ $params = array( 'full_view' => false, ); -if ($tag) { +if ($file_type) { $params['metadata_name'] = $md_type; - $params['metadata_value'] = $tag; + $params['metadata_value'] = $file_type; $content = elgg_list_entities_from_metadata($params); } else { $content = elgg_list_entities($params); @@ -86,7 +86,6 @@ if ($tag) { $body = elgg_view_layout('content', array( 'filter' => '', - 'buttons' => '', 'content' => $content, 'title' => $title, 'sidebar' => $sidebar, diff --git a/mod/file/pages/file/upload.php b/mod/file/pages/file/upload.php index d97cc038d..3aa25b6db 100644 --- a/mod/file/pages/file/upload.php +++ b/mod/file/pages/file/upload.php @@ -32,7 +32,6 @@ $body = elgg_view_layout('content', array( 'content' => $content, 'title' => $title, 'filter' => '', - 'buttons' => '', )); echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/view.php b/mod/file/pages/file/view.php index daa2a400e..50c55a74f 100644 --- a/mod/file/pages/file/view.php +++ b/mod/file/pages/file/view.php @@ -22,14 +22,20 @@ $title = $file->title; elgg_push_breadcrumb($title); -$content = elgg_view_entity($file, true); +$content = elgg_view_entity($file, array('full_view' => true)); $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", + 'link_class' => 'elgg-button elgg-button-action', +)); + $body = elgg_view_layout('content', array( 'content' => $content, 'title' => $title, 'filter' => '', - 'header' => '', )); echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/world.php b/mod/file/pages/file/world.php index bfe965084..e438ca2f0 100644 --- a/mod/file/pages/file/world.php +++ b/mod/file/pages/file/world.php @@ -7,6 +7,8 @@ elgg_push_breadcrumb(elgg_echo('file')); +elgg_register_title_button(); + $limit = get_input("limit", 10); $title = elgg_echo('file:all'); diff --git a/mod/file/views/default/file/embed_upload.php b/mod/file/views/default/file/embed_upload.php deleted file mode 100644 index e5076b052..000000000 --- a/mod/file/views/default/file/embed_upload.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -/** - * Files upload form for embed - */ - -echo elgg_view_form('file/upload', array('id' => 'file_embed_upload'), array('ajax' => TRUE)); - - diff --git a/mod/file/views/default/file/group_module.php b/mod/file/views/default/file/group_module.php index 830b1096c..c37b13927 100644 --- a/mod/file/views/default/file/group_module.php +++ b/mod/file/views/default/file/group_module.php @@ -14,10 +14,6 @@ $all_link = elgg_view('output/url', array( 'text' => elgg_echo('link:view:all'), )); -$header = "<span class=\"groups-widget-viewall\">$all_link</span>"; -$header .= '<h3>' . elgg_echo('file:group') . '</h3>'; - - elgg_push_context('widgets'); $options = array( 'type' => 'object', @@ -34,12 +30,14 @@ if (!$content) { $content = '<p>' . elgg_echo('file:none') . '</p>'; } -if ($group->canWriteToContainer()) { - $new_link = elgg_view('output/url', array( - 'href' => "file/add/$group->guid", - 'text' => elgg_echo('file:add'), - )); - $content .= "<span class='elgg-widget-more'>$new_link</span>"; -} +$new_link = elgg_view('output/url', array( + 'href' => "file/add/$group->guid", + 'text' => elgg_echo('file:add'), +)); -echo elgg_view_module('info', '', $content, array('header' => $header)); +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('file:group'), + 'content' => $content, + 'all_link' => $all_link, + 'add_link' => $new_link, +)); diff --git a/mod/file/views/default/file/typecloud.php b/mod/file/views/default/file/typecloud.php index ce4d6c127..4253bf674 100644 --- a/mod/file/views/default/file/typecloud.php +++ b/mod/file/views/default/file/typecloud.php @@ -15,7 +15,7 @@ function file_type_cloud_get_url($type, $friends) { } if ($type->tag == "image") { - $url .= "&listtype=gallery"; + $url .= "&list_type=gallery"; } if (elgg_get_page_owner_guid()) { diff --git a/mod/file/views/default/forms/file/upload.php b/mod/file/views/default/forms/file/upload.php index 001e66674..f637a419e 100644 --- a/mod/file/views/default/forms/file/upload.php +++ b/mod/file/views/default/forms/file/upload.php @@ -11,13 +11,17 @@ $desc = elgg_extract('description', $vars, ''); $tags = elgg_extract('tags', $vars, ''); $access_id = elgg_extract('access_id', $vars, ACCESS_DEFAULT); $container_guid = elgg_extract('container_guid', $vars); +if (!$container_guid) { + $container_guid = elgg_get_logged_in_user_guid(); +} $guid = elgg_extract('guid', $vars, null); -$ajax = elgg_extract('ajax', $vars, FALSE); if ($guid) { $file_label = elgg_echo("file:replace"); + $submit_label = elgg_echo('save'); } else { $file_label = elgg_echo("file:file"); + $submit_label = elgg_echo('upload'); } ?> @@ -49,21 +53,16 @@ if ($categories) { <label><?php echo elgg_echo('access'); ?></label><br /> <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?> </div> -<div> +<div class="elgg-foot"> <?php echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid)); -//@todo this should not be necessary in 1.8... -- ajax actions can be auto-detected -if ($ajax) { - echo elgg_view('input/hidden', array('name' => 'ajax', 'value' => 1)); -} - if ($guid) { echo elgg_view('input/hidden', array('name' => 'file_guid', 'value' => $guid)); } -echo elgg_view('input/submit', array('value' => elgg_echo("save"))); +echo elgg_view('input/submit', array('value' => $submit_label)); ?> </div> diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php index 93a21c8e6..95e190d35 100644 --- a/mod/file/views/default/object/file.php +++ b/mod/file/views/default/object/file.php @@ -67,12 +67,6 @@ if ($full && !elgg_in_context('gallery')) { $extra = elgg_view("file/specialcontent/$base_type/default", $vars); } - $download = elgg_view('output/url', array( - 'href' => "mod/file/download.php?file_guid=$file->guid", - 'text' => elgg_echo("file:download"), - 'class' => 'elgg-button elgg-button-action', - )); - $header = elgg_view_title($file->title); $params = array( @@ -82,17 +76,16 @@ if ($full && !elgg_in_context('gallery')) { 'subtitle' => $subtitle, 'tags' => $tags, ); + $params = $params + $vars; $list_body = elgg_view('object/elements/summary', $params); $file_info = elgg_view_image_block($file_icon, $list_body); echo <<<HTML -$header $file_info <div class="file elgg-content"> $body $extra - <p>$download</p> </div> HTML; @@ -112,6 +105,7 @@ HTML; 'tags' => $tags, 'content' => $excerpt, ); + $params = $params + $vars; $list_body = elgg_view('object/elements/summary', $params); echo elgg_view_image_block($file_icon, $list_body); diff --git a/mod/file/views/default/river/object/file/create.php b/mod/file/views/default/river/object/file/create.php index 620d1d18c..dad629120 100644 --- a/mod/file/views/default/river/object/file/create.php +++ b/mod/file/views/default/river/object/file/create.php @@ -7,29 +7,7 @@ $object = $vars['item']->getObjectEntity(); $excerpt = strip_tags($object->description); $excerpt = elgg_get_excerpt($excerpt); -$params = array( - 'href' => $object->getURL(), - 'text' => $object->title, -); -$link = elgg_view('output/url', $params); - -$group_string = ''; -$container = $object->getContainerEntity(); -if ($container instanceof ElggGroup) { - $params = array( - 'href' => $container->getURL(), - 'text' => $container->name, - ); - $group_link = elgg_view('output/url', $params); - $group_string = elgg_echo('river:ingroup', array($group_link)); -} - -echo elgg_echo('file:river:create'); - -echo " $link $group_string"; - -if ($excerpt) { - echo '<div class="elgg-river-content">'; - echo $excerpt; - echo '</div>'; -} +echo elgg_view('river/item', array( + 'item' => $vars['item'], + 'message' => $excerpt, +));
\ No newline at end of file |