diff options
| author | Tristan Zur <tzur@webserver.ccwn.org> | 2015-06-10 20:55:53 +0200 |
|---|---|---|
| committer | Tristan Zur <tzur@webserver.ccwn.org> | 2015-06-10 20:55:53 +0200 |
| commit | 406abd7c4df1ace2cd3e4e17159e8941a2e8c0c4 (patch) | |
| tree | a324be16021f44f2fd6d55e609f47024e945b1db /modules/watermark/helpers | |
Initial import
Diffstat (limited to 'modules/watermark/helpers')
| -rw-r--r-- | modules/watermark/helpers/watermark.php | 82 | ||||
| -rw-r--r-- | modules/watermark/helpers/watermark_event.php | 29 | ||||
| -rw-r--r-- | modules/watermark/helpers/watermark_installer.php | 42 |
3 files changed, 153 insertions, 0 deletions
diff --git a/modules/watermark/helpers/watermark.php b/modules/watermark/helpers/watermark.php new file mode 100644 index 0000000..3357c14 --- /dev/null +++ b/modules/watermark/helpers/watermark.php @@ -0,0 +1,82 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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_Core { + static function get_add_form() { + for ($i = 1; $i <= 100; $i++) { + $range[$i] = "$i%"; + } + + $form = new Forge("admin/watermarks/add", "", "post", array("id" => "g-add-watermark-form")); + $group = $form->group("add_watermark")->label(t("Upload watermark")); + $group->upload("file")->label(t("Watermark"))->rules("allow[jpg,png,gif]|size[1MB]|required") + ->error_messages("required", "You must select a watermark") + ->error_messages("invalid_type", "The watermark must be a JPG, GIF or PNG") + ->error_messages("max_size", "The watermark is too big (1 MB max)"); + $group->dropdown("position")->label(t("Watermark position")) + ->options(self::positions()) + ->selected("southeast"); + $group->dropdown("transparency")->label(t("Transparency (100% = completely transparent)")) + ->options($range) + ->selected(1); + $group->submit("")->value(t("Upload")); + return $form; + } + + static function get_edit_form() { + for ($i = 1; $i <= 100; $i++) { + $range[$i] = "$i%"; + } + + $form = new Forge("admin/watermarks/edit", "", "post", array("id" => "g-edit-watermark-form")); + $group = $form->group("edit_watermark")->label(t("Edit Watermark")); + $group->dropdown("position")->label(t("Watermark Position")) + ->options(self::positions()) + ->selected(module::get_var("watermark", "position")); + $group->dropdown("transparency")->label(t("Transparency (100% = completely transparent)")) + ->options($range) + ->selected(module::get_var("watermark", "transparency")); + $group->submit("")->value(t("Save")); + return $form; + } + + static function get_delete_form() { + $form = new Forge("admin/watermarks/delete", "", "post", array("id" => "g-delete-watermark-form")); + $group = $form->group("delete_watermark")->label(t("Really delete Watermark?")); + $group->submit("")->value(t("Delete")); + return $form; + } + + static function positions() { + return array("northwest" => t("Northwest"), + "north" => t("North"), + "northeast" => t("Northeast"), + "west" => t("West"), + "center" => t("Center"), + "east" => t("East"), + "southwest" => t("Southwest"), + "south" => t("South"), + "southeast" => t("Southeast")); + } + + static function position($key) { + $positions = self::positions(); + return $positions[$key]; + } +}
\ No newline at end of file diff --git a/modules/watermark/helpers/watermark_event.php b/modules/watermark/helpers/watermark_event.php new file mode 100644 index 0000000..7547515 --- /dev/null +++ b/modules/watermark/helpers/watermark_event.php @@ -0,0 +1,29 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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_event_Core { + static function admin_menu($menu, $theme) { + $menu->get("content_menu") + ->append( + Menu::factory("link") + ->id("watermarks") + ->label(t("Watermarks")) + ->url(url::site("admin/watermarks"))); + } +} diff --git a/modules/watermark/helpers/watermark_installer.php b/modules/watermark/helpers/watermark_installer.php new file mode 100644 index 0000000..1333891 --- /dev/null +++ b/modules/watermark/helpers/watermark_installer.php @@ -0,0 +1,42 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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_installer { + static function install() { + $db = Database::instance(); + $db->query("CREATE TABLE IF NOT EXISTS {watermarks} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(32) NOT NULL, + `width` int(9) NOT NULL, + `height` int(9) NOT NULL, + `active` boolean default 0, + `position` boolean default 0, + `mime_type` varchar(64) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + DEFAULT CHARSET=utf8;"); + + @mkdir(VARPATH . "modules/watermark"); + } + + static function uninstall() { + Database::instance()->query("DROP TABLE {watermarks}"); + dir::unlink(VARPATH . "modules/watermark"); + } +} |
