diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-10-21 21:17:46 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-10-21 21:17:46 +0000 |
commit | d5a2cf5e234207e1d9e76b28bdb5c2ffcb5b4e29 (patch) | |
tree | 09031a5a95250f1e7b6b6616b81479d60c3f824a | |
parent | e22eb49fec3e82a49cefc9a90d5a39e4453fa58f (diff) |
code refactoring for function get_cat_display_name
git-svn-id: http://piwigo.org/svn/trunk@569 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/functions_html.inc.php | 46 |
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; } /** |