diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-20 16:55:09 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-20 16:55:09 -0700 |
commit | 8383ea9827048bab9b166a5df24d1384c676d9cb (patch) | |
tree | 77f04c500b47133d30c15b5c4ca411e6ba653df1 | |
parent | ef7f1d07b246c0d58fd5322cfcdd8fb0cfbee2f3 (diff) |
Keywords in G2 are free form. So we don't know what our user used as a separator. Try to
be smart about it. If we see a comma or a semicolon, expect the keywords to be separated
by that delimeter. Otherwise, use space as the delimiter.
Fixes ticket #446
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 4cac8304..2eee564a 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -582,7 +582,18 @@ class g2_import_Core { return; } - foreach (preg_split("/[,;]/", $keywords) as $keyword) { + // Keywords in G2 are free form. So we don't know what our user used as a separator. Try to + // be smart about it. If we see a comma or a semicolon, expect the keywords to be separated + // by that delimeter. Otherwise, use space as the delimiter. + if (strpos($keywords, ";")) { + $delim = ";"; + } else if (strpos($keywords, ",")) { + $delim = ","; + } else { + $delim = " "; + } + + foreach (preg_split("/$delim/", $keywords) as $keyword) { $keyword = trim($keyword); if ($keyword) { tag::add($item, $keyword); |