Ignore:
Timestamp:
Oct 12, 2007, 5:27:34 AM (17 years ago)
Author:
rvelices
Message:
  • fix plugin menu link broken with xamp (realpath behaves differently)
  • complete quick search rewriting
    • now we can quote phrases as in google "New York" is not the same as New York
    • user comments not searched anymore (faster)
    • the big full text query does not use joins anymore (faster)
    • related tags not shown on the index page, but now you can see the matching tags and matching categories
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r2126 r2135  
    760760  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
    761761
    762   $where_clauses = ws_std_image_sql_filter( $params );
    763   $order_by = ws_std_image_sql_order($params);
    764 
    765   if ( !empty($where_clauses) and !empty($order_by) )
    766   {
     762  $where_clauses = ws_std_image_sql_filter( $params, 'i.' );
     763  $order_by = ws_std_image_sql_order($params, 'i.');
     764
     765  if ( !empty($order_by) )
     766  {
     767    global $conf;
     768    $conf['order_by'] = 'ORDER BY '.$order_by;
    767769    $page['super_order_by']=1; // quick_search_result might be faster
    768770  }
    769   $search_result = get_quick_search_results($params['query']);
    770 
    771   global $image_ids; //needed for sorting by rank (usort)
    772   if ( ( !isset($search_result['as_is'])
    773       or !empty($where_clauses)
    774       or !empty($order_by) )
    775       and !empty($search_result['items']) )
    776   {
    777     $where_clauses[] = 'id IN ('
    778         .wordwrap(implode(', ', $search_result['items']), 80, "\n")
    779         .')';
    780     $where_clauses[] = get_sql_condition_FandF(
    781         array
    782           (
    783             'forbidden_categories' => 'category_id',
    784             'visible_categories' => 'category_id',
    785             'visible_images' => 'id'
    786           ),
    787         '', true
    788       );
    789     $query = '
    790 SELECT DISTINCT id FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
    791   WHERE '.implode('
    792     AND ', $where_clauses);
    793     if (!empty($order_by))
    794     {
    795       $query .= '
    796   ORDER BY '.$order_by;
    797     }
    798     $image_ids = array_from_query($query, 'id');
    799     global $ranks;
    800     $ranks = array_flip( $search_result['items'] );
    801     usort(
    802       $image_ids,
    803       create_function('$i1,$i2', 'global $ranks; return $ranks[$i1]-$ranks[$i2];')
    804     );
    805     unset ($ranks);
    806   }
    807   else
    808   {
    809     $image_ids = $search_result['items'];
    810   }
     771
     772  $search_result = get_quick_search_results($params['query'],
     773    implode(',', $where_clauses) );
     774  $image_ids = $search_result['items'];
    811775
    812776  $image_ids = array_slice($image_ids,
Note: See TracChangeset for help on using the changeset viewer.