Changeset 2043 for trunk


Ignore:
Timestamp:
Jun 23, 2007, 9:40:38 PM (17 years ago)
Author:
rvelices
Message:

quick search results improvement: elements with the same relevance are ordered using the global order_bye

File:
1 edited

Legend:

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

    r1906 r2043  
    418418    // before returning the result "as is", make sure the user has the
    419419    // permissions for every item
     420    global $conf;
    420421    $query = '
    421422SELECT DISTINCT(id)
     
    432433      ),
    433434    'AND'
    434   );
    435     $allowed_image_ids = array_from_query( $query, 'id');
    436     $by_weights = array_intersect_key($by_weights, array_flip($allowed_image_ids));
     435  ).'
     436  '.$conf['order_by'];
     437    $allowed_images = array_flip( array_from_query( $query, 'id') );
     438    $by_weights = array_intersect_key($by_weights, $allowed_images );
     439    $divisor = 4.0 * count($allowed_images);
     440    // decrease weight from 0 to 0.25 corresponding to the order
     441    foreach ($allowed_images as $id=>$rank )
     442    {
     443      $by_weights[$id] -=  $rank / $divisor;
     444    }
    437445    $permissions_checked = true;
    438446  }
Note: See TracChangeset for help on using the changeset viewer.