Index: trunk/extensions/NamespacePaths/NamespacePaths.i18n.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for NamespacePaths extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Daniel Friesen |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'namespacepaths-desc' => 'Allows custom article paths to be mapped to namespaces of the wiki. Eg: Mapping pages like Help:A to /help/Page instead of /wiki/Help:Page.', |
| 17 | +); |
| 18 | + |
Property changes on: trunk/extensions/NamespacePaths/NamespacePaths.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/extensions/NamespacePaths/NamespacePaths.php |
— | — | @@ -0,0 +1,65 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Copyright 2010 Daniel Friesen |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + * |
| 11 | + * This program is free software; you can redistribute it and/or |
| 12 | + * modify it under the terms of the GNU General Public License |
| 13 | + * as published by the Free Software Foundation; either version 2 |
| 14 | + * of the License, or (at your option) any later version. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License |
| 22 | + * along with this program; if not, write to the Free Software |
| 23 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 24 | + */ |
| 25 | + |
| 26 | +if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." ); |
| 27 | + |
| 28 | +$wgExtensionCredits['other'][] = array( |
| 29 | + 'path' => __FILE__, |
| 30 | + 'name' => 'NamespacePaths', |
| 31 | + 'version' => '1.0', |
| 32 | + 'author' => array( '[http://mediawiki.org/wiki/User:Dantman Daniel Friesen]', '[http://redwerks.org/mediawiki/ Redwerks]' ), |
| 33 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:NamespacePaths', |
| 34 | + 'descriptionmsg' => 'namespacepaths-desc', |
| 35 | +); |
| 36 | + |
| 37 | +$wgExtensionMessagesFiles['NamespacePaths'] = dirname( __FILE__ ) . '/NamespacePaths.i18n.php'; |
| 38 | + |
| 39 | +$wgHooks['WebRequestGetPathInfoRequestURI'][] = 'efNamepacePathsGetPathInfo'; |
| 40 | +$wgHooks['GetLocalURL::Article'][] = 'efNamepacePathsGetURL'; |
| 41 | + |
| 42 | +function efNamepacePathsGetPathInfo( $path, &$matches ) { |
| 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; |
| 52 | +} |
| 53 | + |
| 54 | +function efNamepacePathsGetURL( $title, &$url ) { |
| 55 | + global $wgNamespacePaths; |
| 56 | + // Ensure that the context of this url is one we'd do article path replacements in |
| 57 | + $ns = $title->getNamespace(); |
| 58 | + if ( array_key_exists( $ns, $wgNamespacePaths ) ) { |
| 59 | + $url = str_replace( '$1', wfUrlencode( $title->getDBkey() ), $wgNamespacePaths[$ns] ); |
| 60 | + } |
| 61 | + return true; |
| 62 | +} |
| 63 | + |
| 64 | +/** Settings **/ |
| 65 | +$wgNamespacePaths = array(); |
| 66 | + |
Property changes on: trunk/extensions/NamespacePaths/NamespacePaths.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 67 | + native |