aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-06-23 19:42:56 +0000
committerrvelices <rv-github@modusoptimus.com>2007-06-23 19:42:56 +0000
commit134c91774f0eeb6532fb7ec8bcdfc3e489c8d2ad (patch)
treeb6ea0ce09f6a8ae747ed671487377e02b9796e01 /include
parent94a89e8f10bf95bb898d693204df4c6ba894291d (diff)
merge 2043 from trunk to branch-1_7
quick search results improvement: elements with the same relevance are ordered using the global order_by git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2044 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_search.inc.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index e2d518e0d..0c2e61214 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -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);