quick search results improvement: elements with the same relevance are ordered using the global order_bye
git-svn-id: http://piwigo.org/svn/trunk@2043 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
a8150ba6a2
commit
6118c54835
1 changed files with 11 additions and 3 deletions
|
|
@ -417,6 +417,7 @@ SELECT image_id, COUNT(tag_id) AS q
|
|||
{
|
||||
// before returning the result "as is", make sure the user has the
|
||||
// permissions for every item
|
||||
global $conf;
|
||||
$query = '
|
||||
SELECT DISTINCT(id)
|
||||
FROM '.IMAGES_TABLE.'
|
||||
|
|
@ -431,9 +432,16 @@ SELECT DISTINCT(id)
|
|||
'visible_images' => 'id'
|
||||
),
|
||||
'AND'
|
||||
);
|
||||
$allowed_image_ids = array_from_query( $query, 'id');
|
||||
$by_weights = array_intersect_key($by_weights, array_flip($allowed_image_ids));
|
||||
).'
|
||||
'.$conf['order_by'];
|
||||
$allowed_images = array_flip( array_from_query( $query, 'id') );
|
||||
$by_weights = array_intersect_key($by_weights, $allowed_images );
|
||||
$divisor = 4.0 * count($allowed_images);
|
||||
// decrease weight from 0 to 0.25 corresponding to the order
|
||||
foreach ($allowed_images as $id=>$rank )
|
||||
{
|
||||
$by_weights[$id] -= $rank / $divisor;
|
||||
}
|
||||
$permissions_checked = true;
|
||||
}
|
||||
arsort($by_weights, SORT_NUMERIC);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue