Changeset 61


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

Multi categories for the same picture

Location:
trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/admin.php

    r57 r61  
    132132   $page_valide = true;
    133133   break;
     134 case 'picture_modify' :
     135   $title = $lang['title_picmod'];
     136   $page_valide = true;
     137   break;
    134138 default:
    135139   $title = $lang['title_default']; break;
  • trunk/admin/comments.php

    r57 r61  
    1818 ***************************************************************************/
    1919include_once( './include/isadmin.inc.php' );
     20$page['plain_structure'] = get_plain_structure();
    2021//------------------------------------------------------------------- functions
    2122function display_pictures( $mysql_result, $maxtime, $validation_box = false )
     
    2930    // 2. for each picture, getting informations for displaying thumbnail and
    3031    //    link to the full size picture
    31     $query = 'SELECT name,file,cat_id,tn_ext';
     32    $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext';
    3233    $query.= ' FROM '.PREFIX_TABLE.'images';
    3334    $query.= ' WHERE id = '.$row['image_id'];
     
    3839    if ( $array_cat_directories[$subrow['cat_id']] == '' )
    3940    {
     41      $array_cat_directories[$subrow['cat_id']] =
     42        get_complete_dir( $subrow['cat_id'] );
    4043      $cat_result = get_cat_info( $subrow['cat_id'] );
    41       $array_cat_directories[$subrow['cat_id']] = $cat_result['dir'];
    4244      $array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id'];
    4345      $array_cat_names[$subrow['cat_id']] =
     
    8486      $vtp->addSession( $sub, 'comment' );
    8587      $vtp->setVar( $sub, 'comment.author', $subrow['author'] );
    86       $displayed_date = $lang['day'][date( "w", $subrow['date'] )];
    87       $displayed_date.= date( " j ", $subrow['date'] );
    88       $displayed_date.= $lang['month'][date( "n", $subrow['date'] )];
    89       $displayed_date.= date( " Y G:i", $subrow['date'] );
     88      $displayed_date = format_date( $subrow['date'], 'unix', true );
    9089      $vtp->setVar( $sub, 'comment.date', $displayed_date );
    9190      $vtp->setVar( $sub, 'comment.content', nl2br( $subrow['content'] ) );
     
    184183  $query.= ' FROM '.PREFIX_TABLE.'comments';
    185184  $query.=     ', '.PREFIX_TABLE.'images as images';
    186   $query.=     ', '.PREFIX_TABLE.'categories';
    187185  $query.= ' WHERE image_id = images.id';
    188   $query.= ' AND   cat_id = images.cat_id';
    189186  $query.= ' AND date > '.$maxtime;
    190   $query.= ' ORDER BY cat_id ASC,date_available DESC';
     187  $query.= ' ORDER BY date_available DESC';
    191188  $query.= ';';
    192189  $result = mysql_query( $query );
     
    222219  $query.= ' FROM '.PREFIX_TABLE.'comments as comments';
    223220  $query.=     ', '.PREFIX_TABLE.'images as images';
    224   $query.=     ', '.PREFIX_TABLE.'categories';
    225221  $query.= ' WHERE image_id = images.id';
    226   $query.= ' AND   cat_id = images.cat_id';
    227222  $query.= " AND comments.validated = 'false'";
    228   $query.= ' ORDER BY cat_id ASC,date_available DESC';
     223  $query.= ' ORDER BY date_available DESC';
    229224  $query.= ';';
    230225  $result = mysql_query( $query );
  • trunk/admin/configuration.php

    r57 r61  
    260260
    261261$tpl = array( 'conf_confirmation','remote_site','delete',
    262               'conf_remote_site_delete_info','submit' );
     262              'conf_remote_site_delete_info','submit','errors_title' );
    263263templatize_array( $tpl, 'lang', $sub );
    264264//-------------------------------------------------------------- errors display
  • trunk/admin/include/functions.php

    r57 r61  
    9595// It also deletes (in the database) :
    9696//    - all the images of the images (thanks to delete_image, see further)
     97//    - all the links between images and this category
    9798//    - all the restrictions linked to the category
    9899// The function works recursively.
     
    102103  $query = 'SELECT id';
    103104  $query.= ' FROM '.PREFIX_TABLE.'images';
    104   $query.= ' WHERE cat_id = '.$id;
     105  $query.= ' WHERE storage_category_id = '.$id;
    105106  $query.= ';';
    106107  $result = mysql_query( $query );
     
    109110    delete_image( $row['id'] );
    110111  }
     112
     113  // destruction of the links between images and this category
     114  $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
     115  $query.= ' WHERE category_id = '.$id;
     116  $query.= ';';
     117  mysql_query( $query );
    111118
    112119  // destruction of the access linked to the category
     
    141148// It also deletes (in the database) :
    142149//    - all the comments related to the image
     150//    - all the links between categories and this image
    143151//    - all the favorites associated to the image
    144152function delete_image( $id )
     
    151159  $query.= ';';
    152160  mysql_query( $query );
    153                
     161
     162  // destruction of the links between images and this category
     163  $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
     164  $query.= ' WHERE image_id = '.$id;
     165  $query.= ';';
     166  mysql_query( $query );
     167
    154168  // destruction of the favorites associated with the picture
    155169  $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
     
    245259  // retrieving all the favorites for this user and comparing their
    246260  // categories to the restricted categories
    247   $query = 'SELECT image_id, cat_id';
    248   $query.= ' FROM '.PREFIX_TABLE.'favorites, '.PREFIX_TABLE.'images';
     261  $query = 'SELECT image_id';
     262  $query.= ' FROM '.PREFIX_TABLE.'favorites';
    249263  $query.= ' WHERE user_id = '.$user_id;
    250   $query.= ' AND id = image_id';
    251264  $query.= ';';
    252265  $result = mysql_query ( $query );
    253266  while ( $row = mysql_fetch_array( $result ) )
    254267  {
    255     if ( in_array( $row['cat_id'], $restricted_cat ) )
     268    // for each picture, we have to check all the categories it belongs
     269    // to. Indeed if a picture belongs to category_1 and category_2 and that
     270    // category_2 is not restricted to the user, he can have the picture as
     271    // favorite.
     272    $query = 'SELECT DISTINCT(category_id) as category_id';
     273    $query.= ' FROM '.PREFIX_TABLE.'image_category';
     274    $query.= ' WHERE image_id = '.$row['image_id'];
     275    $query.= ';';
     276    $picture_result = mysql_query( $query );
     277    $picture_cat = array();
     278    while ( $picture_row = mysql_fetch_array( $picture_result ) )
     279    {
     280      array_push( $picture_cat, $picture_row['category_id'] );
     281    }
     282    if ( count( array_diff( $picture_cat, $restricted_cat ) ) > 0 )
    256283    {
    257284      $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
     
    263290  }
    264291}
     292
     293// update_category updates calculated informations about a category :
     294// date_last and nb_images
     295function update_category( $id = 'all' )
     296{
     297  if ( $id == 'all' )
     298  {
     299    $query = 'SELECT id';
     300    $query.= ' FROM '.PREFIX_TABLE.'categories';
     301    $query.= ';';
     302    $result = mysql_query( $query );
     303    while ( $row = mysql_fetch_array( $result ) )
     304    {
     305      // recursive call
     306      update_category( $row['id'] );
     307    }
     308  }
     309  else if ( is_numeric( $id ) )
     310  {
     311    // updating the number of pictures
     312    $query = 'SELECT COUNT(*) as nb_images';
     313    $query.= ' FROM '.PREFIX_TABLE.'image_category';
     314    $query.= ' WHERE category_id = '.$id;
     315    $query.= ';';
     316    $row = mysql_fetch_array( mysql_query( $query ) );
     317    $query = 'UPDATE '.PREFIX_TABLE.'categories';
     318    $query.= ' SET nb_images = '.$row['nb_images'];
     319    $query.= ' WHERE id = '.$id;
     320    $query.= ';';
     321    mysql_query( $query );
     322    // updating the date_last
     323    $query = 'SELECT date_available';
     324    $query.= ' FROM '.PREFIX_TABLE.'images';
     325    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     326    $query.= ' WHERE category_id = '.$id;
     327    $query.= ' ORDER BY date_available DESC';
     328    $query.= ' LIMIT 0,1';
     329    $query.= ';';
     330    $row = mysql_fetch_array( mysql_query( $query ) );
     331    $query = 'UPDATE '.PREFIX_TABLE.'categories';
     332    $query.= " SET date_last = '".$row['date_available']."'";
     333    $query.= ' WHERE id = '.$id;
     334    $query.= ';';
     335    mysql_query( $query );
     336  }
     337}
     338
     339function check_date_format( $date )
     340{
     341  // date arrives at this format : DD/MM/YYYY
     342  list($day,$month,$year) = explode( '/', $date );
     343  return checkdate ( $month, $day, $year );
     344}
     345
     346function date_convert( $date )
     347{
     348  // date arrives at this format : DD/MM/YYYY
     349  // It must be transformed in YYYY-MM-DD
     350  list($day,$month,$year) = explode( '/', $date );
     351  return $year.'-'.$month.'-'.$day;
     352}
     353
     354function date_convert_back( $date )
     355{
     356  // date arrives at this format : YYYY-MM-DD
     357  // It must be transformed in DD/MM/YYYY
     358  if ( $date != '' )
     359  {
     360    list($year,$month,$day) = explode( '-', $date );
     361    return $day.'/'.$month.'/'.$year;
     362  }
     363  else
     364  {
     365    return '';
     366  }
     367}
     368
     369// get_keywords returns an array with relevant keywords found in the string
     370// given in argument. Keywords must be separated by comma in this string.
     371// keywords must :
     372//   - be longer or equal to 3 characters
     373//   - not contain ', " or blank characters
     374//   - unique in the string ("test,test" -> "test")
     375function get_keywords( $keywords_string )
     376{
     377  $keywords = array();
     378
     379  $candidates = explode( ',', $keywords_string );
     380  foreach ( $candidates as $candidate ) {
     381    if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
     382      array_push( $keywords, $candidate );
     383  }
     384
     385  return array_unique( $keywords );
     386}
     387
     388function display_categories( $categories, $indent )
     389{
     390  global $vtp,$sub;
     391
     392  foreach ( $categories as $category ) {
     393    $vtp->addSession( $sub, 'associate_cat' );
     394    $vtp->setVar( $sub, 'associate_cat.value',   $category['id'] );
     395    $content = $indent.'- '.$category['name'];
     396    $vtp->setVar( $sub, 'associate_cat.content', $content );
     397    $vtp->closeSession( $sub, 'associate_cat' );
     398    display_categories( $category['subcats'], $indent.str_repeat(' ',3) );
     399  }
     400}
    265401?>
  • trunk/admin/infos_images.php

    r57 r61  
    2020include_once( './include/isadmin.inc.php' );
    2121include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' );
    22 //------------------------------------------------------------------- functions
    23 function check_date_format( $date )
    24 {
    25   // date arrives at this format : DD/MM/YYYY
    26   list($day,$month,$year) = explode( '/', $date );
    27   return checkdate ( $month, $day, $year );
    28 }
    29 
    30 function date_convert( $date )
    31 {
    32   // date arrives at this format : DD/MM/YYYY
    33   // It must be transformed in YYYY-MM-DD
    34   list($day,$month,$year) = explode( '/', $date );
    35   return $year.'-'.$month.'-'.$day;
    36 }
    37 
    38 function date_convert_back( $date )
    39 {
    40   // date arrives at this format : YYYY-MM-DD
    41   // It must be transformed in DD/MM/YYYY
    42   if ( $date != '' )
    43   {
    44     list($year,$month,$day) = explode( '-', $date );
    45     return $day.'/'.$month.'/'.$year;
    46   }
    47   else
    48   {
    49     return '';
    50   }
    51 }
    52 
    53 // get_keywords returns an array with relevant keywords found in the string
    54 // given in argument. Keywords must be separated by comma in this string.
    55 // keywords must :
    56 //   - be longer or equal to 3 characters
    57 //   - not contain ', " or blank characters
    58 //   - unique in the string ("test,test" -> "test")
    59 function get_keywords( $keywords_string )
    60 {
    61   $keywords = array();
    62 
    63   $candidates = explode( ',', $keywords_string );
    64   foreach ( $candidates as $candidate ) {
    65     if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
    66       array_push( $keywords, $candidate );
    67   }
    68 
    69   return array_unique( $keywords );
    70 }
    7122//-------------------------------------------------------------- initialization
    7223check_cat_id( $_GET['cat_id'] );
    73 
    7424if ( isset( $page['cat'] ) )
    7525{
     
    7727  $query = 'SELECT id,file';
    7828  $query.= ' FROM '.PREFIX_TABLE.'images';
    79   $query.= ' WHERE cat_id = '.$page['cat'];
     29  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     30  $query.= ' WHERE category_id = '.$page['cat'];
    8031  $query.= ';';
    8132  $result = mysql_query( $query );
     
    12273      else
    12374      {
    124         $query.= '"';
     75        $query.= "'";
    12576        foreach ( $keywords_array as $i => $keyword ) {
    12677          if ( $i > 0 ) $query.= ',';
    12778          $query.= $keyword;
    12879        }
    129         $query.= '"';
     80        $query.= "'";
    13081      }
    13182
     
    13485      mysql_query( $query );
    13586    }
    136   }
     87    // add link to another category
     88    if ( $_POST['check-'.$row['id']] == 1 )
     89    {
     90      $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     91      $query.= ' (image_id,category_id) VALUES';
     92      $query.= ' ('.$row['id'].','.$_POST['associate'].')';
     93      $query.= ';';
     94      mysql_query( $query );
     95    }
     96  }
     97  update_category( $_POST['associate'] );
    13798//------------------------------------------------------ update general options
    13899  if ( $_POST['use_common_author'] == 1 )
    139100  {
    140     $query = 'UPDATE '.PREFIX_TABLE.'images';
    141     if ( $_POST['author_cat'] == '' )
    142     {
    143       $query.= ' SET author = NULL';
    144     }
    145     else
    146     {
    147       $query.= ' SET author = ';
    148       $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
    149     }
    150     $query.= ' WHERE cat_id = '.$page['cat'];
    151     $query.= ';';
    152     mysql_query( $query );
     101    $query = 'SELECT image_id';
     102    $query.= ' FROM '.PREFIX_TABLE.'image_category';
     103    $query.= ' WHERE category_id = '.$page['cat'];
     104    $result = mysql_query( $query );
     105    while ( $row = mysql_fetch_array( $result ) )
     106    {
     107      $query = 'UPDATE '.PREFIX_TABLE.'images';
     108      if ( $_POST['author_cat'] == '' )
     109      {
     110        $query.= ' SET author = NULL';
     111      }
     112      else
     113      {
     114        $query.= ' SET author = ';
     115        $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
     116      }
     117      $query.= ' WHERE id = '.$row['image_id'];
     118      $query.= ';';
     119      mysql_query( $query );
     120    }
    153121  }
    154122  if ( $_POST['use_common_date_creation'] == 1 )
     
    157125    {
    158126      $date = date_convert( $_POST['date_creation_cat'] );
    159       $query = 'UPDATE '.PREFIX_TABLE.'images';
    160       if ( $_POST['date_creation_cat'] == '' )
    161       {
    162         $query.= ' SET date_creation = NULL';
    163       }
    164       else
    165       {
    166         $query.= " SET date_creation = '".$date."'";
    167       }
    168       $query.= ' WHERE cat_id = '.$page['cat'];
    169       $query.= ';';
    170       mysql_query( $query );
     127      $query = 'SELECT image_id';
     128      $query.= ' FROM '.PREFIX_TABLE.'image_category';
     129      $query.= ' WHERE category_id = '.$page['cat'];
     130      $result = mysql_query( $query );
     131      while ( $row = mysql_fetch_array( $result ) )
     132      {
     133        $query = 'UPDATE '.PREFIX_TABLE.'images';
     134        if ( $_POST['date_creation_cat'] == '' )
     135        {
     136          $query.= ' SET date_creation = NULL';
     137        }
     138        else
     139        {
     140          $query.= " SET date_creation = '".$date."'";
     141        }
     142        $query.= ' WHERE id = '.$row['image_id'];
     143        $query.= ';';
     144        mysql_query( $query );
     145      }
    171146    }
    172147    else
     
    179154    $query = 'SELECT id,keywords';
    180155    $query.= ' FROM '.PREFIX_TABLE.'images';
    181     $query.= ' WHERE cat_id = '.$page['cat'];
     156    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     157    $query.= ' WHERE category_id = '.$page['cat'];
    182158    $query.= ';';
    183159    $result = mysql_query( $query );
     
    242218  }
    243219  // retrieving category information
     220  $page['plain_structure'] = get_plain_structure();
    244221  $result = get_cat_info( $page['cat'] );
    245   $cat['local_dir'] = $result['local_dir'];
    246   $cat['dir'] = $result['dir'];
    247222  $cat['name'] = $result['name'];
    248   $cat['site_id'] = $result['site_id'];
    249223  $cat['nb_images'] = $result['nb_images'];
    250224//----------------------------------------------------- template initialization
     
    255229                'infoimage_creation_date','keywords',
    256230                'infoimage_addtoall','infoimage_removefromall',
    257                 'infoimage_keyword_separation' );
     231                'infoimage_keyword_separation','infoimage_associate' );
    258232  templatize_array( $tpl, 'lang', $sub );
     233  $vtp->setGlobalVar( $sub, 'user_template',   $user['template'] );
    259234//------------------------------------------------------------------------ form
    260235  $url = './admin.php?page=infos_images&cat_id='.$page['cat'];
     
    267242  $vtp->setVar( $sub, 'cat_name', $cat_name );
    268243
     244  $array_cat_directories = array();
     245
    269246  $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords';
     247  $query.= ',storage_category_id,category_id';
    270248  $query.= ' FROM '.PREFIX_TABLE.'images';
    271   $query.= ' WHERE cat_id = '.$page['cat'];
     249  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
     250  $query.= ' WHERE category_id = '.$page['cat'];
    272251  $query.= $conf['order_by'];
    273252  $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
     
    288267    $vtp->setVar( $sub, 'picture.default_name', $file );
    289268    // creating url to thumbnail
    290     if ( $cat['site_id'] == 1 )
    291     {
    292       $thumbnail_url = '../galleries/'.$cat['local_dir'].'/';
    293     }
    294     else
    295     {
    296       $thumbnail_url = $cat['dir'];
     269    if ( $array_cat_directories[$row['storage_category_id']] == '' )
     270    {
     271      $array_cat_directories[$row['storage_category_id']] =
     272        get_complete_dir( $row['storage_category_id'] );
     273    }
     274    $thumbnail_url = $array_cat_directories[$row['storage_category_id']];
     275    if ( preg_match( '/^\.\/galleries/', $thumbnail_url ) )
     276    {
     277      $thumbnail_url = '.'.$thumbnail_url;
    297278    }
    298279    $thumbnail_url.= 'thumbnail/';
     
    303284    $vtp->closeSession( $sub, 'picture' );
    304285  }
     286  $structure = create_structure( '', array() );
     287  display_categories( $structure, ' ' );
    305288}
    306289//----------------------------------------------------------- sending html code
  • trunk/admin/update.php

    r57 r61  
    3131  if ( is_numeric( $cat_id ) )
    3232  {
     33    $cat_directory.= '/'.get_local_dir( $cat_id );
    3334    $result = get_cat_info( $cat_id );
    34     $cat_directory.= '/'.$result['local_dir'];
    3535    // 1. display the category name to update
    3636    $src = '../template/'.$user['template'].'/admin/images/puce.gif';
    3737    $output = '<img src="'.$src.'" alt="&gt;" />';
    3838    $output.= '<span style="font-weight:bold;">'.$result['name'][0].'</span>';
    39     $output.= ' [ '.$result['last_dir'].' ]';
     39    $output.= ' [ '.$result['dir'].' ]';
    4040    $output.= '<div class="retrait">';
    41                        
     41
    4242    // 2. we search pictures of the category only if the update is for all
    4343    //    or a cat_id is specified
     
    4545    {
    4646      $output.= insert_local_image( $cat_directory, $cat_id );
    47       update_cat_info( $cat_id );
    48     }
    49   }
    50                
     47      update_category( $cat_id );
     48    }
     49  }
     50
    5151  // 3. we have to remove the categories of the database not present anymore
    5252  $query = 'SELECT id';
     
    6666  {
    6767    // retrieving the directory
    68     $rep = '../galleries';
    69     $resultat = get_cat_info( $row['id'] );
    70     $rep.= '/'.$resultat['local_dir'];
    71                        
     68    $rep = '../galleries/'.get_local_dir( $row['id'] );
    7269    // is the directory present ?
    73     if ( !is_dir( $rep ) )
    74     {
    75       delete_category( $row['id'] );
    76     }
    77   }
    78                
     70    if ( !is_dir( $rep ) ) delete_category( $row['id'] );
     71  }
    7972  // 4. retrieving the sub-directories
    8073  $sub_rep = array();
     
    9487    }
    9588  }
    96                
    9789  for ( $i = 0; $i < sizeof( $sub_rep ); $i++ )
    9890  {
     
    120112      $query.= ' (dir,site_id,id_uppercat) VALUES';
    121113      $query.= " ('".$sub_rep[$i]."','".$site_id."'";
    122       if ( !is_numeric( $cat_id ) )
    123       {
    124         $query.= ',NULL';
    125       }
    126       else
    127       {
    128         $query.= ",'".$cat_id."'";
    129       }
     114      if ( !is_numeric( $cat_id ) ) $query.= ',NULL';
     115      else                          $query.= ",'".$cat_id."'";
    130116      $query.= ');';
    131117      mysql_query( $query );
     
    159145  $query = 'SELECT id,file,tn_ext';
    160146  $query.= ' FROM '.PREFIX_TABLE.'images';
    161   $query.= ' WHERE cat_id = '.$category_id;
     147  $query.= ' WHERE storage_category_id = '.$category_id;
    162148  $query.= ';';
    163149  $result = mysql_query( $query );
     
    200186        $query = 'SELECT id,validated,infos';
    201187        $query.= ' FROM '.PREFIX_TABLE.'waiting';
    202         $query.= ' WHERE cat_id = '.$category_id;
     188        $query.= ' WHERE category_id = '.$category_id;
    203189        $query.= " AND file = '".$file."'";
    204190        $query.= ';';
     
    212198            $query = 'SELECT id';
    213199            $query.= ' FROM '.PREFIX_TABLE.'images';
    214             $query.= ' WHERE cat_id = '.$category_id;
     200            $query.= ' WHERE storage_category_id = '.$category_id;
    215201            $query.= " AND file = '".$file."'";
    216202            $query.= ';';
     
    267253  foreach ( $pictures as $picture ) {
    268254    $query = 'INSERT INTO '.PREFIX_TABLE.'images';
    269     $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height';
     255    $query.= ' (file,storage_category_id,date_available,tn_ext';
     256    $query.= ',filesize,width,height';
    270257    $query.= ',name,author,comment,date_creation)';
    271258    $query.= ' VALUES ';
     
    286273    mysql_query( $query );
    287274    $count_new++;
    288    
     275    // retrieving the id of newly inserted picture
     276    $query = 'SELECT id';
     277    $query.= ' FROM '.PREFIX_TABLE.'images';
     278    $query.= ' WHERE storage_category_id = '.$category_id;
     279    $query.= " AND file = '".$picture['file']."'";
     280    $query.= ';';
     281    list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
     282    // adding the link between this picture and its storage category
     283    $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     284    $query.= ' (image_id,category_id) VALUES ';
     285    $query.= ' ('.$image_id.','.$category_id.')';
     286    $query.= ';';
     287    mysql_query( $query );
     288
    289289    $output.= $picture['file'];
    290290    $output.= ' <span style="font-weight:bold;">';
     
    295295  return $output;
    296296}
    297        
    298 // The function "update_cat_info" updates the information about the last
    299 // online image and the number of images in the category
    300 function update_cat_info( $category_id )
    301 {
    302   $query = 'SELECT date_available';
    303   $query.= ' FROM '.PREFIX_TABLE.'images';
    304   $query.= ' WHERE cat_id = '.$category_id;
    305   $query.= ' ORDER BY date_available DESC';
    306   $query.= ' LIMIT 0,1';
    307   $query.= ';';
    308   $result = mysql_query( $query );
    309   $row = mysql_fetch_array( $result );
    310   $date_last = $row['date_available'];
    311                
    312   $query = 'SELECT COUNT(*) as nb_images';
    313   $query.= ' FROM '.PREFIX_TABLE.'images';
    314   $query.= ' WHERE cat_id = '.$category_id;
    315   $result = mysql_query( $query );
    316   $row = mysql_fetch_array( $result );
    317   $nb_images = $row['nb_images'];
    318                
    319   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    320   $query.= " SET date_last = '".$date_last."'";
    321   $query.= ', nb_images = '.$nb_images;
    322   $query.= ' where id = '.$category_id;
    323   $query.= ';';
    324   mysql_query( $query );
    325 }
    326297
    327298// remote_images verifies if a file named "listing.xml" is present is the
     
    342313
    343314  // 2. is the site already existing ?
    344   $query = 'select id';
    345   $query.= ' from '.PREFIX_TABLE.'sites';
    346   $query.= " where galleries_url = '".$url."'";
     315  $query = 'SELECT id';
     316  $query.= ' FROM '.PREFIX_TABLE.'sites';
     317  $query.= " WHERE galleries_url = '".$url."'";
    347318  $query.= ';';
    348319  $result = mysql_query( $query );
     
    350321  {
    351322    // we have to register this site in the database
    352     $query = 'insert into '.PREFIX_TABLE.'sites';
    353     $query.= " (galleries_url) values ('".$url."')";
     323    $query = 'INSERT INTO '.PREFIX_TABLE.'sites';
     324    $query.= " (galleries_url) VALUES ('".$url."')";
    354325    $query.= ';';
    355326    mysql_query( $query );
     
    391362    $output.= '<div class="retrait">';
    392363
    393     $query = 'select id';
    394     $query.= ' from '.PREFIX_TABLE.'categories';
    395     $query.= ' where site_id = '.$site_id;
    396     $query.= " and dir = '".$name."'";
     364    $query = 'SELECT id';
     365    $query.= ' FROM '.PREFIX_TABLE.'categories';
     366    $query.= ' WHERE site_id = '.$site_id;
     367    $query.= " AND dir = '".$name."'";
    397368    if ( $id_uppercat == 'NULL' )
    398369    {
    399       $query.= ' and id_uppercat is NULL';
     370      $query.= ' AND id_uppercat IS NULL';
    400371    }
    401372    else
    402373    {
    403       $query.= ' and id_uppercat = '.$id_uppercat;
     374      $query.= ' AND id_uppercat = '.$id_uppercat;
    404375    }
    405376    $query.= ';';
     
    408379    {
    409380      // we have to create the category
    410       $query = 'insert into '.PREFIX_TABLE.'categories';
    411       $query.= " (dir,site_id,id_uppercat) values ('".$name."',".$site_id;
     381      $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
     382      $query.= " (dir,site_id,id_uppercat) VALUES ('".$name."',".$site_id;
    412383      if ( !is_numeric( $id_uppercat ) )
    413384      {
     
    429400    }
    430401    $output.= insert_remote_image( $list_dirs[$i], $category_id );
    431     update_cat_info( $category_id );
     402    update_category( $category_id );
    432403    $output.= insert_remote_category( $list_dirs[$i], $site_id,
    433404                                      $category_id, $level+1 );
     
    436407  // we have to remove the categories of the database not present in the xml
    437408  // file (ie deleted from the picture storage server)
    438   $query = 'select dir,id';
    439   $query.= ' from '.PREFIX_TABLE.'categories';
    440   $query.= ' where site_id = '.$site_id;
     409  $query = 'SELECT dir,id';
     410  $query.= ' FROM '.PREFIX_TABLE.'categories';
     411  $query.= ' WHERE site_id = '.$site_id;
    441412  if ( !is_numeric( $id_uppercat ) )
    442413  {
    443     $query.= ' and id_uppercat is NULL';
     414    $query.= ' AND id_uppercat IS NULL';
    444415  }
    445416  else
    446417  {
    447     $query.= ' and id_uppercat = '.$id_uppercat;
     418    $query.= ' AND id_uppercat = '.$id_uppercat;
    448419  }
    449420  $query.= ';';
     
    485456                       
    486457    // is the picture already existing in the database ?
    487     $query = 'select id,tn_ext';
    488     $query.= ' from '.PREFIX_TABLE.'images';
    489     $query.= ' where cat_id = '.$category_id;
    490     $query.= " and file = '".$file."'";
     458    $query = 'SELECT id,tn_ext';
     459    $query.= ' FROM '.PREFIX_TABLE.'images';
     460    $query.= ' WHERE storage_category_id = '.$category_id;
     461    $query.= " AND file = '".$file."'";
    491462    $query.= ';';
    492463    $result = mysql_query( $query );
     
    494465    if ( mysql_num_rows( $result ) == 0 )
    495466    {
    496       $query = 'insert into '.PREFIX_TABLE.'images';
    497       $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)';
    498       $query.= ' values (';
     467      $query = 'INSERT INTO '.PREFIX_TABLE.'images';
     468      $query.= ' (file,storage_category_id,date_available,tn_ext';
     469      $query.= ',filesize,width,height)';
     470      $query.= ' VALUES (';
    499471      $query.= "'".$file."'";
    500472      $query.= ",'".$category_id."'";
     
    506478      $query.= ')';
    507479      $query.= ';';
     480      // retrieving the id of newly inserted picture
     481      $query = 'SELECT id';
     482      $query.= ' FROM '.PREFIX_TABLE.'images';
     483      $query.= ' WHERE storage_category_id = '.$category_id;
     484      $query.= " AND file = '".$file."'";
     485      $query.= ';';
     486      list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
     487      // adding the link between this picture and its storage category
     488      $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     489      $query.= ' (image_id,category_id) VALUES ';
     490      $query.= ' ('.$image_id.','.$category_id.')';
     491      $query.= ';';
     492      mysql_query( $query );
    508493
    509494      $output.= $file;
     
    520505      if ( $row['tn_ext'] != $tn_ext )
    521506      {
    522         $query = 'update '.PREFIX_TABLE.'images';
    523         $query.= ' set';
     507        $query = 'UPDATE '.PREFIX_TABLE.'images';
     508        $query.= ' SET';
    524509        $query.= " tn_ext = '".$tn_ext."'";
    525         $query.= ' where cat_id = '.$category_id;
    526         $query.= " and file = '".$file."'";
     510        $query.= ' WHERE storage_category_id = '.$category_id;
     511        $query.= " AND file = '".$file."'";
    527512        $query.= ';';
    528513      }
     
    536521  // we have to remove the pictures of the database not present in the xml file
    537522  // (ie deleted from the picture storage server)
    538   $query = 'select id,file';
    539   $query.= ' from '.PREFIX_TABLE.'images';
    540   $query.= ' where cat_id = '.$category_id;
     523  $query = 'SELECT id,file';
     524  $query.= ' FROM '.PREFIX_TABLE.'images';
     525  $query.= ' WHERE storage_category_id = '.$category_id;
    541526  $query.= ';';
    542527  $result = mysql_query( $query );
     
    558543templatize_array( $tpl, 'lang', $sub );
    559544$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
     545//-------------------------------------------------------- categories structure
     546$page['plain_structure'] = get_plain_structure();
    560547//-------------------------------------------- introduction : choices of update
    561548// Display choice if "update" var is not specified
  • trunk/admin/waiting.php

    r57 r61  
    2121if ( isset( $_POST['submit'] ) )
    2222{
    23   $query = 'SELECT id,cat_id,file,tn_ext';
     23  $query = 'SELECT id,storage_category_id,file,tn_ext';
    2424  $query.= ' FROM '.PREFIX_TABLE.'waiting';
    2525  $query.= " WHERE validated = 'false'";
     
    4040        $query.= ';';
    4141        mysql_query( $query );
     42        // linking logically the picture to its storage category
     43        $query = 'INSERT INTO';
    4244      }
    4345      else
     
    5052        mysql_query( $query );
    5153        // deletion of the associated files
    52         $cat = get_cat_info( $row['cat_id'] );
    53         unlink( '.'.$cat['dir'].$row['file'] );
     54        $dir = get_complete_dir( $row['storage_category_id'] );
     55        unlink( '.'.$dir.$row['file'] );
    5456        if ( $row['tn_ext'] != '' )
    5557        {
     
    5759          $thumbnail.= get_filename_wo_extension( $row['file'] );
    5860          $thumbnail.= '.'.$row['tn_ext'];
    59           $url = '.'.$cat['dir'].'thumbnail/'.$thumbnail;
     61          $url = '.'.$dir.'thumbnail/'.$thumbnail;
    6062          unlink( $url );
    6163        }
     
    7173//---------------------------------------------------------------- form display
    7274$cat_names = array();
    73 $query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext';
     75$query = 'SELECT id,storage_category_id,file,username,mail_address';
     76$query.= ',date,tn_ext';
    7477$query.= ' FROM '.PREFIX_TABLE.'waiting';
    7578$query.= " WHERE validated = 'false'";
    76 $query.= ' ORDER BY cat_id';
     79$query.= ' ORDER BY storage_category_id';
    7780$query.= ';';
    7881$result = mysql_query( $query );
     
    8689    $vtp->setVar( $sub, 'picture.class', 'row2' );
    8790  }
    88   if ( !isset( $cat_names[$row['cat_id']] ) )
     91  if ( !isset( $cat_names[$row['storage_category_id']] ) )
    8992  {
    90     $cat = get_cat_info( $row['cat_id'] );
    91     $cat_names[$row['cat_id']] = array();
    92     $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir'];
    93     $cat_names[$row['cat_id']]['display_name'] =
     93    $cat = get_cat_info( $row['storage_category_id'] );
     94    $cat_names[$row['storage_category_id']] = array();
     95    $cat_names[$row['storage_category_id']]['dir'] =
     96      '.'.get_complete_dir( $row['storage_category_id'] );
     97    $cat_names[$row['storage_category_id']]['display_name'] =
    9498      get_cat_display_name( $cat['name'], ' &gt; ', 'font-weight:bold;' );
    9599  }
    96100  // category name
    97101  $vtp->setVar( $sub, 'picture.cat_name',
    98                 $cat_names[$row['cat_id']]['display_name'] );
     102                $cat_names[$row['storage_category_id']]['display_name'] );
    99103  // date displayed like this (in English ) :
    100104  //                     Sunday 15 June 2003 21:29
    101   $date = $lang['day'][date( 'w', $row['date'] )];   // Sunday
    102   $date.= date( ' j ', $row['date'] );               // 15
    103   $date.= $lang['month'][date( 'n', $row['date'] )]; // June
    104   $date.= date( ' Y G:i', $row['date'] );            // 2003 21:29
     105  $date = format_date( $row['date'], 'unix', true );
    105106  $vtp->setVar( $sub, 'picture.date', $date );
    106107  // file preview link
    107   $url = $cat_names[$row['cat_id']]['dir'].$row['file'];
     108  $url = $cat_names[$row['storage_category_id']]['dir'].$row['file'];
    108109  $vtp->setVar( $sub, 'picture.preview_url', $url );
    109110  // file name
     
    116117    $thumbnail.= get_filename_wo_extension( $row['file'] );
    117118    $thumbnail.= '.'.$row['tn_ext'];
    118     $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail;
     119    $url = $cat_names[$row['storage_category_id']]['dir'];
     120    $url.= 'thumbnail/'.$thumbnail;
    119121    $vtp->setVar( $sub, 'thumbnail.preview_url', $url );
    120122    $vtp->setVar( $sub, 'thumbnail.file', $thumbnail );
  • 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'];
  • trunk/include/functions.inc.php

    r57 r61  
    350350  }
    351351}
     352
     353function format_date( $date, $type = 'us', $show_time = false )
     354{
     355  global $lang;
     356
     357  switch ( $type )
     358  {
     359  case 'us' :
     360    list( $year,$month,$day ) = explode( '-', $date );
     361    $unixdate = mktime(0,0,0,$month,$day,$year);
     362    break;
     363  case 'unix' :
     364    $unixdate = $date;
     365    break;
     366  }
     367  $formated_date = $lang['day'][date( "w", $unixdate )];
     368  $formated_date.= date( " j ", $unixdate );
     369  $formated_date.= $lang['month'][date( "n", $unixdate )];
     370  $formated_date.= date( ' Y', $unixdate );
     371  if ( $show_time )
     372  {
     373    $formated_date.= date( ' G:i', $unixdate );
     374  }
     375
     376  return $formated_date;
     377}
    352378?>
  • 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'];
  • trunk/language/francais.php

    r48 r61  
    3030$lang['open'] = 'ouvrir';
    3131$lang['keywords'] = 'mots-clefs';
     32$lang['errors_title'] = 'Erreurs';
     33$lang['default'] = 'défaut';
    3234// end version 1.3
    3335
     
    265267  $lang['title_group_perm'] = 'Modifier les permissions pour le groupe';
    266268  $lang['title_comments'] = 'Commentaires des visiteurs';
     269  $lang['title_picmod'] = 'Modifier les informations d\'une image';
    267270// end version 1.3
    268271  $lang['title_categories'] = 'Gestion des catégories';
     
    512515  $lang['infoimage_addtoall'] = 'ajouter à tous';
    513516  $lang['infoimage_removefromall'] = 'retirer à tous';
     517  $lang['infoimage_associate'] = 'Associer à la catégorie';
    514518// end version 1.3
    515519  $lang['infoimage_general'] = 'Options générale pour la catégorie';
  • trunk/picture.php

    r57 r61  
    2424check_cat_id( $_GET['cat'] );
    2525check_login_authorization();
     26$page['plain_structure'] = get_plain_structure();
    2627if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
    2728{
     
    3940//------------------------------------- main picture information initialization
    4041$query = 'SELECT id,date_available,comment,hit,keywords';
    41 $query.= ',author,name,file,date_creation,filesize,width,height,cat_id';
     42$query.= ',author,name,file,date_creation,filesize,width,height';
     43$query.= ',storage_category_id,category_id';
    4244$query.= ' FROM '.PREFIX_TABLE.'images';
     45$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    4346$query.= $page['where'];
    4447$query.= ' AND id = '.$_GET['image_id'];
     
    5861$page['width']          = $row['width'];
    5962$page['height']         = $row['height'];
    60 $page['cat_id']         = $row['cat_id'];
     63$page['category_id']    = $row['category_id'];
    6164$page['keywords']       = $row['keywords'];
     65$page['storage_category_id'] = $row['storage_category_id'];
    6266// retrieving the number of the picture in its category (in order)
    6367$query = 'SELECT id';
    6468$query.= ' FROM '.PREFIX_TABLE.'images';
     69$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    6570$query.= $page['where'];
    6671$query.= $conf['order_by'];
     
    124129    $query = 'SELECT id';
    125130    $query.= ' FROM '.PREFIX_TABLE.'images';
     131    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    126132    $query.= $page['where'];
    127133    $query.= $conf['order_by'];
     
    206212{
    207213  $prev = $page['num'] - 1;
    208   $query = 'SELECT id,name,file,tn_ext,cat_id';
     214  $query = 'SELECT id,name,file,tn_ext,storage_category_id';
    209215  $query.= ' FROM '.PREFIX_TABLE.'images';
     216  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    210217  $query.= $page['where'];
    211218  $query.= $conf['order_by'];
     
    215222  $row = mysql_fetch_array( $result );
    216223
    217   if ( !is_numeric( $page['cat'] ) )
    218   {
    219     if ( $array_cat_directories[$row['cat_id']] == '' )
    220     {
    221       $cat_result = get_cat_info( $row['cat_id'] );
    222       $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
    223     }
    224     $cat_directory = $array_cat_directories[$row['cat_id']];
    225   }
    226                
    227   $file = substr ( $row['file'], 0, strrpos ( $row['file'], '.' ) );
     224  if ( $array_cat_directories[$row['storage_category_id']] == '' )
     225  {
     226    $array_cat_directories[$row['storage_category_id']] =
     227      get_complete_dir( $row['storage_category_id'] );
     228  }
     229  $cat_directory = $array_cat_directories[$row['storage_category_id']];
     230
     231  $file = substr( $row['file'], 0, strrpos ( $row['file'], '.' ) );
    228232  $lien_thumbnail = $cat_directory.'/thumbnail/';
    229233  $lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
    230                
     234
    231235  $prev_title = $lang['previous_image'].' : ';
    232236  $alt_thumbnaill = '';
     
    262266else
    263267{
    264   $cat_result = get_cat_info( $page['cat_id'] );
    265   if ( $array_cat_directories[$page['cat_id']] == "" )
    266   {
    267     $array_cat_directories[$page['cat_id']] = $cat_result['dir'];
    268   }
    269   $cat_directory = $array_cat_directories[$page['cat_id']];
    270268  $intitule_cat = $page['title'];
    271269}
     270
     271if ( $array_cat_directories[$page['storage_category_id']] == '' )
     272{
     273  $array_cat_directories[$page['storage_category_id']] =
     274    get_complete_dir( $page['storage_category_id'] );
     275}
     276$cat_directory = $array_cat_directories[$page['storage_category_id']];
     277
    272278$n = $page['num'] + 1;
    273279$intitule_titre = replace_space( $intitule_cat." - " ).$n.'/'.
     
    348354  $vtp->addSession( $handle, 'info_line' );
    349355  $vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' );
    350   list( $year,$month,$day ) = explode( '-', $page['date_creation'] );
    351356  $vtp->setVar( $handle, 'info_line.content',
    352                 $day.'/'.$month.'/'.$year );
     357                format_date( $page['date_creation'] ) );
    353358  $vtp->closeSession( $handle, 'info_line' );
    354359}
     
    358363list( $year,$month,$day ) = explode( '-', $page['date_available'] );
    359364$vtp->setVar( $handle, 'info_line.content',
    360               $day.'/'.$month.'/'.$year );
     365              format_date( $page['date_available'] ) );
    361366$vtp->closeSession( $handle, 'info_line' );
    362367// size in pixels
     
    456461{
    457462  $vtp->addSession( $handle, 'modification' );
    458   $url = './admin/admin.php?page=infos_images&amp;cat_id='.$page['cat'];
    459   $url.= '&amp;num='.$page['num'];
    460   $vtp->setVar( $handle, 'modification.link',
    461                 add_session_id( $url )."#".$page['id'] );
     463  $url = './admin/admin.php?page=picture_modify&amp;cat_id='.$page['cat'];
     464  $url.= '&amp;image_id='.$page['id'];
     465  $vtp->setVar( $handle, 'modification.link', add_session_id( $url ) );
    462466  $vtp->setVar( $handle, 'modification.name', $lang['link_info_image'] );
    463467}
     
    466470{
    467471  $next = $page['num'] + 1;
    468   $query = 'SELECT id,name,file,tn_ext,cat_id';
     472  $query = 'SELECT id,name,file,tn_ext,storage_category_id';
    469473  $query.= ' FROM '.PREFIX_TABLE.'images';
     474  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
    470475  $query.= $page['where'];
    471476  $query.= $conf['order_by'];
     
    474479  $result = mysql_query( $query );
    475480  $row = mysql_fetch_array( $result );
    476                
    477   if ( !is_numeric( $page['cat'] ) )
    478   {
    479     if ( $array_cat_directories[$row['cat_id']] == "" )
    480     {
    481       $cat_result = get_cat_info( $row['cat_id'] );
    482       $array_cat_directories[$row['cat_id']] = $cat_result['dir'];
    483     }
    484     $cat_directory = $array_cat_directories[$row['cat_id']];
    485   }
     481
     482  if ( $array_cat_directories[$row['storage_category_id']] == '' )
     483  {
     484    $array_cat_directories[$row['storage_category_id']] =
     485      get_complete_dir( $row['storage_category_id'] );
     486  }
     487  $cat_directory = $array_cat_directories[$row['storage_category_id']];
    486488
    487489  $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
     
    630632    $vtp->addSession( $handle, 'comment' );
    631633    $vtp->setVar( $handle, 'comment.author', $row['author'] );
    632     $displayed_date = $lang['day'][date( "w", $row['date'] )];
    633     $displayed_date.= date( " j ", $row['date'] );
    634     $displayed_date.= $lang['month'][date( "n", $row['date'] )];
    635     $displayed_date.= date( ' Y G:i', $row['date'] );
    636     $vtp->setVar( $handle, 'comment.date', $displayed_date );
     634    $vtp->setVar( $handle, 'comment.date',
     635                  format_date( $row['date'], 'unix', true ) );
    637636    $vtp->setVar( $handle, 'comment.content', nl2br( $row['content'] ) );
    638637    if ( $user['status'] == 'admin' )
  • trunk/template/default/admin/configuration.vtp

    r55 r61  
    11<!--VTP_errors-->
    22<div class="errors">
    3   <div class="errors_title">Erreurs</div>
     3  <div class="errors_title">{#errors_title}</div>
    44  <ul>
    55    <!--VTP_li-->
  • trunk/template/default/admin/infos_image.vtp

    r48 r61  
    4343  <table width="100%">
    4444    <tr>
    45       <th colspan="6">{#infoimage_detailed}</th>
     45      <th colspan="7">{#infoimage_detailed}</th>
    4646    </tr>
    4747    <tr>
    48       <td colspan="6" align="center">{#navigation_bar}</td>
     48      <td colspan="7" align="center">{#navigation_bar}</td>
    4949    </tr>
    5050    <tr>
     51      <td style="width:0px;">&nbsp;</td>
    5152      <td class="row2" style="text-align:center;">{#thumbnail}</td>
    5253      <td class="row2" style="text-align:center;">{#infoimage_title}</td>
     
    5859    <!--VTP_picture-->
    5960    <tr>
     61      <td style="width:0px;">
     62        <div style="margin-left:2px;margin-right:2px;">
     63          <input type="checkbox" name="check-{#id}" value="1" />
     64        </div>
     65      </td>
    6066      <td style="text-align:center;"><a name="{#link}" href="{#url}"><img src="{#thumbnail_url}" alt="" class="miniature" title="{#filename}" /></td>
    6167      <td style="text-align:center;">{#default_name}<br /><input type="text" name="name-{#id}" value="{#name}" maxlength="255"/></td>
     
    6773    <!--/VTP_picture-->
    6874    <tr>
     75      <td colspan="6">
     76        <img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="&lt;" />
     77        {#infoimage_associate}
     78        <select name="associate">
     79          <!--VTP_associate_cat-->
     80          <option value="{#value}">{#content}</option>
     81          <!--/VTP_associate_cat-->
     82        </select>
     83    </td>
     84  </tr>
     85    <tr>
    6986      <td colspan="6" style="text-align:center;">
    7087        <input type="submit" value="{#submit}" name="submit" />
  • trunk/upload.php

    r57 r61  
    206206  {
    207207    $query = 'insert into '.PREFIX_TABLE.'waiting';
    208     $query.= ' (cat_id,file,username,mail_address,date,infos) values';
    209     $query.= " (".$page['cat'].",'".$_FILES['picture']['name']."'";
     208    $query.= ' (storage_category_id,file,username,mail_address,date,infos)';
     209    $query.= ' values ';
     210    $query.= '('.$page['cat'].",'".$_FILES['picture']['name']."'";
    210211    $query.= ",'".htmlspecialchars( $_POST['username'], ENT_QUOTES)."'";
    211212    $query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
Note: See TracChangeset for help on using the changeset viewer.