diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index c6d7fc838c..255d5df29a 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -26,9 +26,7 @@ public function app($id) { $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 @@ public function add_photo($id) { 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 @@ public function finish() { 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 0000000000..b1d9fa74e5 --- /dev/null +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -0,0 +1,54 @@ + 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 0000000000..549010b83a --- /dev/null +++ b/modules/gallery/libraries/Form_Uploadify_buttons.php @@ -0,0 +1,25 @@ +", - script: "id}") ?>", - scriptData: Session::instance()->id(), - "tags" => "", - "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), - "csrf" => $csrf)) ?>, + script: "id}") ?>", + scriptData: , fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", fileDesc: for_js() ?>, cancelImg: "", @@ -92,68 +88,36 @@ return true; } }); - - $('#g-add-photos-tags').autocomplete( - '', - {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} - ); - $('#g-add-photos-tags').blur(function (event) { - $("#g-uploadify").uploadifySettings("scriptData", {"tags": $(this).val()}); - }); - }); -
"> -
- html::purify($item->title))) ?> - -
-
- - - - -
-

- -

-
    - parents() as $i => $parent): ?> - > title) ?> - -
  • title) ?>
  • -
-
- -
- - -
-
-
    -
-
+ + + - -
- - -
- +
+

+ +

+
    + parents() as $i => $parent): ?> + > title) ?> + +
  • title) ?>
  • +
+
- - - -
-
+
+ + +
+
+ +
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 0000000000..d88bb6aa98 --- /dev/null +++ b/modules/gallery/views/form_uploadify_buttons.html.php @@ -0,0 +1,8 @@ + + + + diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 19c917ac4f..a857a99d28 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -98,13 +98,31 @@ static function item_index_data($item, $data) { $data[] = join(" ", tag::item_tags($item)); } - static function add_tags_to_item($item, $tags) { - foreach (split(",", $tags) as $tag_name) { + static function add_photos_form($album, $form) { + $group = $form->add_photos; + $group->input("tags") + ->label(t("Add tags to all uploaded files")) + ->value(""); + $group->uploadify->script_data("tags", ""); + + $autocomplete_url = url::site("tags/autocomplete"); + $group->script("") + ->text("$('input[name=tags]') + .autocomplete( + '$autocomplete_url', + {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} + ) + .change(function (event) { + $('#g-uploadify').uploadifySettings('scriptData', {'tags': $(this).val()}); + });"); + } + + static function add_photos_form_completed($album, $form) { + foreach (split(",", $form->add_photos->tags->value) as $tag_name) { $tag_name = trim($tag_name); if ($tag_name) { - $tag = tag::add($item, $tag_name); + $tag = tag::add($album, $tag_name); } } } - } diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 03d439180d..9c440412ae 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -86,9 +86,13 @@ user_menu() ?> header_top() ?> -
+ + + + + header_bottom() ?>