From b0f6db0c1350beb85dcff044dc2770f404a1b540 Mon Sep 17 00:00:00 2001 From: Adrian Lang <lang@cosmocode.de> Date: Wed, 23 Jun 2010 14:24:11 +0200 Subject: [PATCH] Support namespace selection in quicksearch --- inc/fulltext.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/fulltext.php b/inc/fulltext.php index b6aac5c91..950e7f7d3 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -229,7 +229,13 @@ function ft_pageLookup($id, $not_in_ns=true, $not_in_title=true){ function _ft_pageLookup(&$data){ // split out original parameters + $id = $data['id']; + if (preg_match('/(?:^| )@(\w+)/', $id, $matches)) { + $ns = cleanID($matches[1]) . ':'; + $id = str_replace($matches[0], '', $id); + } + $in_ns = !$data['not_in_ns']; $in_title = !$data['not_in_title']; @@ -241,8 +247,9 @@ function _ft_pageLookup(&$data){ $cleaned = cleanID($id); $matched_pages = array(); foreach ($pages as $p_id => $p_title) { - if ((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false) || - ($in_title && stripos($p_title, $id) !== false)) { + if (((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false) || + ($in_title && stripos($p_title, $id) !== false)) && + (!isset($ns) || strpos($p_id, $ns) === 0)) { $matched_pages[$p_id] = $p_title; } } -- GitLab