From dee20ed6a2bd92a2e67c27ccc7d60303d66cdcde Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 26 Dec 2008 05:43:06 +0000 Subject: Added the concept of "permanent" messages that we show to admins. Use this to show a "your thumbs/resizes are out of date" message whenever we change the graphics rules. Tweak watermark module to add graphics rules whenever we make a change, which triggers the graphics module to add the permanent message. --- modules/watermark/controllers/admin_watermarks.php | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'modules/watermark/controllers') diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index 733e0589..9f87fed4 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -40,8 +40,9 @@ class Admin_Watermarks_Controller extends Admin_Controller { public function edit() { $form = watermark::get_edit_form(); if ($form->validate()) { - module::set_var("watermark", "position", $form->edit_watermark->position->value); - graphics::mark_all_dirty(); + $position = $form->edit_watermark->position->value; + module::set_var("watermark", "position", $position); + $this->_update_graphics_rules(module::get_var("watermark", "name"), $position); log::success("watermark", _("Watermark changed")); message::success(_("Watermark changed")); @@ -70,7 +71,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { module::clear_var("watermark", "height"); module::clear_var("watermark", "mime_type"); module::clear_var("watermark", "position"); - graphics::mark_all_dirty(); + $this->_update_graphics_rules(); log::success("watermark", _("Watermark deleted")); message::success(_("Watermark deleted")); @@ -105,12 +106,13 @@ class Admin_Watermarks_Controller extends Admin_Controller { } rename($file, VARPATH . "modules/watermark/$name"); + $position = $form->add_watermark->position->value; module::set_var("watermark", "name", $name); module::set_var("watermark", "width", $image_info[0]); module::set_var("watermark", "height", $image_info[1]); module::set_var("watermark", "mime_type", $image_info["mime"]); - module::set_var("watermark", "position", $form->add_watermark->position->value); - graphics::mark_all_dirty(); + module::set_var("watermark", "position", $position); + $this->_update_graphics_rules(module::get_var("watermark", "name"), $position); @unlink($file); message::success(_("Watermark saved")); @@ -124,4 +126,15 @@ class Admin_Watermarks_Controller extends Admin_Controller { "form" => $form->__toString())); } } + + private function _update_graphics_rules($name=null, $position=null) { + graphics::remove_rules("watermark"); + if ($name) { + graphics::add_rule( + "watermark", "thumb", "compose", + array("overlay" => VARPATH . "modules/watermark/$name", + "position" => $position), + 1000); + } + } } \ No newline at end of file -- cgit v1.2.3