From: <ru...@us...> - 2009-09-17 08:44:25
|
Revision: 7137 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7137&view=rev Author: rurban Date: 2009-09-17 08:44:13 +0000 (Thu, 17 Sep 2009) Log Message: ----------- new titleSearch option 16 for fallback if not found Modified Paths: -------------- trunk/lib/XmlRpcServer.php trunk/themes/default/templates/search.tmpl Modified: trunk/lib/XmlRpcServer.php =================================================================== --- trunk/lib/XmlRpcServer.php 2009-09-17 08:40:19 UTC (rev 7136) +++ trunk/lib/XmlRpcServer.php 2009-09-17 08:44:13 UTC (rev 7137) @@ -636,7 +636,7 @@ $wiki_dmap['titleSearch'] = array('signature' => array(array($xmlrpcArray, $xmlrpcString, $xmlrpcString)), 'documentation' => "Return matching pagenames. -Option 1: caseexact, 2: regex, 4: starts_with, 8: exact", +Option 1: caseexact, 2: regex, 4: starts_with, 8: exact, 16: fallback", 'function' => 'titleSearch'); function titleSearch($params) @@ -653,6 +653,7 @@ $case_exact = $option & 1; $regex = $option & 2; + $fallback = $option & 16; if (!$regex) { if ($option & 4) { // STARTS_WITH $regex = true; @@ -675,7 +676,17 @@ $pages = array(); while ($page = $iterator->next()) { $pages[] = short_string($page->getName()); - } + } + // On failure try again broader (substring + case inexact) + if ($fallback and empty($pages)) { + $query = new TextSearchQuery(short_string_decode($ParamPageName->scalarval()), false, + $regex ? 'auto' : 'none'); + $dbh = $request->getDbh(); + $iterator = $dbh->titleSearch($query); + while ($page = $iterator->next()) { + $pages[] = short_string($page->getName()); + } + } return new xmlrpcresp(new xmlrpcval($pages, "array")); } Modified: trunk/themes/default/templates/search.tmpl =================================================================== --- trunk/themes/default/templates/search.tmpl 2009-09-17 08:40:19 UTC (rev 7136) +++ trunk/themes/default/templates/search.tmpl 2009-09-17 08:44:13 UTC (rev 7137) @@ -20,7 +20,7 @@ class="dropdown" id="searchInput" title="<?=_("LiveSearch") . " [$p-f]"?>" style="width:115px;" acdropdown="true" autocomplete_complete="false" autocomplete_matchsubstring="false" - autocomplete_list="xmlrpc:wiki.titleSearch [S] 4<?= $request->getArg("start_debug") ? " debug" : "" ?>" /> + autocomplete_list="xmlrpc:wiki.titleSearch [S] 20<?= $request->getArg("start_debug") ? " debug" : "" ?>" /> <?php } elseif (ENABLE_LIVESEARCH) { ?> type="text" id="livesearch" title="<?=_("LiveSearch") . " [$p-f]"?>" onKeypress="liveSearchStart()" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |