diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-27 13:54:20 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-27 13:54:20 -0700 |
commit | f21044ae1d4574daa992818afec85045598cd057 (patch) | |
tree | ee190a23582345434638e74755e11102ffc2bfff | |
parent | 1f014aae6c16bbda62d8f5937180f11ccb0eb1b1 (diff) |
Standardize the specification of tags.
With this patch a comma(,) is the only valid tag separator. Spaces
are allowed in tags and phrases no longer need to be specified with a
dot.
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 2 | ||||
-rw-r--r-- | modules/tag/controllers/tags.php | 6 | ||||
-rw-r--r-- | modules/tag/helpers/tag_event.php | 12 |
3 files changed, 10 insertions, 10 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 134edcff..436cef52 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -616,7 +616,7 @@ class g2_import_Core { // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { $tags .= (strlen($tags) ? ", " : "") . - tag::add($g3_item, preg_replace('/\s+/', '.', $tag_name)); + tag::add($g3_item, $tag_name); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index a600ea1a..69178925 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("#[,\s]+# ", $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..7becf36f 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); } @@ -71,16 +71,16 @@ class tag_event_Core { '$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)")) + $tag_value = implode(", ", tag::item_tags($item)); + $view->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(); |