diff --git a/main.inc.php b/main.inc.php index a8646a4..01631f6 100644 --- a/main.inc.php +++ b/main.inc.php @@ -8,6 +8,13 @@ Author URI: http://piwigo.org */ +// characters to separate group with +global $tag_group_sep; +$tag_group_sep=":/"; +// show tags which have no group in their own group? +global $tag_group_hide_nogroup; +$tag_group_hide_nogroup = true; + if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); $render_tag_names = true; @@ -42,7 +49,9 @@ function tg_clean_tag_name($tag_name) { - return preg_replace('/^[^:]*:/', '', $tag_name); + global $tag_group_sep; + $pattern='/^[^'.preg_quote($tag_group_sep,'/').']*'.preg_quote($tag_group_sep,'/').'/'; + return preg_replace($pattern, '', $tag_name); } // file_get_contents('tags.tpl') @@ -55,6 +64,7 @@ function tg_clean_tag_name($tag_name) function tg_groups_display() { global $conf, $template, $user, $tags, $page; + global $tag_group_sep, $tag_group_hide_nogroup; load_language('plugin.lang', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); @@ -84,15 +94,24 @@ function tg_groups_display() foreach ($tags as $tag) { - // if the tag belongs to no group, we don't show it on the "tag by - // group" display mode - if (strpos($tag['name'], ':') === false) + // any group present? + if (preg_match("/[".preg_quote($tag_group_sep,"/")."]/", $tag['name']) < 1) { - continue; + if ($tag_group_hide_nogroup) + { + // if the tag belongs to no group, we don't show it on the "tag by + // group" display mode + continue; + } + else + { + // no group specified so name = group + $tag['group']=$tag['name']; + } } else { - list($tag['group'], $tag['name']) = explode(':', $tag['name'], 2); + list($tag['group'], $tag['name']) = preg_split("/[".preg_quote($tag_group_sep,"/")."]+/", $tag['name'], 2); $tag['group'] = preg_replace('/^[^=]*=/', '', $tag['group']); } @@ -203,7 +222,7 @@ function tg_index_groups_display() $is_tag_group_selection = true; foreach ($page['tags'] as $tag) { - if (!preg_match('/:/', $tag['name'])) + if (preg_match("/[".preg_quote($tag_group_sep,"/")."]/", $tag['name']) < 1) { $is_tag_group_selection = false; } @@ -255,7 +274,7 @@ function tg_index_groups_display() $tag_groups = array(); foreach ($tags as $id => $tag) { - list($group, $name) = explode(':', $tag['name'], 2); + list($group, $name) = preg_split("/[".preg_quote($tag_group_sep,"/")."]+/", $tag['name'], 2); if (!isset($tag_groups[$group])) { diff --git a/tags.tpl b/tags.tpl index 9d55b27..4920091 100644 --- a/tags.tpl +++ b/tags.tpl @@ -8,7 +8,8 @@
{$tag.name} [{$tag.counter}] | +{$tag.name} | +{$tag.counter|@translate_dec:'%d photo':'%d photos'} |