Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +define( 'NS_EXPRESSION', 16 ); |
| 5 | + |
4 | 6 | require_once( "Wikidata.php" ); |
5 | 7 | |
6 | 8 | // Ids |
— | — | @@ -147,4 +149,25 @@ |
148 | 150 | |
149 | 151 | |
150 | 152 | |
| 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 | + |
151 | 174 | ?> |