Changeset 61 for trunk/category.php


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/category.php

    r57 r61  
    232232if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
    233233{
    234   if ( is_numeric( $page['cat'] ) )
    235   {
    236     $cat_directory = $page['cat_dir'];
    237   }
    238   else if ( $page['cat'] == 'search' or $page['cat'] == 'fav' )
    239   {
    240     $array_cat_directories = array();
    241   }
     234  $array_cat_directories = array();
    242235 
    243   $query = 'SELECT id,file,date_available,tn_ext,name,filesize,cat_id';
     236  $query = 'SELECT id,file,date_available,tn_ext,name,filesize';
     237  $query.= ',storage_category_id,category_id';
    244238  $query.= ' FROM '.PREFIX_TABLE.'images';
     239  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    245240  $query.= $page['where'];
    246241  $query.= $conf['order_by'];
    247242  $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
    248243  $query.= ';';
    249   echo $query;
    250244  $result = mysql_query( $query );
    251245
     
    258252  while ( $row = mysql_fetch_array( $result ) )
    259253  {
    260     if ( !is_numeric( $page['cat'] ) )
    261     {
    262       if ( $array_cat_directories[$row['cat_id']] == '' )
    263       {
    264         $cat_result = get_cat_info( $row['cat_id'] );
    265         $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
    266       }
    267       $cat_directory = $array_cat_directories[$row['cat_id']];
    268     }
     254    if ( $array_cat_directories[$row['storage_category_id']] == '' )
     255    {
     256      $array_cat_directories[$row['storage_category_id']] =
     257        get_complete_dir( $row['storage_category_id'] );
     258    }
     259    $cat_directory = $array_cat_directories[$row['storage_category_id']];
     260
    269261    $file = get_filename_wo_extension( $row['file'] );
    270262    // name of the picture
    271     if ( $row['name'] != '' )
    272     {
    273       $name = $row['name'];
    274     }
    275     else
    276     {
    277       $name = str_replace( '_', ' ', $file );
    278     }
     263    if ( $row['name'] != '' ) $name = $row['name'];
     264    else                      $name = str_replace( '_', ' ', $file );
     265
    279266    if ( $page['cat'] == 'search' )
    280267    {
     
    359346  $i = 0;
    360347  foreach ( $subcats as $subcat_id => $non_empty_id ) {
    361     $subcat_infos    = get_cat_info( $subcat_id );
    362     $non_empty_infos = get_cat_info( $non_empty_id );
     348    $subcat_infos  = get_cat_info( $subcat_id );
    363349
    364350    $name ='[ <span style="font-weight:bold;">';
    365351    $name.= $subcat_infos['name'][0];
    366352    $name.= '</span> ]';
    367    
    368     $query = 'SELECT file,tn_ext';
     353
     354    $query = 'SELECT file,tn_ext,storage_category_id';
    369355    $query.= ' FROM '.PREFIX_TABLE.'images';
    370     $query.= ' WHERE cat_id = '.$non_empty_id;
     356    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     357    $query.= ' WHERE category_id = '.$non_empty_id;
    371358    $query.= ' ORDER BY RAND()';
    372359    $query.= ' LIMIT 0,1';
     
    378365
    379366    // creating links for thumbnail and associated category
    380     $thumbnail_link = $non_empty_infos['dir'];
     367    $thumbnail_link = get_complete_dir( $image_row['storage_category_id'] );
    381368    $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
    382369    $thumbnail_link.= $file.'.'.$image_row['tn_ext'];
Note: See TracChangeset for help on using the changeset viewer.