summaryrefslogtreecommitdiff
path: root/modules/tag/controllers
diff options
context:
space:
mode:
authorroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
committerroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
commitc62d1f440f077ba806b7ff0c6b90ef89c79b2fd3 (patch)
treeb64f05e2a7bd8db7200e3c407904e255826b4cf2 /modules/tag/controllers
parentb96ac1eb81b7ccd5bd050ffab0ca9ce1feec8f4f (diff)
parentcaa2002d7777e0ceb884d4c628650804620ca2b6 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/tag/controllers')
-rw-r--r--modules/tag/controllers/admin_tags.php8
-rw-r--r--modules/tag/controllers/tags.php19
2 files changed, 22 insertions, 5 deletions
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php
index dcdc16b9..8b8dde21 100644
--- a/modules/tag/controllers/admin_tags.php
+++ b/modules/tag/controllers/admin_tags.php
@@ -53,8 +53,8 @@ class Admin_Tags_Controller extends Admin_Controller {
$name = $tag->name;
Database::instance()->delete("items_tags", array("tag_id" => "$tag->id"));
$tag->delete();
- message::success(t("Deleted tag %tag_name", array("tag_name" => p::clean($name))));
- log::success("tags", t("Deleted tag %tag_name", array("tag_name" => p::clean($name))));
+ message::success(t("Deleted tag %tag_name", array("tag_name" => $name)));
+ log::success("tags", t("Deleted tag %tag_name", array("tag_name" => $name)));
print json_encode(
array("result" => "success",
@@ -98,7 +98,7 @@ class Admin_Tags_Controller extends Admin_Controller {
$tag->save();
$message = t("Renamed tag %old_name to %new_name",
- array("old_name" => p::clean($old_name), "new_name" => p::clean($tag->name)));
+ array("old_name" => $old_name, "new_name" => $tag->name));
message::success($message);
log::success("tags", $message);
@@ -106,7 +106,7 @@ class Admin_Tags_Controller extends Admin_Controller {
array("result" => "success",
"location" => url::site("admin/tags"),
"tag_id" => $tag->id,
- "new_tagname" => p::clean($tag->name)));
+ "new_tagname" => html::clean($tag->name)));
} else {
print json_encode(
array("result" => "error",
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 85f6d16e..c993e374 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -53,7 +53,7 @@ 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);
@@ -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("#,#", $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);
+ }
}