aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_category.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-11-20 17:23:42 +0000
committerplegall <plg@piwigo.org>2004-11-20 17:23:42 +0000
commit13cd251e63232e88069759e8396b0c35b991088b (patch)
treeabf65955235f108908dc95e37678e2404ff87115 /include/functions_category.inc.php
parentf39c3af29b7d44fa11b0670bb8ad6f7e9b7c53d0 (diff)
- optimization : representative picture becomes mandatory for a non empty
category. So, at each insertion in images table for a category, a new representative element is elected (by rand). This must be improved by not reelcting a random picture admin set an element as representative manually. - optimization : recent cats page only needs 2 queries instead of 3*N (N categories to display). The bad point is that it shows representative element of recent cat and not a random element among recently added. - optimization : empty cats page only needs 1 query per non empty sub category instead of... a lot. For each sub category, PhpWebGallery shows the representative element of a category chosen randomly in sub cats. Thus, get_non_empty_subcat_ids and get_first_non_empty_cat_id becomes obsolete. - new function get_cat_display_name_cache to show category names with a caching for all gallery categories names. This function, to the contrary of get_cat_display_name shows names in the correct order... git-svn-id: http://piwigo.org/svn/trunk@610 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_category.inc.php87
1 files changed, 0 insertions, 87 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 330137d6d..d46ddc104 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -828,93 +828,6 @@ SELECT COUNT(1) AS count
pwg_debug( 'end initialize_category' );
}
-// get_non_empty_subcat_ids returns an array with sub-categories id
-// associated with their first non empty category id.
-//
-// example :
-//
-// - catname [cat_id]
-// - cat1 [1] -> given uppercat
-// - cat1.1 [12] (empty)
-// - cat1.1.1 [5] (empty)
-// - cat1.1.2 [6]
-// - cat1.2 [3]
-// - cat1.3 [4]
-//
-// get_non_empty_sub_cat_ids will return :
-// $ids[12] = 6;
-// $ids[3] = 3;
-// $ids[4] = 4;
-function get_non_empty_subcat_ids( $id_uppercat )
-{
- global $user;
-
- $ids = array();
-
- $query = 'SELECT id,nb_images';
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' WHERE id_uppercat ';
- if ( !is_numeric( $id_uppercat ) ) $query.= 'is NULL';
- else $query.= '= '.$id_uppercat;
- // we must not show pictures of a forbidden category
- if ( $user['forbidden_categories'] != '' )
- {
- $query.= ' AND id NOT IN ('.$user['forbidden_categories'].')';
- }
- $query.= ' ORDER BY rank';
- $query.= ';';
-
- $result = pwg_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- // only categories with findable picture in any of its subcats is
- // represented.
- if ( ( $row['nb_images'] != 0 and $non_empty_cat = $row['id'] )
- or $non_empty_cat = get_first_non_empty_cat_id( $row['id'] ) )
- {
- $ids[$row['id']] = $non_empty_cat;
- }
- }
- return $ids;
-}
-
-// get_first_non_empty_cat_id returns the id of the first non empty
-// sub-category to the given uppercat. If no picture is found in any
-// subcategory, false is returned.
-function get_first_non_empty_cat_id( $id_uppercat )
-{
- global $user;
-
- $query = 'SELECT id,nb_images';
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' WHERE id_uppercat = '.$id_uppercat;
- // we must not show pictures of a forbidden category
- if ( $user['forbidden_categories'] != '' )
- {
- $query.= ' AND id NOT IN ('.$user['forbidden_categories'].')';
- }
- $query.= ' ORDER BY RAND()';
- $query.= ';';
- $result = pwg_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- if ( $row['nb_images'] > 0 )
- {
- return $row['id'];
- }
- }
- $result = pwg_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- // recursive call
- if ( $subcat = get_first_non_empty_cat_id( $row['id'] ) )
- {
- return $subcat;
- }
- }
- return false;
-}
-
function display_select_categories($categories,
$indent,
$selecteds,