Changeset 296


Ignore:
Timestamp:
Jan 18, 2004, 11:05:53 PM (20 years ago)
Author:
z0rglub
Message:

Modify function get_cat_info for preventing Php Warning when NULL values
found in category description

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/include/functions_category.inc.php

    r280 r296  
    115115        $category['date_last'] = mktime(0,0,0,$month,$day,$year);
    116116      }
    117           else
    118           {
    119                 $category[$info] = $row[$info];
    120           }
     117      else if ( isset( $row[$info] ) ) $category[$info] = $row[$info];
     118      else                             $category[$info] = '';
    121119    }
    122120    $plain_structure[$row['id']] = $category;
     
    262260  global $page;
    263261
    264   $cat = array();
    265 
    266   $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir';
    267   $query.= ',date_last,uploadable,status,visible,representative_picture_id';
    268   $query.= ',uppercats';
     262  $infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url'
     263                  ,'dir','date_last','uploadable','status','visible'
     264                  ,'representative_picture_id','uppercats' );
     265
     266  $query = 'SELECT '.implode( ',', $infos );
    269267  $query.= ' FROM '.PREFIX_TABLE.'categories AS a';
    270268  $query.= ', '.PREFIX_TABLE.'sites AS b';
    271269  $query.= ' WHERE a.id = '.$id;
    272   $query.= ' AND a.site_id = b.id;';
     270  $query.= ' AND a.site_id = b.id';
     271  $query.= ';';
    273272  $row = mysql_fetch_array( mysql_query( $query ) );
    274   $cat['site_id']     = $row['site_id'];
    275   $cat['id_uppercat'] = $row['id_uppercat'];
    276   $cat['comment']     = nl2br( $row['comment'] );
    277   $cat['nb_images']   = $row['nb_images'];
    278   $cat['dir']         = $row['dir'];
    279   $cat['date_last']   = $row['date_last'];
    280   $cat['uploadable']  = get_boolean( $row['uploadable'] );
    281   $cat['status']      = $row['status'];
    282   $cat['visible']     = get_boolean( $row['visible'] );
    283   $cat['uppercats']   = $row['uppercats'];
    284   $cat['representative_picture_id'] = $row['representative_picture_id'];
     273
     274  $cat = array();
     275  // affectation of each field of the table "config" to an information of the
     276  // array $cat.
     277  foreach ( $infos as $info ) {
     278    if ( isset( $row[$info] ) ) $cat[$info] = $row[$info];
     279    else                        $cat[$info] = '';
     280    // If the field is true or false, the variable is transformed into a
     281    // boolean value.
     282    if ( $cat[$info] == 'true' or $cat[$info] == 'false' )
     283    {
     284      $cat[$info] = get_boolean( $cat[$info] );
     285    }
     286  }
     287  $cat['comment'] = nl2br( $cat['comment'] );
    285288
    286289  $cat['name'] = array();
Note: See TracChangeset for help on using the changeset viewer.