From 92e6ed8a8a9baad24318299edbaa0da1236089ce Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 15 Dec 2008 23:08:18 +0000 Subject: Start of the dialog to specify the watermark placement. For convience, using the imagemagik nomicalture regarding watermark locations (east, west, center, etc.) You can drag the watermark around but it doesn't stay in place. Need to figure out how to resize the dialog box and all of the supporting javascript --- modules/watermark/controllers/watermark.php | 11 ++--- modules/watermark/controllers/watermark_admin.php | 57 +++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 modules/watermark/controllers/watermark_admin.php (limited to 'modules/watermark/controllers') diff --git a/modules/watermark/controllers/watermark.php b/modules/watermark/controllers/watermark.php index 4bf90401..a23cce64 100644 --- a/modules/watermark/controllers/watermark.php +++ b/modules/watermark/controllers/watermark.php @@ -22,13 +22,12 @@ class Watermark_Controller extends Controller { $form = watermark::get_watermark_form(); if ($form->validate()) { $file = $_POST["file"]; - - // Format of the file is config["upload.directory"]/uploadfile-hash-filename. - $index = strrpos($file, "-"); - $watermark_target = VARPATH . substr($file, strrpos($file, "-") + 1); - if (rename($file, $watermark_target)) { - module::set_var("watermark", "watermark_image_path", $watermark_target); + $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 diff --git a/modules/watermark/controllers/watermark_admin.php b/modules/watermark/controllers/watermark_admin.php new file mode 100644 index 00000000..c6d53999 --- /dev/null +++ b/modules/watermark/controllers/watermark_admin.php @@ -0,0 +1,57 @@ +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 -- cgit v1.2.3