Changeset 621 for trunk/include
- Timestamp:
- Nov 25, 2004, 3:12:33 PM (20 years ago)
- Location:
- trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/category_default.inc.php
r606 r621 47 47 LIMIT '.$page['start'].','.$page['nb_image_page'].' 48 48 ;'; 49 // 49 //echo '<pre>'.$query.'</pre>'; 50 50 $result = pwg_query($query); 51 51 -
trunk/include/functions_category.inc.php
r617 r621 166 166 $query.= ';'; 167 167 168 // $query = '169 // SELECT COUNT(DISTINCT(image_id)) as total170 // FROM '.PREFIX_TABLE.'image_category';171 // if (count($user['restrictions']) > 0)172 // {173 // $query.= '174 // WHERE category_id NOT IN ('.$user['forbidden_categories'].')';175 // }176 // $query = '177 // ;';178 179 168 $row = mysql_fetch_array( pwg_query( $query ) ); 180 169 181 170 if ( !isset( $row['total'] ) ) $row['total'] = 0; 182 183 171 return $row['total']; 184 172 } … … 345 333 $page['nb_image_page'] = $user['nb_image_page']; 346 334 // $url is used to create the navigation bar 347 $url = './category.php?cat='.$page['cat'];335 $url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; 348 336 if ( isset($page['expand']) ) $url.= '&expand='.$page['expand']; 349 337 // simple category … … 428 416 // SQL where clauses are stored in $clauses array during query 429 417 // construction 430 $clauses = array(); 431 432 $textfields = array('file', 'name', 'comment', 'keywords', 'author'); 433 foreach ($textfields as $textfield) 434 { 435 if (isset($search['fields'][$textfield])) 418 $clauses = $temp_clauses = array(); 419 if (isset($search['fields']['keywords'])) 420 { 421 $textfields = array('file', 'name', 'comment', 'keywords', 'author'); 422 foreach ($textfields as $textfield) 436 423 { 437 424 $local_clauses = array(); 438 foreach ($search['fields'][ $textfield]['words'] as $word)425 foreach ($search['fields']['keywords']['words'] as $word) 439 426 { 440 427 array_push($local_clauses, $textfield." LIKE '%".$word."%'"); … … 442 429 // adds brackets around where clauses 443 430 array_walk($local_clauses,create_function('&$s','$s="(".$s.")";')); 444 array_push($ clauses,445 implode(' '.$search['fields'][ $textfield]['mode'].' ',431 array_push($temp_clauses, 432 implode(' '.$search['fields']['keywords']['mode'].' ', 446 433 $local_clauses)); 447 434 } 448 } 435 array_push($clauses, implode(' OR ', $temp_clauses)); 436 } 437 438 if (isset($search['fields']['author'])) 439 { 440 array_push($clauses, "author LIKE '%".$search['fields']['author']['words'][0]."%'"); 441 } 449 442 450 443 $datefields = array('date_available', 'date_creation'); … … 454 447 if (isset($search['fields'][$key])) 455 448 { 456 $local_clause = $datefield." = '"; 449 $local_clause = $datefield." "; 450 if (isset($search['fields'][$key]['mode'])) 451 { 452 $local_clause .=">"; 453 } 454 $local_clause .="= '"; 457 455 $local_clause.= str_replace('.', '-', 458 456 $search['fields'][$key]['words'][0]); 459 457 $local_clause.= "'"; 460 458 array_push($clauses, $local_clause); 461 } 462 463 foreach (array('after','before') as $suffix) 464 { 465 $key = $datefield.'-'.$suffix; 466 if (isset($search['fields'][$key])) 467 { 468 $local_clause = $datefield; 469 if ($suffix == 'after') 470 { 471 $local_clause.= ' >'; 472 } 473 else 474 { 475 $local_clause.= ' <'; 476 } 477 if (isset($search['fields'][$key]['mode']) 478 and $search['fields'][$key]['mode'] == 'inc') 479 { 480 $local_clause.= '='; 481 } 482 $local_clause.= " '"; 483 $local_clause.= str_replace('.', '-', 484 $search['fields'][$key]['words'][0]); 485 $local_clause.= "'"; 486 array_push($clauses, $local_clause); 487 } 488 } 489 } 490 459 460 if (isset($search['fields'][$key]['mode'])) 461 { 462 $search_tokens = explode('.', $search['fields'][$key]['words'][0]); 463 $start_time = mktime(0, 0, 0, $search_tokens[1], $search_tokens[2],$search_tokens[0]); 464 $search_duration = intval($search['fields'][$key]['mode']) * 86400; 465 $end_time = $start_time + $search_duration; 466 $end_sql_date = date('Y-m-d',$end_time); 467 $local_clause = $datefield." <= '".$end_sql_date."'"; 468 array_push($clauses, $local_clause); 469 } 470 } 471 } 472 491 473 if (isset($search['fields']['cat'])) 492 474 { … … 530 512 // adds brackets around where clauses 531 513 array_walk($clauses, create_function('&$s', '$s = "(".$s.")";')); 532 $page['where'] = 'WHERE '.implode(' '.$search['mode'].'', $clauses);514 $page['where'] = 'WHERE '.implode(' AND ', $clauses); 533 515 if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden; 534 516
Note: See TracChangeset
for help on using the changeset viewer.