r32852 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32851‎ | r32852 | r32853 >
Date:14:07, 6 April 2008
Author:tlaqua
Status:old
Tags:
Comment:
Checks search terms against the Category: namespace for Go 'jump to page' functionality
Modified paths:
  • /trunk/extensions/GoToCategory (added) (history)
  • /trunk/extensions/GoToCategory/GoToCategory.php (added) (history)

Diff [purge]

Index: trunk/extensions/GoToCategory/GoToCategory.php
@@ -0,0 +1,41 @@
 2+<?php
 3+/** \file
 4+* \brief Contains code for the GoToCategory extension
 5+*/
 6+
 7+# Not a valid entry point, skip unless MEDIAWIKI is defined
 8+if (!defined('MEDIAWIKI')) {
 9+ echo "GoToCategory extension";
 10+ exit(1);
 11+}
 12+
 13+$wgExtensionCredits['other'][] = array(
 14+ 'name' => 'GoToCategory',
 15+ 'version' => '1.0',
 16+ 'author' => 'Tim Laqua',
 17+ 'description' => "Checks search terms against the Category: namespace for Go 'jump to page' functionality",
 18+ 'url' => 'http://www.mediawiki.org/wiki/Extension:GoToCategory',
 19+);
 20+
 21+$wgExtensionFunctions[] = 'efGoToCategory_Setup';
 22+
 23+function efGoToCategory_Setup() {
 24+ global $wgHooks;
 25+ $wgHooks['SpecialSearchNogomatch'][] = 'efGoToCategory_SpecialSearchNogomatch';
 26+ return true;
 27+}
 28+
 29+function efGoToCategory_SpecialSearchNogomatch($t) {
 30+ global $wgOut, $wgRequest;
 31+
 32+ $term = $wgRequest->getText('search');
 33+ if( !empty( $term ) && strpos( 'category:', strtolower( $term ) ) !== 0 ) {
 34+ $term = "Category:{$term}";
 35+ }
 36+
 37+ $title = SearchEngine::getNearMatch( $term );
 38+ if( !is_null( $title ) ) {
 39+ $wgOut->redirect( $title->getFullURL() );
 40+ }
 41+ return true;
 42+}
\ No newline at end of file
Property changes on: trunk/extensions/GoToCategory/GoToCategory.php
___________________________________________________________________
Added: svn:eol-style
143 + native

Status & tagging log