r104286 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104285‎ | r104286 | r104287 >
Date:17:44, 26 November 2011
Author:dantman
Status:deferred
Tags:
Comment:
Update NamespacePaths to use the new PathRouter code.
Modified paths:
  • /trunk/extensions/NamespacePaths/NamespacePaths.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NamespacePaths/NamespacePaths.php
@@ -35,21 +35,23 @@
3636
3737 $wgExtensionMessagesFiles['NamespacePaths'] = dirname( __FILE__ ) . '/NamespacePaths.i18n.php';
3838
39 -$wgHooks['WebRequestGetPathInfoRequestURI'][] = 'efNamepacePathsGetPathInfo';
 39+$wgHooks['WebRequestPathInfoRouter'][] = 'efNamepacePathRouter';
4040 $wgHooks['GetLocalURL::Article'][] = 'efNamepacePathsGetURL';
4141
42 -function efNamepacePathsGetPathInfo( $path, &$matches ) {
 42+function efNamepacePathRouter( $router ) {
4343 global $wgNamespacePaths;
44 - if ( !$matches && $wgNamespacePaths ) {
45 - $matches = WebRequest::extractTitle( $path, $wgNamespacePaths, ' namespace' );
46 - if ( $matches ) {
47 - $matches['title'] = MWNamespace::getCanonicalName( $matches[' namespace'] ) . ':' . $matches['title'];
48 - unset($matches[' namespace']);
49 - }
50 - }
51 - return !$matches;
 44+ $router->add( $wgNamespacePaths,
 45+ array( 'data:page_title' => '$1', 'data:ns' => '$key' ),
 46+ array( 'callback' => 'efNamespacePathCallback' )
 47+ );
 48+ return true;
5249 }
5350
 51+function efNamespacePathCallback( &$matches, $data ) {
 52+ $nstext = MWNamespace::getCanonicalName( intval( $data['ns'] ) );
 53+ $matches['title'] = $nstext . ':' . $data['page_title'];
 54+}
 55+
5456 function efNamepacePathsGetURL( $title, &$url ) {
5557 global $wgNamespacePaths;
5658 // Ensure that the context of this url is one we'd do article path replacements in

Status & tagging log