r90472 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90471‎ | r90472 | r90473 >
Date:17:54, 20 June 2011
Author:kipcool
Status:deferred
Tags:
Comment:
Hook so that the Go button searches by default in the Expression namespace
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php
@@ -1,5 +1,7 @@
22 <?php
33
 4+define( 'NS_EXPRESSION', 16 );
 5+
46 require_once( "Wikidata.php" );
57
68 // Ids
@@ -147,4 +149,25 @@
148150
149151
150152
 153+// Hook: The Go button should search (first) in the Expression namespace instead of Article namespace
 154+$wgHooks[ 'SearchGetNearMatchBefore' ][] = 'owGoClicked';
 155+
 156+function owGoClicked( $allSearchTerms, &$title ) {
 157+ $term = $allSearchTerms[0] ;
 158+ $title = Title::newFromText( $term ) ;
 159+ if ( is_null( $title ) ){
 160+ return true;
 161+ }
 162+
 163+ # Replace normal namespace with expression namespace
 164+ if ( $title->getNamespace() == NS_MAIN ) {
 165+ $title = Title::newFromText( $term, NS_EXPRESSION ) ; // $expressionNamespaceId ) ;
 166+ }
 167+
 168+ if ( $title->exists() ) {
 169+ return false; // match!
 170+ }
 171+ return true; // no match
 172+}
 173+
151174 ?>

Status & tagging log