X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=ac4bb99da86fdbbe64d0ad625e380a76f9ba39c4;hb=4741900b5edfd9022252580aa1008c570b2e224f;hp=1d327be628ec150e788d148791d609232e4c213e;hpb=44bf43baf7ced7ea61542fef72338fde5ae517cc;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Linker.php b/includes/Linker.php
index 1d327be628..ac4bb99da8 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -36,24 +36,11 @@ class Linker {
const TOOL_LINKS_NOBLOCK = 1;
const TOOL_LINKS_EMAIL = 2;
- /**
- * Get the appropriate HTML attributes to add to the "a" element of an
- * external link, as created by [wikisyntax].
- *
- * @param string $class The contents of the class attribute; if an empty
- * string is passed, which is the default value, defaults to 'external'.
- * @return string
- * @deprecated since 1.18 Just pass the external class directly to something
- * using Html::expandAttributes.
- */
- static function getExternalLinkAttributes( $class = 'external' ) {
- wfDeprecated( __METHOD__, '1.18' );
- return self::getLinkAttributesInternal( '', $class );
- }
-
/**
* Get the appropriate HTML attributes to add to the "a" element of an interwiki link.
*
+ * @deprecated since 1.25
+ *
* @param string $title The title text for the link, URL-encoded (???) but
* not HTML-escaped
* @param string $unused Unused
@@ -64,6 +51,8 @@ class Linker {
static function getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' ) {
global $wgContLang;
+ wfDeprecated( __METHOD__, '1.25' );
+
# @todo FIXME: We have a whole bunch of handling here that doesn't happen in
# getExternalLinkAttributes, why?
$title = urldecode( $title );
@@ -76,6 +65,8 @@ class Linker {
/**
* Get the appropriate HTML attributes to add to the "a" element of an internal link.
*
+ * @deprecated since 1.25
+ *
* @param string $title The title text for the link, URL-encoded (???) but
* not HTML-escaped
* @param string $unused Unused
@@ -83,6 +74,8 @@ class Linker {
* @return string
*/
static function getInternalLinkAttributes( $title, $unused = null, $class = '' ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
$title = urldecode( $title );
$title = str_replace( '_', ' ', $title );
return self::getLinkAttributesInternal( $title, $class );
@@ -92,6 +85,8 @@ class Linker {
* Get the appropriate HTML attributes to add to the "a" element of an internal
* link, given the Title object for the page we want to link to.
*
+ * @deprecated since 1.25
+ *
* @param Title $nt
* @param string $unused Unused
* @param string $class The contents of the class attribute, default none
@@ -100,6 +95,8 @@ class Linker {
* @return string
*/
static function getInternalLinkAttributesObj( $nt, $unused = null, $class = '', $title = false ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
if ( $title === false ) {
$title = $nt->getPrefixedText();
}
@@ -109,12 +106,16 @@ class Linker {
/**
* Common code for getLinkAttributesX functions
*
+ * @deprecated since 1.25
+ *
* @param string $title
* @param string $class
*
* @return string
*/
private static function getLinkAttributesInternal( $title, $class ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
$title = htmlspecialchars( $title );
$class = htmlspecialchars( $class );
$r = '';
@@ -208,8 +209,9 @@ class Linker {
$dummy = new DummyLinker; // dummy linker instance for bc on the hooks
$ret = null;
- if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
- &$customAttribs, &$query, &$options, &$ret ) ) ) {
+ if ( !Hooks::run( 'LinkBegin',
+ array( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) )
+ ) {
wfProfileOut( __METHOD__ );
return $ret;
}
@@ -219,7 +221,7 @@ class Linker {
# If we don't know whether the page exists, let's find out.
wfProfileIn( __METHOD__ . '-checkPageExistence' );
- if ( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
+ if ( !in_array( 'known', $options ) && !in_array( 'broken', $options ) ) {
if ( $target->isKnown() ) {
$options[] = 'known';
} else {
@@ -249,7 +251,7 @@ class Linker {
}
$ret = null;
- if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
+ if ( Hooks::run( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
$ret = Html::rawElement( 'a', $attribs, $html );
}
@@ -364,7 +366,7 @@ class Linker {
foreach ( $merged as $key => $val ) {
# A false value suppresses the attribute, and we don't want the
# href attribute to be overridden.
- if ( $key != 'href' and $val !== false ) {
+ if ( $key != 'href' && $val !== false ) {
$ret[$key] = $val;
}
}
@@ -409,7 +411,7 @@ class Linker {
*/
public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
$ret = "{$prefix}{$html}{$trail}";
- if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
+ if ( !Hooks::run( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
return $ret;
}
@@ -495,7 +497,7 @@ class Linker {
$alt = self::fnamePart( $url );
}
$img = '';
- $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
+ $success = Hooks::run( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
if ( !$success ) {
wfDebug( "Hook LinkerMakeExternalImage changed the output of external image "
. "with url {$url} and alt text {$alt} to {$img}\n", true );
@@ -549,7 +551,7 @@ class Linker {
) {
$res = null;
$dummy = new DummyLinker;
- if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
+ if ( !Hooks::run( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
&$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
return $res;
}
@@ -1029,7 +1031,7 @@ class Linker {
'title' => $alt
);
- if ( !wfRunHooks( 'LinkerMakeMediaLinkFile',
+ if ( !Hooks::run( 'LinkerMakeMediaLinkFile',
array( $title, $file, &$html, &$attribs, &$ret ) ) ) {
wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link "
. "with url {$url} and text {$html} to {$ret}\n", true );
@@ -1088,7 +1090,7 @@ class Linker {
}
$attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
$link = '';
- $success = wfRunHooks( 'LinkerMakeExternalLink',
+ $success = Hooks::run( 'LinkerMakeExternalLink',
array( &$url, &$text, &$link, &$attribs, $linktype ) );
if ( !$success ) {
wfDebug( "Hook LinkerMakeExternalLink changed the output of link "
@@ -1174,10 +1176,10 @@ class Linker {
$items[] = self::emailLink( $userId, $userText );
}
- wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
+ Hooks::run( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
if ( $items ) {
- return wfMessage( 'word-separator' )->plain()
+ return wfMessage( 'word-separator' )->escaped()
. ''
. wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
. '';
@@ -1264,7 +1266,7 @@ class Linker {
$userId = $rev->getUser( Revision::FOR_THIS_USER );
$userText = $rev->getUserText( Revision::FOR_THIS_USER );
$link = self::userLink( $userId, $userText )
- . wfMessage( 'word-separator' )->plain()
+ . wfMessage( 'word-separator' )->escaped()
. self::userToolLinks( $userId, $userText );
} else {
$link = wfMessage( 'rev-deleted-user' )->escaped();
@@ -1331,7 +1333,7 @@ class Linker {
$auto = $match[2];
$post = $match[3];
$comment = null;
- wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
+ Hooks::run( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
if ( $comment === null ) {
$link = '';
if ( $title ) {
@@ -1489,9 +1491,12 @@ class Linker {
# Foobar -- normal
# :Foobar -- override special treatment of prefix (images, language links)
# /Foobar -- convert to CurrentPage/Foobar
- # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial / from text
+ # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
# ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
- # ../Foobar -- convert to CurrentPage/Foobar, from CurrentPage/CurrentSubPage
+ # ../Foobar -- convert to CurrentPage/Foobar,
+ # (from CurrentPage/CurrentSubPage)
+ # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
+ # (from CurrentPage/CurrentSubPage)
wfProfileIn( __METHOD__ );
$ret = $target; # default return value is no change
@@ -1537,7 +1542,7 @@ class Linker {
$ret = implode( '/', array_slice( $exploded, 0, -$dotdotcount ) );
# / at the end means don't show full path
if ( substr( $nodotdot, -1, 1 ) === '/' ) {
- $nodotdot = substr( $nodotdot, 0, -1 );
+ $nodotdot = rtrim( $nodotdot, '/' );
if ( $text === '' ) {
$text = $nodotdot . $suffix;
}
@@ -1807,7 +1812,7 @@ class Linker {
$inner = self::buildRollbackLink( $rev, $context, $editCount );
if ( !in_array( 'noBrackets', $options ) ) {
- $inner = $context->msg( 'brackets' )->rawParams( $inner )->plain();
+ $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
}
return '' . $inner . '';
@@ -1892,7 +1897,7 @@ class Linker {
) {
global $wgShowRollbackEditCount, $wgMiserMode;
- // To config which pages are effected by miser mode
+ // To config which pages are affected by miser mode
$disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
if ( $context === null ) {