summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Kieffer <ckieffer@gmail.com>2009-11-19 21:51:20 -0700
committerChad Kieffer <ckieffer@gmail.com>2009-11-19 21:51:20 -0700
commit1a9a4a09dea9368794ded2fb8242a63744133817 (patch)
tree9df3465a19b107e5b9958a4695324755c164b22a
parent9d9cc5382cf55b6530139ec5c326efedb31923b7 (diff)
parenteb34b301a75237a0c27b5cca01e6f96e436b7709 (diff)
Merge branch 'master' of github.com:gallery/gallery3
-rw-r--r--modules/gallery/controllers/simple_uploader.php5
-rw-r--r--modules/gallery/views/simple_uploader.html.php19
-rw-r--r--modules/tag/helpers/tag_event.php10
3 files changed, 32 insertions, 2 deletions
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php
index d43d2f9d..c6d7fc83 100644
--- a/modules/gallery/controllers/simple_uploader.php
+++ b/modules/gallery/controllers/simple_uploader.php
@@ -66,6 +66,11 @@ class Simple_Uploader_Controller extends Controller {
log::success("content", t("Added a photo"),
html::anchor("photos/$item->id", t("view photo")));
}
+
+ $tags = $this->input->post("tags");
+ if (!(empty($tags))) {
+ module::event("add_tags_to_item", $item, $tags);
+ }
} catch (Exception $e) {
Kohana::log("alert", $e->__toString());
if (file_exists($temp_filename)) {
diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php
index 80dcc5bc..45fb6a4d 100644
--- a/modules/gallery/views/simple_uploader.html.php
+++ b/modules/gallery/views/simple_uploader.html.php
@@ -21,6 +21,7 @@
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)) ?>,
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4",
@@ -45,7 +46,6 @@
return true;
},
onComplete: function(event, queueID, fileObj, response, data) {
- // @todo handle a response of "Error: xxxx" as an error
var re = /^error: (.*)$/i;
var msg = re.exec(response);
if (msg) {
@@ -57,7 +57,6 @@
}
return true;
},
-
onError: function(event, queueID, fileObj, errorObj) {
var msg = " - ";
if (errorObj.type == "HTTP") {
@@ -91,6 +90,15 @@
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>
@@ -122,6 +130,13 @@
</ul>
</div>
+ <? 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 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>
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 57986e40..19c917ac 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -97,4 +97,14 @@ class tag_event_Core {
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) {
+ $tag_name = trim($tag_name);
+ if ($tag_name) {
+ $tag = tag::add($item, $tag_name);
+ }
+ }
+ }
+
}