- Timestamp:
- Nov 15, 2004, 10:42:08 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_category.inc.php
r602 r603 307 307 function get_cat_info( $id ) 308 308 { 309 $infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url' 310 ,'dir','date_last','uploadable','status','visible' 311 ,'representative_picture_id','uppercats','commentable' ); 312 313 $query = 'SELECT '.implode( ',', $infos ); 314 $query.= ' FROM '.CATEGORIES_TABLE.' AS a'; 315 $query.= ', '.SITES_TABLE.' AS b'; 316 $query.= ' WHERE a.id = '.$id; 317 $query.= ' AND a.site_id = b.id'; 318 $query.= ';'; 319 $row = mysql_fetch_array( pwg_query( $query ) ); 309 $infos = array('nb_images','id_uppercat','comment','site_id' 310 ,'dir','date_last','uploadable','status','visible' 311 ,'representative_picture_id','uppercats','commentable'); 312 313 $query = ' 314 SELECT '.implode(',', $infos).' 315 FROM '.CATEGORIES_TABLE.' 316 WHERE id = '.$id.' 317 ;'; 318 $row = mysql_fetch_array(pwg_query($query)); 320 319 321 320 $cat = array(); 322 // affectation of each field of the table "config" to an information of the 323 // array $cat. 324 foreach ( $infos as $info ) { 325 if ( isset( $row[$info] ) ) $cat[$info] = $row[$info]; 326 else $cat[$info] = ''; 321 foreach ($infos as $info) 322 { 323 if (isset($row[$info])) 324 { 325 $cat[$info] = $row[$info]; 326 } 327 else 328 { 329 $cat[$info] = ''; 330 } 327 331 // If the field is true or false, the variable is transformed into a 328 332 // boolean value. 329 if ( $cat[$info] == 'true' or $cat[$info] == 'false')333 if ($cat[$info] == 'true' or $cat[$info] == 'false') 330 334 { 331 335 $cat[$info] = get_boolean( $cat[$info] ); 332 336 } 333 337 } 334 $cat['comment'] = nl2br( $cat['comment']);338 $cat['comment'] = nl2br($cat['comment']); 335 339 336 340 $cat['name'] = array(); 337 341 338 $query = 'SELECT name,id FROM '.CATEGORIES_TABLE; 339 $query.= ' WHERE id IN ('.$cat['uppercats'].')'; 340 $query.= ' ORDER BY id ASC'; 341 $query.= ';'; 342 $result = pwg_query( $query ); 343 while( $row = mysql_fetch_array( $result ) ) 342 $query = ' 343 SELECT name,id 344 FROM '.CATEGORIES_TABLE.' 345 WHERE id IN ('.$cat['uppercats'].') 346 ORDER BY id ASC 347 ;'; 348 $result = pwg_query($query); 349 while($row = mysql_fetch_array($result)) 344 350 { 345 351 $cat['name'][$row['id']] = $row['name']; … … 953 959 } 954 960 } 961 962 /** 963 * returns all subcategory identifiers of given category ids 964 * 965 * @param array ids 966 * @return array 967 */ 968 function get_subcat_ids($ids) 969 { 970 $query = ' 971 SELECT DISTINCT(id) 972 FROM '.CATEGORIES_TABLE.' 973 WHERE '; 974 foreach ($ids as $num => $category_id) 975 { 976 if ($num > 0) 977 { 978 $query.= ' 979 OR '; 980 } 981 $query.= 'uppercats REGEXP \'(^|,)'.$category_id.'(,|$)\''; 982 } 983 $query.= ' 984 ;'; 985 $result = pwg_query($query); 986 987 $subcats = array(); 988 while ($row = mysql_fetch_array($result)) 989 { 990 array_push($subcats, $row['id']); 991 } 992 return $subcats; 993 } 955 994 ?>
Note: See TracChangeset
for help on using the changeset viewer.