From 47512ce6a64fa356214c162a8313480c6aed41d2 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 27 Feb 2007 01:56:16 +0000 Subject: - refactoring page['category'] before 1.7 release page['category'] is not an id anymore, but an associative array of category info all of page['cat_xxx'] or page['uppercats'] merged into one simplifies calls to make_index_url give plugins a clean start for page variables for version 1.7 git-svn-id: http://piwigo.org/svn/trunk@1861 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_html.inc.php | 59 +++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 33 deletions(-) (limited to 'include/functions_html.inc.php') diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 60f26a45a..dcb42cdb1 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -235,7 +235,7 @@ function create_navigation_bar( * * categories string returned contains categories as given in the input * array $cat_informations. $cat_informations array must be an association - * of {category_id => category_name}. If url input parameter is null, + * of {category_id => array( id, name) }. If url input parameter is null, * returns only the categories name without links. * * @param array cat_informations @@ -251,8 +251,11 @@ function get_cat_display_name($cat_informations, $output = ''; $is_first = true; - foreach ($cat_informations as $id => $name) + foreach ($cat_informations as $id => $cat) { + is_array($cat) or trigger_error( + 'get_cat_display_name wrong type for cat '.$id, E_USER_WARNING + ); if ($is_first) { $is_first = false; @@ -264,24 +267,23 @@ function get_cat_display_name($cat_informations, if ( !isset($url) ) { - $output.= $name; + $output.= $cat['name']; } elseif ($url == '') { $output.= ''; - $output.= $name.''; + $output.= $cat['name'].''; } else { $output.= ''; - $output.= $name.''; + $output.= $cat['name'].''; } } if ($replace_space) @@ -311,18 +313,18 @@ function get_cat_display_name_cache($uppercats, $url = '', $replace_space = true) { - global $cat_names, $conf; + global $cache, $conf; - if (!isset($cat_names)) + if (!isset($cache['cat_names'])) { $query = ' -SELECT id,name +SELECT id, name FROM '.CATEGORIES_TABLE.' ;'; $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) + while ($row = mysql_fetch_assoc($result)) { - $cat_names[$row['id']] = $row['name']; + $cache['cat_names'][$row['id']] = $row; } } @@ -330,7 +332,7 @@ SELECT id,name $is_first = true; foreach (explode(',', $uppercats) as $category_id) { - $name = $cat_names[$category_id]; + $cat = $cache['cat_names'][$category_id]; if ($is_first) { @@ -343,7 +345,7 @@ SELECT id,name if ( !isset($url) ) { - $output.= $name; + $output.= $cat['name']; } elseif ($url == '') { @@ -351,16 +353,15 @@ SELECT id,name '.$name.''; + .'">'.$cat['name'].''; } else { $output.= ' -'.$name.''; +'.$cat['name'].''; } } if ($replace_space) @@ -384,21 +385,14 @@ SELECT id,name * @param array categories * @return string */ -function get_html_menu_category($categories) +function get_html_menu_category($categories, $selected_category) { - global $page, $lang; + global $lang; $ref_level = 0; $level = 0; $menu = ''; - // $page_cat value remains 0 for special sections - $page_cat = 0; - if (isset($page['category'])) - { - $page_cat = $page['category']; - } - foreach ($categories as $category) { $level = substr_count($category['global_rank'], '.') + 1; @@ -419,7 +413,7 @@ function get_html_menu_category($categories) $ref_level = $level; $menu.= "\n\n".'$category['id'], - 'cat_name'=>$category['name'] + 'category' => $category ) ); $menu.= "\n".'