summaryrefslogtreecommitdiff
path: root/modules/tag/controllers
diff options
context:
space:
mode:
authorChad Kieffer <ckieffer@gmail.com>2009-07-25 09:25:31 -0600
committerChad Kieffer <ckieffer@gmail.com>2009-07-25 09:25:31 -0600
commiteca46d76a7832f771d377edb3939ea1aded2fac9 (patch)
treed4f0323202c7eb6eab60ff6e14f9905b625e349b /modules/tag/controllers
parent63511316be51f193d37c4f3b9dd3455a9ab60de8 (diff)
parent50d6cc0150b930d79d3e8b90956ffa9655fcc9c5 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/tag/controllers')
-rw-r--r--modules/tag/controllers/tags.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 85f6d16e..a600ea1a 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -53,10 +53,10 @@ class Tags_Controller extends REST_Controller {
$form = tag::get_add_form($item);
if ($form->validate()) {
- foreach (split("[\,\ \;]", $form->add_tag->inputs["name"]->value) as $tag_name) {
+ foreach (split("[\,\;]", $form->add_tag->inputs["name"]->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
- $tag = tag::add($item, $tag_name);
+ $tag = tag::add($item, str_replace(" ", ".", $tag_name));
}
}
@@ -78,4 +78,21 @@ class Tags_Controller extends REST_Controller {
return tag::get_add_form($item);
}
+
+ public function autocomplete() {
+ $tags = array();
+ $tag_parts = preg_split("#[,\s;]+# ", $this->input->get("q"));
+ $limit = $this->input->get("limit");
+ $tag_part = end($tag_parts);
+ $tag_list = ORM::factory("tag")
+ ->like("name", "{$tag_part}%", false)
+ ->orderby("name", "ASC")
+ ->limit($limit)
+ ->find_all();
+ foreach ($tag_list as $tag) {
+ $tags[] = $tag->name;
+ }
+
+ print implode("\n", $tags);
+ }
}