diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-16 17:30:18 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-16 17:30:18 +0000 |
commit | 04441e11cccceea92454d3fcbc54e0e103fb8bd6 (patch) | |
tree | 06ce3eb18eb156b736cb3510ac92e1af3aa4bb94 /modules | |
parent | 931d8c6bdce9fa4656d36c2f07ff6a38d0b47c5d (diff) |
1) Remove the load watermark from the scaffolding... use the menu option
2) The set watermark dialog is now sizing properly. @todo is recenter in the window
Diffstat (limited to 'modules')
-rw-r--r-- | modules/watermark/controllers/watermark.php | 39 | ||||
-rw-r--r-- | modules/watermark/controllers/watermark_admin.php | 21 | ||||
-rw-r--r-- | modules/watermark/helpers/watermark.php | 6 | ||||
-rw-r--r-- | modules/watermark/helpers/watermark_menu.php | 16 | ||||
-rw-r--r-- | modules/watermark/js/watermark.js | 2 | ||||
-rw-r--r-- | modules/watermark/views/watermark_position.html.php | 28 |
6 files changed, 54 insertions, 58 deletions
diff --git a/modules/watermark/controllers/watermark.php b/modules/watermark/controllers/watermark.php deleted file mode 100644 index a23cce64..00000000 --- a/modules/watermark/controllers/watermark.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access."); -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2008 Bharat Mediratta - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ -class Watermark_Controller extends Controller { - public function load() { - $form = watermark::get_watermark_form(); - if ($form->validate()) { - $file = $_POST["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; - } -}
\ No newline at end of file diff --git a/modules/watermark/controllers/watermark_admin.php b/modules/watermark/controllers/watermark_admin.php index c6d53999..9557e27f 100644 --- a/modules/watermark/controllers/watermark_admin.php +++ b/modules/watermark/controllers/watermark_admin.php @@ -18,6 +18,27 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Watermark_admin_Controller extends Controller { + public function load() { + $form = watermark::get_watermark_form(); + Kohana::log("debug", print_r($form, 1)); + if ($form->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 diff --git a/modules/watermark/helpers/watermark.php b/modules/watermark/helpers/watermark.php index 438fbc24..ce2d5e0b 100644 --- a/modules/watermark/helpers/watermark.php +++ b/modules/watermark/helpers/watermark.php @@ -19,11 +19,10 @@ */ class watermark_Core { public static function get_watermark_form() { - $form = new Forge("watermark/load", "", "post", + $form = new Forge("admin/watermark/load", "", "post", array("id" => "gUploadWatermarkForm", "enctype" => "multipart/form-data")); $group = $form->group("add_watermark")->label(_("Upload Watermark")); $group->upload("file")->label(_("Watermark"))->rules("allow[jpg,png,gif],size[1M]"); - $group->submit(_("Upload")); return $form; } @@ -36,9 +35,6 @@ class watermark_Core { "west", "center", "east", "southwest", "south", "southeast")) ->selected("8"); - - $group->submit(_("Update")); - $group->submit(_("Reset")); return $form; } }
\ No newline at end of file diff --git a/modules/watermark/helpers/watermark_menu.php b/modules/watermark/helpers/watermark_menu.php index 384ba9c4..71927da3 100644 --- a/modules/watermark/helpers/watermark_menu.php +++ b/modules/watermark/helpers/watermark_menu.php @@ -23,12 +23,20 @@ class watermark_menu_Core { public static function site_navigation($menu, $theme) { $user = user::active(); if ($user->admin) { - Kohana::log("debug", print_r($menu, 1)); $menu->get("admin_menu")->append( Menu::Factory("dialog") - ->id("watermark_position") - ->label(_("Set Watermark Position")) - ->url(url::site("admin/watermark/get_form/$user->id"))); + ->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"))); + } } } } diff --git a/modules/watermark/js/watermark.js b/modules/watermark/js/watermark.js index 9117971e..1770abd9 100644 --- a/modules/watermark/js/watermark.js +++ b/modules/watermark/js/watermark.js @@ -1,4 +1,4 @@ -$("document").ready(function() { +$("gUploadWatermarkForm").ready(function() { ajaxify_watermark_add_form(); }); diff --git a/modules/watermark/views/watermark_position.html.php b/modules/watermark/views/watermark_position.html.php index af824ed1..663be90f 100644 --- a/modules/watermark/views/watermark_position.html.php +++ b/modules/watermark/views/watermark_position.html.php @@ -1,13 +1,23 @@ -<? defined("SYSPATH") or die("No direct script access."); ?> +<script> +$("#gWatermarkAdmin").ready(function() { + + var container = $("#gDialog").parent().parent(); + var container_height = $(container).attr("offsetHeight"); + var container_width = $(container).attr("offsetWidth"); + + var new_height = $("#gDialog").attr("offsetHeight") + + container.find("div.ui-dialog-titlebar").attr("offsetHeight") + + container.find("div.ui-dialog-buttonpane").attr("offsetHeight"); + container.css("height", Math.max(new_height, container_height) + "px"); + container.css("width", Math.max($("#gDialog").attr("offsetWidth"), container_width) + "px"); +}); +</script> <div id="gWatermarkAdmin"> - <div id="gTargetImage" class="droppable"> - <img src="<?= $sample_image ?>"></img> - </div> - <div id="gWaterMark"> - <!-- This style and div is only temporary --> - <div style="background-color: #cccccc;"> - <img src="<?= $watermark_image ?>" class="draggable" - width="<?= $watermark_width ?>" height="<?= $watermark_height ?>" /> + <div id="gTarget" class="droppable"> + <img id="gTargetImage" src="<?= $sample_image ?>"></img> + <div id="gWaterMark" style="float:none;z-index:1005;position:absolute;top:100px"> + <img id ="gWaterMarkImage" src="<?= $watermark_image ?>" class="draggable" + width="<?= $watermark_width ?>" height="<?= $watermark_height ?>" /> </div> </div> <div id="gWatermarkPostionForm" > |