summaryrefslogtreecommitdiff
path: root/modules/watermark/controllers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-12-14 23:53:30 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-12-14 23:53:30 +0000
commitdb7e60da32e3feba918cc819a1ef8fada6aec02a (patch)
treec29e16d739ae9696620c8a2782ceeb13895bf274 /modules/watermark/controllers
parentc46bd97407e2eef500fa224ef7593193e3da6d18 (diff)
Change the watermark module to use forge.
Also the watermark file is now stored in varpath. and the location is stored in the module vars table
Diffstat (limited to 'modules/watermark/controllers')
-rw-r--r--modules/watermark/controllers/watermark.php28
1 files changed, 13 insertions, 15 deletions
diff --git a/modules/watermark/controllers/watermark.php b/modules/watermark/controllers/watermark.php
index cd294c6c..4bf90401 100644
--- a/modules/watermark/controllers/watermark.php
+++ b/modules/watermark/controllers/watermark.php
@@ -19,22 +19,20 @@
*/
class Watermark_Controller extends Controller {
public function load() {
- $form = new View("watermark_add_form.html");
- $form->errors = $form->fields = array("file" => "");
+ $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);
- if ($_FILES) {
- $post = Validation::factory(array_merge($_POST, $_FILES))
- ->add_rules("file", "upload::valid", "upload::type[gif,jpg,png]", "upload::size[1M]");
-
- if ($post->validate()) {
- $file = upload::save("file");
- Kohana::log("debug", $file);
- $form->success = _("Watermark saved");
- } else {
- $form->fields = arr::overwrite($form->fields, $post->as_array());
- $form->errors = arr::overwrite($form->errors, $post->errors());
- Kohana::log("debug", print_r($form->errors,1));
- }
+ $form->success = _("Watermark saved");
+ } else {
+ // @todo set and error message
+ }
}
print $form;