X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=a96bc5f34d8cb248e0b548abb28834a7e0c4341d;hb=32b58ee1181f3ee3f295f2099100ef4279116b03;hp=2f6ee22f773604fcc68f872595b02b34f2298e2f;hpb=0e5f53d262825e0859c609e47c56d94665d33e90;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Linker.php b/includes/Linker.php index 2f6ee22f77..a96bc5f34d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -33,7 +33,7 @@ class Linker { * Flags for userToolLinks() */ const TOOL_LINKS_NOBLOCK = 1; - const TOOL_LINKS_EMAIL = 2; + const TOOL_LINKS_EMAIL = 2; /** * Get the appropriate HTML attributes to add to the "a" element of an ex- @@ -600,9 +600,9 @@ class Linker { $prefix = $postfix = ''; if ( 'center' == $fp['align'] ) { - $prefix = '
'; + $prefix = '
'; $postfix = '
'; - $fp['align'] = 'none'; + $fp['align'] = 'none'; } if ( $file && !isset( $hp['width'] ) ) { if ( isset( $hp['height'] ) && $file->isVectorized() ) { @@ -724,7 +724,7 @@ class Linker { $extLinkAttrs = $parser->getExternalLinkAttribs( $frameParams['link-url'] ); foreach ( $extLinkAttrs as $name => $val ) { // Currently could include 'rel' and 'target' - $mtoParams['parser-extlink-'.$name] = $val; + $mtoParams['parser-extlink-' . $name] = $val; } } } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) { @@ -751,7 +751,7 @@ class Linker { * @return mixed */ public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt, - $align = 'right', $params = array(), $framed = false , $manualthumb = "" ) + $align = 'right', $params = array(), $framed = false, $manualthumb = "" ) { $frameParams = array( 'alt' => $alt, @@ -1028,7 +1028,7 @@ class Linker { $key = strtolower( $name ); } - return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMessage( $key )->text() ); + return self::linkKnown( SpecialPage::getTitleFor( $name ), wfMessage( $key )->text() ); } /** @@ -1038,9 +1038,11 @@ class Linker { * @param $escape Boolean: do we escape the link text? * @param $linktype String: type of external link. Gets added to the classes * @param $attribs Array of extra attributes to + * @param $title Title|null Title object used for title specific link attributes * @return string */ - public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) { + public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array(), $title = null ) { + global $wgTitle; $class = "external"; if ( $linktype ) { $class .= " $linktype"; @@ -1053,6 +1055,11 @@ class Linker { if ( $escape ) { $text = htmlspecialchars( $text ); } + + if ( !$title ) { + $title = $wgTitle; + } + $attribs['rel'] = Parser::getExternalLinkRel( $url, $title ); $link = ''; $success = wfRunHooks( 'LinkerMakeExternalLink', array( &$url, &$text, &$link, &$attribs, $linktype ) ); @@ -1665,11 +1672,10 @@ class Linker { $lang = wfGetLangObj( $lang ); $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped(); - return - '
' - . '

' . $title . "

\n" - . $toc - . "\n
\n"; + return '
' + . '

' . $title . "

\n" + . $toc + . "\n
\n"; } /** @@ -1927,13 +1933,13 @@ class Linker { * Make an HTML list of templates, and then add a "More..." link at * the bottom. If $more is null, do not add a "More..." link. If $more * is a Title, make a link to that title and use it. If $more is a string, - * directly paste it in as the link. + * directly paste it in as the link (escaping needs to be done manually). + * Finally, if $more is a Message, call toString(). * - * @param $templates Array of templates from Article::getUsedTemplate - * or similar + * @param array $templates Array of templates from Article::getUsedTemplate or similar * @param bool $preview Whether this is for a preview * @param bool $section Whether this is for a section edit - * @param Title|string|null $more A link for "More..." of the templates + * @param Title|Message|string|null $more An escaped link for "More..." of the templates * @return String: HTML output */ public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) { @@ -2068,7 +2074,7 @@ class Linker { # Compatibility: formerly some tooltips had [alt-.] hardcoded $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip ); # Message equal to '-' means suppress it. - if ( $tooltip == '-' ) { + if ( $tooltip == '-' ) { $tooltip = false; } } @@ -2150,17 +2156,17 @@ class Linker { // RevDelete links using revision ID are stable across // page deletion and undeletion; use when possible. $query = array( - 'type' => 'revision', + 'type' => 'revision', 'target' => $title->getPrefixedDBkey(), - 'ids' => $rev->getId() + 'ids' => $rev->getId() ); } else { // Older deleted entries didn't save a revision ID. // We have to refer to these by timestamp, ick! $query = array( - 'type' => 'archive', + 'type' => 'archive', 'target' => $title->getPrefixedDBkey(), - 'ids' => $rev->getTimestamp() + 'ids' => $rev->getTimestamp() ); } return Linker::revDeleteLink( $query, @@ -2280,7 +2286,7 @@ class Linker { * @return string the a-element */ static function makeKnownLinkObj( - $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' + $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = '' ) { wfDeprecated( __METHOD__, '1.21' );