summaryrefslogtreecommitdiff
path: root/lib/exe/ajax.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-06-26 13:38:10 +0200
committerAndreas Gohr <andi@splitbrain.org>2010-06-26 13:42:11 +0200
commit8d22f1e96be5aa2c65ecb6ee934debbfe0f8f4cc (patch)
tree1d582c848d55a3f49b715049264550e9ee3c04d0 /lib/exe/ajax.php
parenta992042bb4cc85fc90ec35a868ed14b3a3bfd7b7 (diff)
downloadrpg-8d22f1e96be5aa2c65ecb6ee934debbfe0f8f4cc.tar.gz
rpg-8d22f1e96be5aa2c65ecb6ee934debbfe0f8f4cc.tar.bz2
Changes to the ft_pageLookup and related event FS#1978
This patch changes the ft_pageLookup function to always return the title of pages with the result. This makes it easier to work with the array, as it no longer changes between numeric and key indexes depending on useheading. This also means that action plugins subscribed to SEARCH_QUERY_PAGELOOKUP need to be adjusted. The event contains a new data field called 'has_titles' which plugins can use to check for backwards compatibility.
Diffstat (limited to 'lib/exe/ajax.php')
-rw-r--r--lib/exe/ajax.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 9c10ca548..8b03bb07c 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -54,7 +54,7 @@ function ajax_qsearch(){
if(empty($query)) $query = $_GET['q'];
if(empty($query)) return;
- $data = ft_pageLookup($query, true, false);
+ $data = ft_pageLookup($query, true, useHeading('navigation'));
if(!count($data)) return;
@@ -93,6 +93,7 @@ function ajax_suggestions() {
$data = array();
$data = ft_pageLookup($query);
if(!count($data)) return;
+ $data = array_keys($data);
// limit results to 15 hits
$data = array_slice($data, 0, 15);
@@ -252,26 +253,27 @@ function ajax_linkwiz(){
// use index to lookup matching pages
$pages = array();
- $pages = ft_pageLookup($id,false);
+ $pages = ft_pageLookup($id,true);
// result contains matches in pages and namespaces
// we now extract the matching namespaces to show
// them seperately
$dirs = array();
- $count = count($pages);
- for($i=0; $i<$count; $i++){
- if(strpos(noNS($pages[$i]),$id) === false){
+
+
+ foreach($pages as $pid => $title){
+ if(strpos(noNS($pid),$id) === false){
// match was in the namespace
- $dirs[getNS($pages[$i])] = 1; // assoc array avoids dupes
+ $dirs[getNS($pid)] = 1; // assoc array avoids dupes
}else{
// it is a matching page, add it to the result
$data[] = array(
- 'id' => $pages[$i],
- 'title' => p_get_first_heading($pages[$i],false),
+ 'id' => $pid,
+ 'title' => $title,
'type' => 'f',
);
}
- unset($pages[$i]);
+ unset($pages[$pid]);
}
foreach($dirs as $dir => $junk){
$data[] = array(