Index: trunk/extensions/NamespacePaths/NamespacePaths.php |
— | — | @@ -35,21 +35,23 @@ |
36 | 36 | |
37 | 37 | $wgExtensionMessagesFiles['NamespacePaths'] = dirname( __FILE__ ) . '/NamespacePaths.i18n.php'; |
38 | 38 | |
39 | | -$wgHooks['WebRequestGetPathInfoRequestURI'][] = 'efNamepacePathsGetPathInfo'; |
| 39 | +$wgHooks['WebRequestPathInfoRouter'][] = 'efNamepacePathRouter'; |
40 | 40 | $wgHooks['GetLocalURL::Article'][] = 'efNamepacePathsGetURL'; |
41 | 41 | |
42 | | -function efNamepacePathsGetPathInfo( $path, &$matches ) { |
| 42 | +function efNamepacePathRouter( $router ) { |
43 | 43 | 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; |
52 | 49 | } |
53 | 50 | |
| 51 | +function efNamespacePathCallback( &$matches, $data ) { |
| 52 | + $nstext = MWNamespace::getCanonicalName( intval( $data['ns'] ) ); |
| 53 | + $matches['title'] = $nstext . ':' . $data['page_title']; |
| 54 | +} |
| 55 | + |
54 | 56 | function efNamepacePathsGetURL( $title, &$url ) { |
55 | 57 | global $wgNamespacePaths; |
56 | 58 | // Ensure that the context of this url is one we'd do article path replacements in |