From d330e4203ad9709ed7bb05a2815016e7809173c7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Dec 2008 00:13:22 +0000 Subject: Step 1 of converting watermarks over to be an admin page. --- modules/watermark/controllers/admin_watermarks.php | 78 ++++++++++++++++++++++ modules/watermark/controllers/watermark_admin.php | 78 ---------------------- modules/watermark/helpers/watermark_block.php | 24 ------- modules/watermark/helpers/watermark_menu.php | 26 ++------ 4 files changed, 84 insertions(+), 122 deletions(-) create mode 100644 modules/watermark/controllers/admin_watermarks.php delete mode 100644 modules/watermark/controllers/watermark_admin.php delete mode 100644 modules/watermark/helpers/watermark_block.php diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php new file mode 100644 index 00000000..ef984e24 --- /dev/null +++ b/modules/watermark/controllers/admin_watermarks.php @@ -0,0 +1,78 @@ +validate()) { + $file = $_POST["file"]; + Kohana::log("debug", $file); + + $pathinfo = pathinfo($file); + $watermark_target = $pathinfo["basename"]; + if (copy($file, VARPATH . $watermark_target)) { + module::set_var("watermark", "watermark_image_path", $watermark_target); + unlink($file); + $form->success = _("Watermark saved"); + } else { + // @todo set and error message + } + } + + print $form; + } + + public function get_form($user_id) { + try { + // @todo check for admin user + + $path = module::get_var("watermark", "watermark_image_path"); + $view = new View("watermark_position.html"); + + if (empty($path)) { + // @todo need to do something when there is no watermark + } + + $photo = ORM::factory("item") + ->where("type", "photo") + ->find_all(1, 0)->current(); + + // @todo determine what to do if water mark is not set + // @todo caclulate the view sizes + $view->sample_image = $photo->resize_url(); + $scaleWidth = $photo->resize_width / $photo->width; + $scaleHeight = $photo->resize_height / $photo->height; + $scale = $scaleHeight < $scaleWidth ? $scaleHeight : $scaleWidth; + + $imageinfo = getimagesize(VARPATH . $path); + + $view->watermark_height = $imageinfo[1] * $scale; + $view->watermark_width = $imageinfo[0] * $scale; + $view->watermark_image = url::abs_file("var/" . $path); + + $current_position = module::get_var("watermark", "watermark_position"); + $view->watermark_position_form = watermark::get_watermark_postion_form($current_position); + + print $view; + } catch (Exception $e) { + print $e; + } + } +} \ No newline at end of file diff --git a/modules/watermark/controllers/watermark_admin.php b/modules/watermark/controllers/watermark_admin.php deleted file mode 100644 index 9557e27f..00000000 --- a/modules/watermark/controllers/watermark_admin.php +++ /dev/null @@ -1,78 +0,0 @@ -validate()) { - $file = $_POST["file"]; - Kohana::log("debug", $file); - - $pathinfo = pathinfo($file); - $watermark_target = $pathinfo["basename"]; - if (copy($file, VARPATH . $watermark_target)) { - module::set_var("watermark", "watermark_image_path", $watermark_target); - unlink($file); - $form->success = _("Watermark saved"); - } else { - // @todo set and error message - } - } - - print $form; - } - - public function get_form($user_id) { - try { - // @todo check for admin user - - $path = module::get_var("watermark", "watermark_image_path"); - $view = new View("watermark_position.html"); - - if (empty($path)) { - // @todo need to do something when there is no watermark - } - - $photo = ORM::factory("item") - ->where("type", "photo") - ->find_all(1, 0)->current(); - - // @todo determine what to do if water mark is not set - // @todo caclulate the view sizes - $view->sample_image = $photo->resize_url(); - $scaleWidth = $photo->resize_width / $photo->width; - $scaleHeight = $photo->resize_height / $photo->height; - $scale = $scaleHeight < $scaleWidth ? $scaleHeight : $scaleWidth; - - $imageinfo = getimagesize(VARPATH . $path); - - $view->watermark_height = $imageinfo[1] * $scale; - $view->watermark_width = $imageinfo[0] * $scale; - $view->watermark_image = url::abs_file("var/" . $path); - - $current_position = module::get_var("watermark", "watermark_position"); - $view->watermark_position_form = watermark::get_watermark_postion_form($current_position); - - print $view; - } catch (Exception $e) { - print $e; - } - } -} \ No newline at end of file diff --git a/modules/watermark/helpers/watermark_block.php b/modules/watermark/helpers/watermark_block.php deleted file mode 100644 index 0751268c..00000000 --- a/modules/watermark/helpers/watermark_block.php +++ /dev/null @@ -1,24 +0,0 @@ -admin) { - $menu->get("admin_menu")->append( - Menu::Factory("dialog") - ->id("watermark_Load") - ->label(_("Load Watermark")) - ->url(url::site("admin/watermark/load"))); - - $path = module::get_var("watermark", "watermark_image_path"); - if (!empty($path)) { - $menu->get("admin_menu")->append( - Menu::Factory("dialog") - ->id("watermark_position") - ->label(_("Set Watermark Position")) - ->url(url::site("admin/watermark/get_form/$user->id"))); - } - } + public static function admin($menu, $theme) { + $menu->append( + Menu::factory("link") + ->id("watermarks") + ->label(_("Watermarks")) + ->url(url::site("admin/watermarks"))); } } -- cgit v1.2.3