+
+ # NS
+ if ( !$found ) {
+ # Check for NS: (namespace expansion)
+ $mwNs = MagicWord::get( MAG_NS );
+ if ( $mwNs->matchStartAndRemove( $text ) ) {
+ if ( intval( $text ) ) {
+ $text = $wgLang->getNsText( intval( $text ) );
+ $found = true;
+ } else {
+ $index = Namespace::getCanonicalIndex( strtolower( $text ) );
+ if ( !is_null( $index ) ) {
+ $text = $wgLang->getNsText( $index );
+ $found = true;
+ }
+ }
+ }
+ }
+
+ # LOCALURL and LOCALURLE
+ if ( !$found ) {
+ $mwLocal = MagicWord::get( MAG_LOCALURL );
+ $mwLocalE = MagicWord::get( MAG_LOCALURLE );
+
+ if ( $mwLocal->matchStartAndRemove( $text ) ) {
+ $func = 'getLocalURL';
+ } elseif ( $mwLocalE->matchStartAndRemove( $text ) ) {
+ $func = 'escapeLocalURL';
+ } else {
+ $func = '';
+ }
+
+ if ( $func !== '' ) {
+ $args = explode( "|", $text );
+ $n = count( $args );
+ if ( $n > 0 ) {
+ $title = Title::newFromText( $args[0] );
+ if ( !is_null( $title ) ) {
+ if ( $n > 1 ) {
+ $text = $title->$func( $args[1] );
+ } else {
+ $text = $title->$func();
+ }
+ $found = true;
+ }
+ }
+ }
+ }