Ignore:
Timestamp:
Jan 3, 2004, 10:20:53 PM (21 years ago)
Author:
z0rglub
Message:
  • use function get_user_plain_structure, create_user_structure
  • using categories.uppercats instead of the calculated structure
  • improving queries to retrieve pictures to display
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/category.php

    r193 r252  
    3535}
    3636//-------------------------------------------------- access authorization check
    37 // creating the plain structure : array of all the available categories and
    38 // their relative informations, see the definition of the function
    39 // get_plain_structure for further details.
    40 $page['plain_structure'] = get_plain_structure();
    41 
    4237check_cat_id( $_GET['cat'] );
    4338check_login_authorization();
     
    4742}
    4843//-------------------------------------------------------------- initialization
     44// detection of the start picture to display
     45if ( !isset( $_GET['start'] )
     46     or !is_numeric( $_GET['start'] )
     47     or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
     48  $page['start'] = 0;
     49else
     50  $page['start'] = $_GET['start'];
     51
     52initialize_category();
     53
    4954// creation of the array containing the cat ids to expand in the menu
    5055// $page['tab_expand'] contains an array with the category ids
     
    5762    if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id );
    5863  }
    59   if ( is_numeric( $page['cat'] ) )
    60   {
    61     // the category displayed (in the URL cat=23) must be seen in the menu ->
    62     // parent categories must be expanded
    63     $parent = $page['plain_structure'][$page['cat']]['id_uppercat'];
    64     while ( $parent != '' )
    65     {
    66       array_push( $page['tab_expand'], $parent );
    67       $parent = $page['plain_structure'][$parent]['id_uppercat'];
    68     }
    69   }
    70   $page['expand'] = implode( ',', $page['tab_expand'] );
    71 }
     64}
     65if ( is_numeric( $page['cat'] ) )
     66{
     67  // the category displayed (in the URL cat=23) must be seen in the menu ->
     68  // parent categories must be expanded
     69  $uppercats = explode( ',', $page['uppercats'] );
     70  foreach ( $uppercats as $uppercat ) {
     71    array_push( $page['tab_expand'], $uppercat );
     72  }
     73}
     74$page['tab_expand'] = array_unique( $page['tab_expand'] );
     75$page['expand'] = implode( ',', $page['tab_expand'] );
    7276// in case of expanding all authorized cats
    7377// The $page['expand'] equals 'all' and
     
    7781  $page['tab_expand'] = array();
    7882  $page['expand'] = 'all';
    79 }
    80 // detection of the start picture to display
    81 if ( !isset( $_GET['start'] )
    82      or !is_numeric( $_GET['start'] )
    83      or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
    84 {
    85   $page['start'] = 0;
    86 }
    87 else
    88 {
    89   $page['start'] = $_GET['start'];
    9083}
    9184// Sometimes, a "num" is provided in the URL. It is the number
     
    9992}
    10093// creating the structure of the categories (useful for displaying the menu)
    101 $page['structure'] = create_structure( '', $user['restrictions'] );
     94// creating the plain structure : array of all the available categories and
     95// their relative informations, see the definition of the function
     96// get_user_plain_structure for further details.
     97$page['plain_structure'] = get_user_plain_structure();
     98$page['structure'] = create_user_structure( '' );
    10299$page['structure'] = update_structure( $page['structure'] );
    103 initialize_category();
    104100//----------------------------------------------------- template initialization
    105101$vtp = new VTemplate;
     
    128124$icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) );
    129125$vtp->setGlobalVar( $handle, 'icon_long', $icon_long );
    130 $nb_total_pictures = count_images( $page['structure'] );
     126$nb_total_pictures = count_user_total_images();
    131127$vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures );
     128
    132129//------------------------------------------------------------- categories menu
    133130// normal categories
     
    255252  $query.= ',storage_category_id';
    256253  $query.= ' FROM '.PREFIX_TABLE.'images AS i';
    257   $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
     254  $query.=' INNER JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
    258255  $query.= $page['where'];
    259256  $query.= $conf['order_by'];
     
    351348elseif ( ( isset( $page['cat'] )
    352349           and is_numeric( $page['cat'] )
    353            and $page['cat_nb_images'] == 0 )
     350           and $page['cat_nb_images'] == 0
     351           and $page['plain_structure'][$page['cat']]['nb_sub_categories'] > 0)
    354352         or $_GET['cat'] == '' )
    355353{
     
    371369    $query.= ' FROM '.PREFIX_TABLE.'categories';
    372370    $query.= ' WHERE id = '.$non_empty_id;
     371    $query.= ';';
    373372    $row = mysql_fetch_array( mysql_query( $query ) );
    374373   
    375374    $query = 'SELECT file,tn_ext,storage_category_id';
    376     $query.= ' FROM '.PREFIX_TABLE.'images';
    377     $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     375    $query.= ' FROM '.PREFIX_TABLE.'images, '.PREFIX_TABLE.'image_category';
    378376    $query.= ' WHERE category_id = '.$non_empty_id;
     377    $query.= ' AND id = image_id';
    379378    // if the category has a representative picture, this is its thumbnail
    380379    // tha will be displayed !
Note: See TracChangeset for help on using the changeset viewer.