Ignore:
Timestamp:
Aug 30, 2003, 5:54:37 PM (21 years ago)
Author:
z0rglub
Message:

Multi categories for the same picture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_category.inc.php

    r57 r61  
    9595{
    9696  $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat',
    97                   'rank');
     97                  'rank','site_id');
    9898 
    9999  $query = 'SELECT ';
     
    271271// $cat['comment']
    272272// $cat['dir']
    273 // $cat['last_dir']
     273// $cat['dir']
    274274// $cat['name'] is an array :
    275275//      - $cat['name'][0] is the lowest cat name
     
    281281function get_cat_info( $id )
    282282{
     283  global $page;
     284
    283285  $cat = array();
    284   $cat['name'] = array();
    285286               
    286287  $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir';
    287   $query.= ',date_last,uploadable';
     288  $query.= ',date_last,uploadable,status,visible';
    288289  $query.= ' FROM '.PREFIX_TABLE.'categories AS a';
    289290  $query.= ', '.PREFIX_TABLE.'sites AS b';
     
    295296  $cat['comment']     = nl2br( $row['comment'] );
    296297  $cat['nb_images']   = $row['nb_images'];
    297   $cat['last_dir']    = $row['dir'];
     298  $cat['dir']         = $row['dir'];
    298299  $cat['date_last']   = $row['date_last'];
    299300  $cat['uploadable']  = get_boolean( $row['uploadable'] );
    300   $galleries_url = $row['galleries_url'];
    301 
    302   $cat['dir'] = "";
    303   $i = 0;
    304   $is_root = false;
    305   $row['id_uppercat'] = $id;
    306   while ( !$is_root )
    307   {
    308     $query = 'SELECT name,dir,id_uppercat';
    309     $query.= ' FROM '.PREFIX_TABLE.'categories';
    310     $query.= ' WHERE id = '.$row['id_uppercat'].';';
    311     $row = mysql_fetch_array( mysql_query( $query ) );
    312     $cat['dir'] = $row['dir'].'/'.$cat['dir'];
    313     if ( $row['name'] == "" )
    314     {
    315       $cat['name'][$i] = str_replace( "_", " ", $row['dir'] );
    316     }
    317     else
    318     {
    319       $cat['name'][$i] = $row['name'];
    320     }
    321     if ( $row['id_uppercat'] == "" )
    322     {
    323       $is_root = true;
    324     }
    325     $i++;
    326   }
    327   $cat['local_dir'] = substr( $cat['dir'], 0 , strlen( $cat['dir'] ) - 1 );
    328   $cat['dir'] = $galleries_url.$cat['dir'];
    329                
     301  $cat['status']      = $row['status'];
     302  $cat['visible']     = get_boolean( $row['visible'] );
     303
     304  $cat['name'] = array();
     305  array_push( $cat['name'], $page['plain_structure'][$id]['name'] );
     306  while ( $page['plain_structure'][$id]['id_uppercat'] != '' )
     307  {
     308    $id = $page['plain_structure'][$id]['id_uppercat'];
     309    array_push( $cat['name'], $page['plain_structure'][$id]['name'] );
     310  }
    330311  return $cat;
    331312}
    332        
     313
     314// get_complete_dir returns the concatenation of get_site_url and
     315// get_local_dir
     316// Example : "pets > rex > 1_year_old" is on the the same site as the
     317// PhpWebGallery files and this category has 22 for identifier
     318// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/"
     319function get_complete_dir( $category_id )
     320{
     321  return get_site_url( $category_id ).get_local_dir( $category_id );
     322}
     323
     324// get_local_dir returns an array with complete path without the site url
     325// Example : "pets > rex > 1_year_old" is on the the same site as the
     326// PhpWebGallery files and this category has 22 for identifier
     327// get_local_dir(22) returns "pets/rex/1_year_old/"
     328function get_local_dir( $category_id )
     329{
     330  global $page;
     331
     332  // creating the local path : "root_cat/sub_cat/sub_sub_cat/"
     333  $dir = $page['plain_structure'][$category_id]['dir'].'/';
     334  while ( $page['plain_structure'][$category_id]['id_uppercat'] != '' )
     335  {
     336    $category_id = $page['plain_structure'][$category_id]['id_uppercat'];
     337    $dir = $page['plain_structure'][$category_id]['dir'].'/'.$dir;
     338  }
     339  return $dir;
     340}
     341
     342// retrieving the site url : "http://domain.com/gallery/" or
     343// simply "./galleries/"
     344function get_site_url( $category_id )
     345{
     346  global $page;
     347
     348  $query = 'SELECT galleries_url';
     349  $query.= ' FROM '.PREFIX_TABLE.'sites';
     350  $query.= ' WHERE id = '.$page['plain_structure'][$category_id]['site_id'];
     351  $query.= ';';
     352  $row = mysql_fetch_array( mysql_query( $query ) );
     353  return $row['galleries_url'];
     354}
     355
    333356// The function get_cat_display_name returns a string containing the list
    334357// of upper categories to the root category from the lowest category shown
     
    402425      $page['cat_uploadable'] = $result['uploadable'];
    403426      $page['title'] = get_cat_display_name( $page['cat_name'], ' - ', '' );
    404       $page['where'] = ' WHERE cat_id = '.$page['cat'];
     427      $page['where'] = ' WHERE category_id = '.$page['cat'];
    405428    }
    406429    else
     
    412435        $restricted_cats = get_all_restrictions( $user['id'],$user['status'] );
    413436        foreach ( $restricted_cats as $restricted_cat ) {
    414           $where_append.= ' AND cat_id != '.$restricted_cat;
     437          $where_append.= ' AND category_id != '.$restricted_cat;
    415438        }
    416439      }
     
    500523      {
    501524        $page['title'] = $conf['top_number'].' '.$lang['most_visited_cat'];
    502         $page['where'] = ' WHERE cat_id != -1'.$where_append;
     525        $page['where'] = ' WHERE category_id != -1'.$where_append;
    503526        $conf['order_by'] = ' ORDER BY hit DESC, file ASC';
    504527        $page['cat_nb_images'] = $conf['top_number'];
Note: See TracChangeset for help on using the changeset viewer.