Changeset 17 for trunk/include/functions_category.inc.php
- Timestamp:
- May 25, 2003, 10:31:39 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_category.inc.php
r16 r17 133 133 if ( $page['cat'] == 'search' ) 134 134 { 135 $url.= "&search=".$_GET['search'] ;135 $url.= "&search=".$_GET['search'].'&mode='.$_GET['mode']; 136 136 } 137 137 $lien_cat = add_session_id( $url ); … … 382 382 else 383 383 { 384 $query = ''; 384 if ( $page['cat'] == 'search' or $page['cat'] == 'most_visited' 385 or $page['cat'] == 'recent' or $page['cat'] == 'best_rated' ) 386 { 387 // we must not show pictures of a forbidden category 388 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); 389 foreach ( $restricted_cats as $restricted_cat ) { 390 $where_append.= ' AND cat_id != '.$restricted_cat; 391 } 392 } 385 393 // search result 386 394 if ( $page['cat'] == 'search' ) … … 392 400 $page['title'].= $_GET['search']."</span>"; 393 401 } 394 $page['where'] = " WHERE ( file LIKE '%".$_GET['search']."%'"; 395 $page['where'].= " OR name LIKE '%".$_GET['search']."%'"; 396 $page['where'].= " OR comment LIKE '%".$_GET['search']."%' )"; 402 403 $page['where'] = ' WHERE ('; 404 $fields = array( 'file', 'name', 'comment' ); 405 $words = explode( ',', $_GET['search'] ); 406 $sql_search = array(); 407 foreach ( $words as $i => $word ) { 408 if ( $_GET['mode'] == 'OR' ) 409 { 410 if ( $i != 0 ) $page['where'].= ' OR'; 411 foreach ( $fields as $j => $field ) { 412 if ( $j != 0 ) $page['where'].= ' OR'; 413 $page['where'].= ' '.$field." LIKE '%".$word."%'"; 414 } 415 } 416 else if ( $_GET['mode'] == 'AND' ) 417 { 418 if ( $i != 0 ) $page['where'].= ' AND'; 419 $page['where'].= ' ('; 420 foreach ( $fields as $j => $field ) { 421 if ( $j != 0 ) $page['where'].= ' OR'; 422 $page['where'].= ' '.$field." LIKE '%".$word."%'"; 423 } 424 $page['where'].= ' )'; 425 } 426 } 427 $page['where'].= ' )'; 428 $page['where'].= $where_append; 397 429 398 430 $query = 'SELECT COUNT(*) AS nb_total_images'; … … 401 433 $query.= ';'; 402 434 403 $url.= '&search='.$_GET['search'] ;435 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 404 436 } 405 437 // favorites displaying … … 426 458 $page['where'] = " WHERE date_available > '"; 427 459 $page['where'].= date( 'Y-m-d', $date )."'"; 460 $page['where'].= $where_append; 428 461 429 462 $query = 'SELECT COUNT(*) AS nb_total_images'; … … 436 469 { 437 470 $page['title'] = $conf['top_number'].' '.$lang['most_visited_cat']; 438 $page['where'] = ' WHERE cat_id != -1' ;471 $page['where'] = ' WHERE cat_id != -1'.$where_append; 439 472 $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 440 473 $page['cat_nb_images'] = $conf['top_number']; … … 450 483 $row = mysql_fetch_array( $result ); 451 484 $page['cat_nb_images'] = $row['nb_total_images']; 452 }453 454 if ( $page['cat'] == 'search' or $page['cat'] == 'most_visited'455 or $page['cat'] == 'recent' or $page['cat'] == 'best_rated' )456 {457 // we must not show pictures of a forbidden category458 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] );459 foreach ( $restricted_cats as $restricted_cat ) {460 $page['where'].= ' AND cat_id != '.$restricted_cat;461 }462 485 } 463 486 } … … 519 542 while ( $row = mysql_fetch_array( $result ) ) 520 543 { 521 if ( $row['nb_images'] == 0 )522 {523 $non_empty_cat = get_first_non_empty_cat_id( $row['id'] );524 }525 else526 {527 $non_empty_cat = $row['id'];528 }529 544 // only categories with findable picture in any of its subcats is 530 545 // represented. 531 if ( $non_empty_cat != false ) 546 if ( ( $row['nb_images'] != 0 and $non_empty_cat = $row['id'] ) 547 or $non_empty_cat = get_first_non_empty_cat_id( $row['id'] ) ) 532 548 { 533 549 $temp_cat = array( 534 'id' => $row['id'],535 'name' => $row['name'],536 'dir' => $row['dir'],537 'date_dernier' => $row['date_dernier'],550 'id' => $row['id'], 551 'name' => $row['name'], 552 'dir' => $row['dir'], 553 'date_dernier' => $row['date_dernier'], 538 554 'non_empty_cat' => $non_empty_cat ); 539 555 array_push( $cats, $temp_cat );
Note: See TracChangeset
for help on using the changeset viewer.