summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/controllers/tags.php6
-rw-r--r--modules/tag/helpers/tag_event.php36
-rw-r--r--modules/tag/helpers/tag_menu.php28
-rw-r--r--modules/tag/helpers/tag_search.php24
-rw-r--r--modules/tag/js/tag.js14
-rw-r--r--modules/tag/views/tag_block.html.php4
6 files changed, 30 insertions, 82 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index a600ea1a..c993e374 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, str_replace(" ", ".", $tag_name));
+ $tag = tag::add($item, $tag_name);
}
}
@@ -81,7 +81,7 @@ class Tags_Controller extends REST_Controller {
public function autocomplete() {
$tags = array();
- $tag_parts = preg_split("#[,\s;]+# ", $this->input->get("q"));
+ $tag_parts = preg_split("#,#", $this->input->get("q"));
$limit = $this->input->get("limit");
$tag_part = end($tag_parts);
$tag_list = ORM::factory("tag")
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index bf60978d..57986e40 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -34,8 +34,8 @@ class tag_event_Core {
if (!empty($iptc["2#025"])) {
foreach($iptc["2#025"] as $tag) {
$tag = str_replace("\0", "", $tag);
- foreach (preg_split("/[,;]/", $tag) as $word) {
- $word = preg_replace('/\s+/', '.', trim($word));
+ foreach (preg_split("/,/", $tag) as $word) {
+ $word = trim($word);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") {
$word = utf8_encode($word);
}
@@ -64,25 +64,37 @@ class tag_event_Core {
tag::compact();
}
- static function item_edit_form($item, $view) {
+ static function item_edit_form($item, $form) {
$url = url::site("tags/autocomplete");
- $view->script[] = "$('#gEditFormContainer form').ready(function() {
- $('#gEditFormContainer form input[id=tags]').autocomplete(
- '$url', {max: 30, formatResult: formatTagAutoCompleteResult}
- );
- });";
- $tag_value = implode("; ", tag::item_tags($item));
- $view->form->edit_item->input("tags")->label(t("Tags (comma or semicolon separated)"))
+ $form->script("")
+ ->text("$('form input[id=tags]').ready(function() {
+ $('form input[id=tags]').autocomplete(
+ '$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1});
+ });");
+ $tag_value = implode(", ", tag::item_tags($item));
+ $form->edit_item->input("tags")->label(t("Tags (comma separated)"))
->value($tag_value);
}
static function item_edit_form_completed($item, $form) {
tag::clear_all($item);
- foreach (preg_split("/[,;]/", $form->edit_item->tags->value) as $tag_name) {
+ foreach (preg_split("/,/", $form->edit_item->tags->value) as $tag_name) {
if ($tag_name) {
- tag::add($item, str_replace(" ", ".", $tag_name));
+ tag::add($item, trim($tag_name));
}
}
tag::compact();
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("content_menu")
+ ->append(Menu::factory("link")
+ ->id("tags")
+ ->label(t("Tags"))
+ ->url(url::site("admin/tags")));
+ }
+
+ static function item_index_data($item, $data) {
+ $data[] = join(" ", tag::item_tags($item));
+ }
}
diff --git a/modules/tag/helpers/tag_menu.php b/modules/tag/helpers/tag_menu.php
deleted file mode 100644
index e1b61a93..00000000
--- a/modules/tag/helpers/tag_menu.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?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 tag_menu_Core {
- static function admin($menu, $theme) {
- $menu->get("content_menu")
- ->append(Menu::factory("link")
- ->id("tags")
- ->label(t("Tags"))
- ->url(url::site("admin/tags")));
- }
-}
diff --git a/modules/tag/helpers/tag_search.php b/modules/tag/helpers/tag_search.php
deleted file mode 100644
index 034b7af5..00000000
--- a/modules/tag/helpers/tag_search.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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 tag_search_Core {
- static function item_index_data($item) {
- return join(" ", tag::item_tags($item));
- }
-}
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index bbf44166..765c2a35 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -67,17 +67,3 @@ function editInPlace(element) {
ajaxify_editInPlaceForm();
}
-function formatTagAutoCompleteResult(row) {
- var text = $(".ac_loading").val();
- if (/[\s,;]/.test(text)) {
- for (var i= text.length - 1; i >= 0; i--) {
- var chr = text.charAt(i);
- if (chr == " " || chr == "," || chr == ";") {
- break;
- }
- }
- return text.substr(0, i + 1) + row[0];
- } else {
- return row[0];
- }
-}
diff --git a/modules/tag/views/tag_block.html.php b/modules/tag/views/tag_block.html.php
index 233eb361..59a4ef88 100644
--- a/modules/tag/views/tag_block.html.php
+++ b/modules/tag/views/tag_block.html.php
@@ -5,7 +5,9 @@
$("#gAddTagForm input:text").autocomplete(
url, {
max: 30,
- formatResult: formatTagAutoCompleteResult}
+ multiple: true,
+ multipleSeparator: ',',
+ cacheLength: 1}
);
});
</script>