summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/fulltext.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php
index 5af0bfc1b..a1dd1774d 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -260,11 +260,27 @@ function _ft_pageLookup(&$data){
}
$pages = array_map('trim',$pages);
- sort($pages);
+ usort($pages,'ft_pagesorter');
return $pages;
}
/**
+ * Sort pages based on their namespace level first, then on their string
+ * values. This makes higher hierarchy pages rank higher than lower hierarchy
+ * pages.
+ */
+function ft_pagesorter($a, $b){
+ $ac = count(explode(':',$a));
+ $bc = count(explode(':',$b));
+ if($ac < $bc){
+ return -1;
+ }elseif($ac > $bc){
+ return 1;
+ }
+ return strcmp ($a,$b);
+}
+
+/**
* Creates a snippet extract
*
* @author Andreas Gohr <andi@splitbrain.org>