summaryrefslogtreecommitdiff
path: root/modules/watermark
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2013-03-19 16:41:42 +0000
committerNathan Kinkade <nath@nkinka.de>2013-03-19 16:41:42 +0000
commit3908e37d965fa76ea774e76ddf42365a872a5f27 (patch)
tree457e1a1e465f83855eee96ba287cd91f1623395c /modules/watermark
parent711651f727e093cc7357a6bbff6bd992fd6dfd80 (diff)
parent1eab94f6062b5f54ea5d9db01d968e7195f3de9d (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/watermark')
-rw-r--r--modules/watermark/controllers/admin_watermarks.php24
-rw-r--r--modules/watermark/tests/Admin_Watermarks_Controller_Test.php6
2 files changed, 16 insertions, 14 deletions
diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php
index b058d6a5..bbefcf01 100644
--- a/modules/watermark/controllers/admin_watermarks.php
+++ b/modules/watermark/controllers/admin_watermarks.php
@@ -55,6 +55,8 @@ class Admin_Watermarks_Controller extends Admin_Controller {
} else {
json::reply(array("result" => "error", "html" => (string)$form));
}
+ // Override the application/json mime type for iframe compatibility. See ticket #2022.
+ header("Content-Type: text/plain; charset=" . Kohana::CHARSET);
}
public function form_delete() {
@@ -67,7 +69,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {
$form = watermark::get_delete_form();
if ($form->validate()) {
if ($name = basename(module::get_var("watermark", "name"))) {
- @unlink(VARPATH . "modules/watermark/$name");
+ system::delete_later(VARPATH . "modules/watermark/$name");
module::clear_var("watermark", "name");
module::clear_var("watermark", "width");
@@ -83,6 +85,8 @@ class Admin_Watermarks_Controller extends Admin_Controller {
} else {
json::reply(array("result" => "error", "html" => (string)$form));
}
+ // Override the application/json mime type for iframe compatibility. See ticket #2022.
+ header("Content-Type: text/plain; charset=" . Kohana::CHARSET);
}
public function form_add() {
@@ -108,7 +112,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {
$name = legal_file::sanitize_filename($name, $extension, "photo");
} catch (Exception $e) {
message::error(t("Invalid or unidentifiable image file"));
- @unlink($file);
+ system::delete_later($file);
return;
}
@@ -120,24 +124,16 @@ class Admin_Watermarks_Controller extends Admin_Controller {
module::set_var("watermark", "position", $form->add_watermark->position->value);
module::set_var("watermark", "transparency", $form->add_watermark->transparency->value);
$this->_update_graphics_rules();
- @unlink($file);
+ system::delete_later($file);
message::success(t("Watermark saved"));
log::success("watermark", t("Watermark saved"));
json::reply(array("result" => "success", "location" => url::site("admin/watermarks")));
} else {
- // rawurlencode the results because the JS code that uploads the file buffers it in an
- // iframe which entitizes the HTML and makes it difficult for the JS to process. If we url
- // encode it now, it passes through cleanly. See ticket #797.
- json::reply(array("result" => "error", "html" => rawurlencode((string)$form)));
+ json::reply(array("result" => "error", "html" => (string)$form));
}
-
- // Override the application/json mime type. The dialog based HTML uploader uses an iframe to
- // buffer the reply, and on some browsers (Firefox 3.6) it does not know what to do with the
- // JSON that it gets back so it puts up a dialog asking the user what to do with it. So force
- // the encoding type back to HTML for the iframe.
- // See: http://jquery.malsup.com/form/#file-upload
- header("Content-Type: text/html; charset=" . Kohana::CHARSET);
+ // Override the application/json mime type for iframe compatibility. See ticket #2022.
+ header("Content-Type: text/plain; charset=" . Kohana::CHARSET);
}
private function _update_graphics_rules() {
diff --git a/modules/watermark/tests/Admin_Watermarks_Controller_Test.php b/modules/watermark/tests/Admin_Watermarks_Controller_Test.php
index 0b4ba84b..6c6ecb15 100644
--- a/modules/watermark/tests/Admin_Watermarks_Controller_Test.php
+++ b/modules/watermark/tests/Admin_Watermarks_Controller_Test.php
@@ -68,6 +68,9 @@ class Admin_Watermarks_Controller_Test extends Gallery_Unit_Test_Case {
$controller->add();
$results = ob_get_clean();
+ // Delete all files marked using system::delete_later (from gallery_event::gallery_shutdown)
+ system::delete_marked_files();
+
// Add should *not* be successful, and watermark should be deleted
$this->assert_equal("", $results);
$this->assert_false(file_exists($watermark_path));
@@ -115,6 +118,9 @@ class Admin_Watermarks_Controller_Test extends Gallery_Unit_Test_Case {
$controller->add();
$results = ob_get_clean();
+ // Delete all files marked using system::delete_later (from gallery_event::gallery_shutdown)
+ system::delete_marked_files();
+
// Add should *not* be successful, and watermark should be deleted
$this->assert_equal("", $results);
$this->assert_false(file_exists($watermark_path));