aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-18 22:05:53 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-18 22:05:53 +0000
commit3d1277bf4d35dcd97c1bac312d1b065eea854fc9 (patch)
tree3205f275f7bc97808cf7194f6a7176a88be18389 /include
parent43ab0be533e5a902a856f93d7c697b11daf2bb9b (diff)
Modify function get_cat_info for preventing Php Warning when NULL values
found in category description git-svn-id: http://piwigo.org/svn/branches/release-1_3@296 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_category.inc.php43
1 files changed, 23 insertions, 20 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index de074e82c..b46f57ddc 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -114,10 +114,8 @@ function get_user_plain_structure()
list($year,$month,$day) = explode( '-', $row['date_last'] );
$category['date_last'] = mktime(0,0,0,$month,$day,$year);
}
- else
- {
- $category[$info] = $row[$info];
- }
+ else if ( isset( $row[$info] ) ) $category[$info] = $row[$info];
+ else $category[$info] = '';
}
$plain_structure[$row['id']] = $category;
}
@@ -261,27 +259,32 @@ function get_cat_info( $id )
{
global $page;
- $cat = array();
+ $infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url'
+ ,'dir','date_last','uploadable','status','visible'
+ ,'representative_picture_id','uppercats' );
- $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir';
- $query.= ',date_last,uploadable,status,visible,representative_picture_id';
- $query.= ',uppercats';
+ $query = 'SELECT '.implode( ',', $infos );
$query.= ' FROM '.PREFIX_TABLE.'categories AS a';
$query.= ', '.PREFIX_TABLE.'sites AS b';
$query.= ' WHERE a.id = '.$id;
- $query.= ' AND a.site_id = b.id;';
+ $query.= ' AND a.site_id = b.id';
+ $query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
- $cat['site_id'] = $row['site_id'];
- $cat['id_uppercat'] = $row['id_uppercat'];
- $cat['comment'] = nl2br( $row['comment'] );
- $cat['nb_images'] = $row['nb_images'];
- $cat['dir'] = $row['dir'];
- $cat['date_last'] = $row['date_last'];
- $cat['uploadable'] = get_boolean( $row['uploadable'] );
- $cat['status'] = $row['status'];
- $cat['visible'] = get_boolean( $row['visible'] );
- $cat['uppercats'] = $row['uppercats'];
- $cat['representative_picture_id'] = $row['representative_picture_id'];
+
+ $cat = array();
+ // affectation of each field of the table "config" to an information of the
+ // array $cat.
+ foreach ( $infos as $info ) {
+ if ( isset( $row[$info] ) ) $cat[$info] = $row[$info];
+ else $cat[$info] = '';
+ // If the field is true or false, the variable is transformed into a
+ // boolean value.
+ if ( $cat[$info] == 'true' or $cat[$info] == 'false' )
+ {
+ $cat[$info] = get_boolean( $cat[$info] );
+ }
+ }
+ $cat['comment'] = nl2br( $cat['comment'] );
$cat['name'] = array();