Changeset 61 for trunk/include/functions_category.inc.php
- Timestamp:
- Aug 30, 2003, 5:54:37 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_category.inc.php
r57 r61 95 95 { 96 96 $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat', 97 'rank' );97 'rank','site_id'); 98 98 99 99 $query = 'SELECT '; … … 271 271 // $cat['comment'] 272 272 // $cat['dir'] 273 // $cat[' last_dir']273 // $cat['dir'] 274 274 // $cat['name'] is an array : 275 275 // - $cat['name'][0] is the lowest cat name … … 281 281 function get_cat_info( $id ) 282 282 { 283 global $page; 284 283 285 $cat = array(); 284 $cat['name'] = array();285 286 286 287 $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir'; 287 $query.= ',date_last,uploadable ';288 $query.= ',date_last,uploadable,status,visible'; 288 289 $query.= ' FROM '.PREFIX_TABLE.'categories AS a'; 289 290 $query.= ', '.PREFIX_TABLE.'sites AS b'; … … 295 296 $cat['comment'] = nl2br( $row['comment'] ); 296 297 $cat['nb_images'] = $row['nb_images']; 297 $cat[' last_dir']= $row['dir'];298 $cat['dir'] = $row['dir']; 298 299 $cat['date_last'] = $row['date_last']; 299 300 $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 } 330 311 return $cat; 331 312 } 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/" 319 function 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/" 328 function 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/" 344 function 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 333 356 // The function get_cat_display_name returns a string containing the list 334 357 // of upper categories to the root category from the lowest category shown … … 402 425 $page['cat_uploadable'] = $result['uploadable']; 403 426 $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']; 405 428 } 406 429 else … … 412 435 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); 413 436 foreach ( $restricted_cats as $restricted_cat ) { 414 $where_append.= ' AND cat _id != '.$restricted_cat;437 $where_append.= ' AND category_id != '.$restricted_cat; 415 438 } 416 439 } … … 500 523 { 501 524 $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; 503 526 $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 504 527 $page['cat_nb_images'] = $conf['top_number'];
Note: See TracChangeset
for help on using the changeset viewer.