From 1afee20ed24e9a9d171e9d90ffe0341a5dad7c89 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 9 Oct 2012 19:47:22 +0000 Subject: some code simplification git-svn-id: http://piwigo.org/svn/trunk@18579 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_category.inc.php | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'include/functions_category.inc.php') diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index ec61b5c1a..d93c5be19 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -128,7 +128,7 @@ WHERE '.$where.' { $row['icon_ts'] = get_icon($row['max_date_last'], $child_date_last); } - array_push($cats, $row); + $cats[] = $row; if ($row['id']==@$page['category']['id']) //save the number of subcats for later optim $page['category']['count_categories'] = $row['count_categories']; } @@ -195,7 +195,6 @@ SELECT * } else { - $names = array(); $query = ' SELECT id, name, permalink FROM '.CATEGORIES_TABLE.' @@ -207,7 +206,7 @@ SELECT * $cat['upper_names'] = array(); foreach ($upper_ids as $cat_id) { - array_push( $cat['upper_names'], $names[$cat_id]); + $cat['upper_names'][] = $names[$cat_id]; } } return $cat; @@ -219,13 +218,13 @@ SELECT * function get_category_preferred_image_orders() { global $conf, $page; - + return trigger_event('get_category_preferred_image_orders', array( array(l10n('Default'), '', true), array(l10n('Photo title, A → Z'), 'name ASC', true), array(l10n('Photo title, Z → A'), 'name DESC', true), array(l10n('Date created, new → old'), 'date_creation DESC', true), - array(l10n('Date created, old → new'), 'date_creation ASC', true), + array(l10n('Date created, old → new'), 'date_creation ASC', true), array(l10n('Date posted, new → old'), 'date_available DESC', true), array(l10n('Date posted, old → new'), 'date_available ASC', true), array(l10n('Rating score, high → low'), 'rating_score DESC', $conf['rate']), @@ -246,10 +245,6 @@ function display_select_categories($categories, $tpl_cats = array(); foreach ($categories as $category) { - if (!empty($category['permalink'])) - { - $category['name'] .= ' √'; - } if ($fullname) { $option = strip_tags( @@ -283,15 +278,7 @@ function display_select_categories($categories, function display_select_cat_wrapper($query, $selecteds, $blockname, $fullname = true) { - $result = pwg_query($query); - $categories = array(); - if (!empty($result)) - { - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($categories, $row); - } - } + $categories = array_from_query($query); usort($categories, 'global_rank_compare'); display_select_categories($categories, $selecteds, $blockname, $fullname); } @@ -324,14 +311,7 @@ SELECT DISTINCT(id) } $query.= ' ;'; - $result = pwg_query($query); - - $subcats = array(); - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($subcats, $row['id']); - } - return $subcats; + return array_from_query($query, 'id'); } /** finds a matching category id from a potential list of permalinks -- cgit v1.2.3