aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-10-21 21:17:46 +0000
committerz0rglub <z0rglub@piwigo.org>2004-10-21 21:17:46 +0000
commitd5a2cf5e234207e1d9e76b28bdb5c2ffcb5b4e29 (patch)
tree09031a5a95250f1e7b6b6616b81479d60c3f824a
parente22eb49fec3e82a49cefc9a90d5a39e4453fa58f (diff)
code refactoring for function get_cat_display_name
git-svn-id: http://piwigo.org/svn/trunk@569 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_html.inc.php46
1 files changed, 32 insertions, 14 deletions
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 103bac3f0..6e28dc5de 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -150,24 +150,42 @@ function style_select($default_style, $select_name = "style")
// You can give this parameters :
// - $style : the style of the span tag for the lowest category,
// "font-style:italic;" for example
-function get_cat_display_name( $cat_informations, $separator,
- $url = 'category.php?cat=', $replace_space = true)
+function get_cat_display_name($cat_informations,
+ $separator,
+ $url = 'category.php?cat=',
+ $replace_space = true)
{
$output = '';
- $i=0;
- while ( list ($id, $name) = each($cat_informations))
+ $is_first = true;
+ foreach ($cat_informations as $id => $name)
{
- if ( $i ) $output.= $separator;
- $i++;
- if (empty($style) && empty($url) || ($i == count( $cat_informations)))
- $output.= $name;
- elseif (!empty($url))
- $output.= '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.$url.$id).'">'.$name."</a>";
- else
- $output.= '<span style="'.$style.'">'.$name.'</span>';
+ if ($is_first)
+ {
+ $is_first = false;
+ }
+ else
+ {
+ $output.= $separator;
+ }
+
+ if ($url == '')
+ {
+ $output.= $name;
+ }
+ else
+ {
+ $output.= '
+<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.$url.$id).'">'.$name.'</a>';
+ }
+ }
+ if ($replace_space)
+ {
+ return replace_space($output);
+ }
+ else
+ {
+ return $output;
}
- if ( $replace_space ) return replace_space( $output );
- else return $output;
}
/**