From 5c9d4b56a22afa8f185b5f79f47bb7f2d2c85b21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Tue, 17 Jun 2008 08:08:59 +0000 Subject: [PATCH] * Second try at normalising special page titles, now at the linker * Normalises namespace and name to the content language of the wiki --- includes/Linker.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 9cf8790d44..142cc5db18 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -277,15 +277,17 @@ class Linker { * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead * @return the a-element */ - function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { + function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { wfProfileIn( __METHOD__ ); - if ( !$nt instanceof Title ) { + if ( !$title instanceof Title ) { # Fail gracefully wfProfileOut( __METHOD__ ); return "{$prefix}{$text}{$trail}"; } + $nt = $this->normaliseSpecialPage( $title ); + $u = $nt->escapeLocalURL( $query ); if ( $nt->getFragment() != '' ) { if( $nt->getPrefixedDbkey() == '' ) { @@ -321,15 +323,17 @@ class Linker { * be included in the link text. Other characters will be appended after * the end of the link. */ - function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) { wfProfileIn( __METHOD__ ); - if ( !$nt instanceof Title ) { + if ( !$title instanceof Title ) { # Fail gracefully wfProfileOut( __METHOD__ ); return "{$prefix}{$text}{$trail}"; } + $nt = $this->normaliseSpecialPage( $title ); + if( $nt->getNamespace() == NS_SPECIAL ) { $q = $query; } else if ( '' == $query ) { @@ -421,6 +425,16 @@ class Linker { return "{$prefix}{$text}{$inside}{$trail}"; } + function normaliseSpecialPage( Title $title ) { + if ( $title->getNamespace() == NS_SPECIAL ) { + list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() ); + if ( !$name ) return $title; + return SpecialPage::getTitleFor( $name, $subpage ); + } else { + return $title; + } + } + /** @todo document */ function fnamePart( $url ) { $basename = strrchr( $url, '/' ); -- 2.20.1