diff options
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/controllers/simple_uploader.php | 25 | ||||
-rw-r--r-- | modules/gallery/libraries/Form_Uploadify.php | 54 | ||||
-rw-r--r-- | modules/gallery/libraries/Form_Uploadify_buttons.php | 25 | ||||
-rw-r--r-- | modules/gallery/module.info | 3 | ||||
-rw-r--r-- | modules/gallery/views/form_uploadify.html.php (renamed from modules/gallery/views/simple_uploader.html.php) | 97 | ||||
-rw-r--r-- | modules/gallery/views/form_uploadify_buttons.html.php | 8 |
6 files changed, 138 insertions, 74 deletions
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index c6d7fc83..255d5df2 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -26,9 +26,7 @@ class Simple_Uploader_Controller extends Controller { $item = $item->parent(); } - $v = new View("simple_uploader.html"); - $v->item = $item; - print $v; + print self::get_add_form($item); } public function start() { @@ -67,9 +65,11 @@ class Simple_Uploader_Controller extends Controller { html::anchor("photos/$item->id", t("view photo"))); } - $tags = $this->input->post("tags"); - if (!(empty($tags))) { - module::event("add_tags_to_item", $item, $tags); + // We currently have no way of showing errors if validation fails, so only call our event + // handlers if validation passes. + $form = self::get_add_form($album); + if ($form->validate()) { + module::event("add_photos_form_completed", $item, $form); } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); @@ -95,4 +95,17 @@ class Simple_Uploader_Controller extends Controller { print json_encode(array("result" => "success")); } + public function get_add_form($album) { + $form = new Forge("simple_uploader/finish", "", "post", array("id" => "g-add-photos-form")); + $group = $form->group("add_photos") + ->label(t("Add photos to %album_title", array("album_title" => html::purify($album->title)))); + $group->uploadify("uploadify")->album($album); + + $group = $form->group("actions"); + $group->uploadify_buttons(""); + + module::event("add_photos_form", $album, $form); + + return $form; + } } diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php new file mode 100644 index 00000000..b1d9fa74 --- /dev/null +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -0,0 +1,54 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 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 Form_Uploadify_Core extends Form_Input { + protected $data = array( + "name" => false, + "type" => "UNKNOWN", + "url" => "", + "text" => ""); + + public function __construct($name) { + parent::__construct($name); + $this->data["script_data"] = array( + "g3sid" => Session::instance()->id(), + "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), + "csrf" => access::csrf_token()); + } + + public function album(Item_Model $album) { + $this->data["album"] = $album; + return $this; + } + + public function script_data($key, $value) { + $this->data["script_data"][$key] = $value; + } + + public function render() { + $v = new View("form_uploadify.html"); + $v->album = $this->data["album"]; + $v->script_data = $this->data["script_data"]; + return $v; + } + + public function validate() { + return true; + } +}
\ No newline at end of file diff --git a/modules/gallery/libraries/Form_Uploadify_buttons.php b/modules/gallery/libraries/Form_Uploadify_buttons.php new file mode 100644 index 00000000..549010b8 --- /dev/null +++ b/modules/gallery/libraries/Form_Uploadify_buttons.php @@ -0,0 +1,25 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 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 Form_Uploadify_buttons_Core extends Form_Input { + public function render() { + $v = new View("form_uploadify_buttons.html"); + return $v; + } +}
\ No newline at end of file diff --git a/modules/gallery/module.info b/modules/gallery/module.info index c3a153b1..ba1ee91d 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,4 +1,5 @@ name = "Gallery 3" description = "Gallery core application" -version = 19 ; Note: skip version 20, use 21 as the next version +; Note: skip version 20, use 21 as the next version +version = 19 diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/form_uploadify.html.php index d23b89e0..7448db84 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -18,12 +18,8 @@ $("#g-add-photos-canvas").ready(function () { $("#g-uploadify").uploadify({ uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>", - script: "<?= url::site("simple_uploader/add_photo/{$item->id}") ?>", - scriptData: <?= json_encode(array( - "g3sid" => Session::instance()->id(), - "tags" => "", - "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), - "csrf" => $csrf)) ?>, + script: "<?= url::site("simple_uploader/add_photo/{$album->id}") ?>", + scriptData: <?= json_encode($script_data) ?>, fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", fileDesc: <?= t("Photos and movies")->for_js() ?>, cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>", @@ -92,69 +88,36 @@ return true; } }); - <? if (module::active("tag")): ?> - $('#g-add-photos-tags').autocomplete( - '<?= url::site("tags/autocomplete") ?>', - {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} - ); - $('#g-add-photos-tags').blur(function (event) { - $("#g-uploadify").uploadifySettings("scriptData", {"tags": $(this).val()}); - }); - <? endif ?> }); </script> -<form id="g-add-photos-form" action="<?= url::site("simple_uploader/finish?csrf=$csrf") ?>"> - <fieldset> - <legend> - <?= t("Add photos to %album_title", array("album_title" => html::purify($item->title))) ?> - </legend> - </fieldset> - <div id="g-add-photos"> - <? if (ini_get("suhosin.session.encrypt")): ?> - <ul id="g-action-status" class="g-message-block"> - <li class="g-error"> - <?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.", - array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt", - "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> - </li> - </ul> - <? endif ?> - - <div> - <p> - <?= t("Photos will be uploaded to album: ") ?> - </p> - <ul class="g-breadcrumbs"> - <? foreach ($item->parents() as $i => $parent): ?> - <li<? if ($i == 0) print " class=\"g-first\"" ?>> <?= html::clean($parent->title) ?> </li> - <? endforeach ?> - <li class="g-active"> <?= html::purify($item->title) ?> </li> - </ul> - </div> - - <div id="g-add-photos-canvas" style="text-align: center;"> - <a id="g-add-photos-button" class="ui-corner-all" style="padding-bottom: 1em;" href="#"><?= t("Select Photos...") ?></a> - <span id="g-uploadify"></span> - </div> - <div id="g-add-photos-status" style="text-align: center;"> - <ul> - </ul> - </div> +<? if (ini_get("suhosin.session.encrypt")): ?> +<ul id="g-action-status" class="g-message-block"> + <li class="g-error"> + <?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.", + array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt", + "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> + </li> +</ul> +<? endif ?> - <? if (module::active("tag")): ?> - <div style="clear: both;"> - <label for="g-add-photos-tags"><?= t("Add tags to all uploaded files") ?></label> - <input type="text" id="g-add-photos-tags" name="tags" value="" /> - </div> - <? endif ?> +<div> + <p> + <?= t("Photos will be uploaded to album: ") ?> + </p> + <ul class="g-breadcrumbs"> + <? foreach ($album->parents() as $i => $parent): ?> + <li<? if ($i == 0) print " class=\"g-first\"" ?>> <?= html::clean($parent->title) ?> </li> + <? endforeach ?> + <li class="g-active"> <?= html::purify($album->title) ?> </li> + </ul> +</div> - <!-- Proxy the done request back to our form, since its been ajaxified --> - <button id="g-upload-done" class="ui-state-default ui-corner-all" onclick="$('#g-add-photos-form').submit();return false;"> - <?= t("Done") ?> - </button> - <button id="g-upload-cancel-all" class="ui-state-default ui-corner-all ui-state-disabled" onclick="$('#g-uploadify').uploadifyClearQueue();return false;" disabled="disabled"> - <?= t("Cancel All") ?> - </button> - </div> -</form> +<div id="g-add-photos-canvas" style="text-align: center;"> + <a id="g-add-photos-button" class="ui-corner-all" style="padding-bottom: 1em;" href="#"><?= t("Select Photos...") ?></a> + <span id="g-uploadify"></span> +</div> +<div id="g-add-photos-status" style="text-align: center;"> + <ul> + </ul> +</div> diff --git a/modules/gallery/views/form_uploadify_buttons.html.php b/modules/gallery/views/form_uploadify_buttons.html.php new file mode 100644 index 00000000..d88bb6aa --- /dev/null +++ b/modules/gallery/views/form_uploadify_buttons.html.php @@ -0,0 +1,8 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<!-- Proxy the done request back to our form, since its been ajaxified --> +<button id="g-upload-done" class="ui-state-default ui-corner-all" onclick="$('#g-add-photos-form').submit();return false;"> + <?= t("Done") ?> +</button> +<button id="g-upload-cancel-all" class="ui-state-default ui-corner-all ui-state-disabled" onclick="$('#g-uploadify').uploadifyClearQueue();return false;" disabled="disabled"> + <?= t("Cancel All") ?> +</button> |