Merge "Fix documentation in Linker::formatTemplates."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 20 Feb 2013 15:39:55 +0000 (15:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 20 Feb 2013 15:39:55 +0000 (15:39 +0000)
1  2 
includes/Linker.php

diff --combined includes/Linker.php
@@@ -33,7 -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-
                $prefix = $postfix = '';
  
                if ( 'center' == $fp['align'] ) {
 -                      $prefix  = '<div class="center">';
 +                      $prefix = '<div class="center">';
                        $postfix = '</div>';
 -                      $fp['align']   = 'none';
 +                      $fp['align'] = 'none';
                }
                if ( $file && !isset( $hp['width'] ) ) {
                        if ( isset( $hp['height'] ) && $file->isVectorized() ) {
                                $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'] !== '' ) {
         * @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,
                        $key = strtolower( $name );
                }
  
 -              return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMessage( $key )->text() );
 +              return self::linkKnown( SpecialPage::getTitleFor( $name ), wfMessage( $key )->text() );
        }
  
        /**
         * @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 <a>
 +       * @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";
                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 ) );
                $lang = wfGetLangObj( $lang );
                $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
  
 -              return
 -                 '<table id="toc" class="toc"><tr><td>'
 -               . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
 -               . $toc
 -               . "</ul>\n</td></tr></table>\n";
 +              return '<table id="toc" class="toc"><tr><td>'
 +                      . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
 +                      . $toc
 +                      . "</ul>\n</td></tr></table>\n";
        }
  
        /**
         * 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 ) {
                        # Compatibility: formerly some tooltips had [alt-.] hardcoded
                        $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
                        # Message equal to '-' means suppress it.
 -                      if (  $tooltip == '-' ) {
 +                      if ( $tooltip == '-' ) {
                                $tooltip = false;
                        }
                }
                                // 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,
         * @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' );