diff options
Diffstat (limited to 'modules/watermark')
| -rw-r--r-- | modules/watermark/controllers/admin_watermarks.php | 24 | ||||
| -rw-r--r-- | modules/watermark/helpers/watermark.php | 23 | ||||
| -rw-r--r-- | modules/watermark/views/admin_watermarks.html.php | 5 | 
3 files changed, 37 insertions, 15 deletions
diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index f009c0cf..3fc06c06 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -24,23 +24,21 @@ class Admin_Watermarks_Controller extends Admin_Controller {      $view = new Admin_View("admin.html");      $view->content = new View("admin_watermarks.html");      if ($name) { -      $view->content->name = $name; +      $view->content->name = module::get_var("watermark", "name");        $view->content->url = url::file("var/modules/watermark/$name"); -      $view->content->width = $name; -      $view->content->height = $name; +      $view->content->width = module::get_var("watermark", "width"); +      $view->content->height = module::get_var("watermark", "height"); +      $view->content->position = module::get_var("watermark", "position");      }      print $view;    } -  public function form_add() { -    print watermark::get_add_form(); -  } -    public function form_edit() {      print watermark::get_edit_form();    }    public function edit() { +    rest::http_content_type(rest::JSON);      $form = watermark::get_edit_form();      if ($form->validate()) {        module::set_var("watermark", "position", $form->edit_watermark->position->value); @@ -59,6 +57,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {    }    public function delete() { +    rest::http_content_type(rest::JSON);      $form = watermark::get_delete_form();      if ($form->validate()) {        if ($name = module::get_var("watermark", "name")) { @@ -70,7 +69,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {          module::clear_var("watermark", "mime_type");          module::clear_var("watermark", "position"); -        log::success("watermark", _("Deleted watermark")); +        log::success("watermark", _("Watermark deleted"));          message::success(_("Watermark deleted"));        }        print json_encode( @@ -83,7 +82,12 @@ class Admin_Watermarks_Controller extends Admin_Controller {      }    } -  public function upload() { +  public function form_add() { +    print watermark::get_add_form(); +  } + +  public function add() { +    rest::http_content_type(rest::JSON);      $form = watermark::get_add_form();      if ($form->validate()) {        $file = $_POST["file"]; @@ -105,7 +109,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {        module::set_var("watermark", "mime_type", $image_info["mime"]);        module::set_var("watermark", "position", $form->add_watermark->position->value);        message::success(_("Watermark saved")); -      log::success("watermark", _("Uploaded watermark")); +      log::success("watermark", _("Watermark saved"));        @unlink($file);        print json_encode( diff --git a/modules/watermark/helpers/watermark.php b/modules/watermark/helpers/watermark.php index c17bf0ab..af266bc5 100644 --- a/modules/watermark/helpers/watermark.php +++ b/modules/watermark/helpers/watermark.php @@ -19,7 +19,7 @@   */  class watermark_Core {    public static function get_add_form() { -    $form = new Forge("admin/watermarks/upload", "", "post"); +    $form = new Forge("admin/watermarks/add", "", "post");      $group = $form->group("add_watermark")->label(_("Upload Watermark"));      $group->upload("file")->label(_("Watermark"))->rules("allow[jpg,png,gif]|size[1MB]|required");      $group->dropdown("position")->label(_("Watermark Position")) @@ -35,9 +35,7 @@ class watermark_Core {      $form = new Forge("admin/watermarks/edit", "", "post");      $group = $form->group("edit_watermark")->label(_("Edit Watermark"));      $group->dropdown("position")->label(_("Watermark Position")) -      ->options(array("northwest",  "north",  "northeast", -                      "west",       "center", "east", -                      "southwest",  "south",  "southeast")) +      ->options(self::positions())        ->selected("8");      $group->submit(_("Modify"));      return $form; @@ -49,4 +47,21 @@ class watermark_Core {      $group->submit(_("Delete"));      return $form;    } + +  public static function positions() { +    return array("northwest" => _("Northwest"), +                 "north" => _("North"), +                 "northeast" => _("Northeast"), +                 "west" => _("West"), +                 "center" => _("Center"), +                 "east" => _("East"), +                 "southwest" => _("Southwest"), +                 "south" => _("South"), +                 "southeast" => _("Southeast")); +  } + +  public static function position($key) { +    $positions = self::positions(); +    return $positions[$key]; +  }  }
\ No newline at end of file diff --git a/modules/watermark/views/admin_watermarks.html.php b/modules/watermark/views/admin_watermarks.html.php index adeba0ef..e4e5cdde 100644 --- a/modules/watermark/views/admin_watermarks.html.php +++ b/modules/watermark/views/admin_watermarks.html.php @@ -7,7 +7,7 @@    <? if (empty($name)): ?>    <a href="<?= url::site("admin/watermarks/form_add") ?>" -     title="<?= _("Add Watermark") ?>" +     title="<?= _("Upload a watermark") ?>"       class="gDialogLink"><?= _("Upload a watermark") ?></a>    <? else: ?>    <h2> <?= _("Active Watermark") ?> </h2> @@ -17,6 +17,9 @@    <p>      <div class="image">        <img width="<?= $width ?>" height="<? $height ?>" src="<?= $url ?>"/> +      <p> +        <?= sprintf(_("Position: %s"), watermark::position($position)) ?> +      </p>      </div>      <div class="controls">        <a href="<?= url::site("admin/watermarks/form_edit") ?>"  | 
