From d5a2cf5e234207e1d9e76b28bdb5c2ffcb5b4e29 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Thu, 21 Oct 2004 21:17:46 +0000 Subject: code refactoring for function get_cat_display_name git-svn-id: http://piwigo.org/svn/trunk@569 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_html.inc.php | 46 +++++++++++++++++++++++++++++------------- 1 file 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.= ''.$name.""; - else - $output.= ''.$name.''; + if ($is_first) + { + $is_first = false; + } + else + { + $output.= $separator; + } + + if ($url == '') + { + $output.= $name; + } + else + { + $output.= ' +'.$name.''; + } + } + if ($replace_space) + { + return replace_space($output); + } + else + { + return $output; } - if ( $replace_space ) return replace_space( $output ); - else return $output; } /** -- cgit v1.2.3