summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-12-16 17:30:18 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-12-16 17:30:18 +0000
commit04441e11cccceea92454d3fcbc54e0e103fb8bd6 (patch)
tree06ce3eb18eb156b736cb3510ac92e1af3aa4bb94
parent931d8c6bdce9fa4656d36c2f07ff6a38d0b47c5d (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
-rw-r--r--core/controllers/welcome.php10
-rw-r--r--core/views/welcome.html.php6
-rw-r--r--modules/watermark/controllers/watermark.php39
-rw-r--r--modules/watermark/controllers/watermark_admin.php21
-rw-r--r--modules/watermark/helpers/watermark.php6
-rw-r--r--modules/watermark/helpers/watermark_menu.php16
-rw-r--r--modules/watermark/js/watermark.js2
-rw-r--r--modules/watermark/views/watermark_position.html.php28
8 files changed, 54 insertions, 74 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index 5afe094e..7235e2c0 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -35,18 +35,12 @@ class Welcome_Controller extends Template_Controller {
->where("type", "photo")->orderby("level", "desc")->find();
$this->template->album_tree = $this->_load_album_tree();
$this->template->add_photo_html = $this->_get_add_photo_html();
- if (module::is_installed("watermark")) {
- $this->template->add_watermark_html = $this->_get_add_watermark_html();
- } else {
- $this->template->add_watermark_html = "";
- }
} catch (Exception $e) {
$this->template->album_count = 0;
$this->template->photo_count = 0;
$this->template->deepest_photo = null;
$this->template->album_tree = array();
$this->template->add_photo_html = "";
- $this->template->add_watermark_html = "";
}
$this->_load_user_info();
@@ -518,8 +512,4 @@ class Welcome_Controller extends Template_Controller {
$parent = ORM::factory("item", $parent_id);
return photo::get_add_form($parent);
}
-
- public function _get_add_watermark_html() {
- return watermark::get_watermark_form();
- }
}
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index d41b81c2..7f3d27a9 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -160,9 +160,6 @@
<? if (module::is_installed("rearrange")): ?>
<?= rearrange_block::head(null) ?>
<? endif ?>
- <? if (module::is_installed("watermark")): ?>
- <?= watermark_block::head(null) ?>
- <? endif ?>
</head>
<body>
<div class="outer">
@@ -287,9 +284,6 @@
<?= new View("rearrange.html") ?>
</fieldset>
<? endif ?>
- <? if (module::is_installed("watermark")): ?>
- <?= $add_watermark_html ?>
- <? endif ?>
</div>
<? if (module::is_installed("user")): ?>
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" >