More use of Title::hasFragment
[lhc/web/wiklou.git] / includes / Linker.php
index f303a17..23bfd61 100644 (file)
@@ -159,9 +159,6 @@ class Linker {
         * link() replaces the old functions in the makeLink() family.
         *
         * @since 1.18 Method exists since 1.16 as non-static, made static in 1.18.
-        * You can call it using this if you want to keep compat with these:
-        * $linker = class_exists( 'DummyLinker' ) ? new DummyLinker() : new Linker();
-        * $linker->link( ... );
         *
         * @param $target        Title  Can currently only be a Title, but this may
         *   change to support Images, literal URLs, etc.
@@ -281,9 +278,9 @@ class Linker {
                wfProfileIn( __METHOD__ );
                # We don't want to include fragments for broken links, because they
                # generally make no sense.
-               if ( in_array( 'broken', $options ) && $target->mFragment !== '' ) {
+               if ( in_array( 'broken', $options ) && $target->hasFragment() ) {
                        $target = clone $target;
-                       $target->mFragment = '';
+                       $target->setFragment( '' );
                }
 
                # If it's a broken link, add the appropriate query pieces, unless
@@ -387,35 +384,12 @@ class Linker {
 
                // If the target is just a fragment, with no title, we return the fragment
                // text.  Otherwise, we return the title text itself.
-               if ( $target->getPrefixedText() === '' && $target->getFragment() !== '' ) {
+               if ( $target->getPrefixedText() === '' && $target->hasFragment() ) {
                        return htmlspecialchars( $target->getFragment() );
                }
                return htmlspecialchars( $target->getPrefixedText() );
        }
 
-       /**
-        * Generate either a normal exists-style link or a stub link, depending
-        * on the given page size.
-        *
-        * @param $size Integer
-        * @param $nt Title object.
-        * @param $text String
-        * @param $query String
-        * @param $trail String
-        * @param $prefix String
-        * @return string HTML of link
-        * @deprecated since 1.17
-        */
-       static function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               global $wgUser;
-               wfDeprecated( __METHOD__, '1.17' );
-
-               $threshold = $wgUser->getStubThreshold();
-               $colour = ( $size < $threshold ) ? 'stub' : '';
-               // @todo FIXME: Replace deprecated makeColouredLinkObj by link()
-               return self::makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
-       }
-
        /**
         * Make appropriate markup for a link to the current article. This is currently rendered
         * as the bold link text. The calling sequence is the same as the other make*LinkObj static functions,
@@ -474,8 +448,7 @@ class Linker {
                        if ( !$name ) {
                                return $title;
                        }
-                       $ret = SpecialPage::getTitleFor( $name, $subpage );
-                       $ret->mFragment = $title->getFragment();
+                       $ret = SpecialPage::getTitleFor( $name, $subpage, $title->getFragment() );
                        return $ret;
                } else {
                        return $title;
@@ -1469,7 +1442,7 @@ class Linker {
 
                        $target = Title::newFromText( $linkTarget );
                        if ( $target ) {
-                               if ( $target->getText() == '' && $target->getInterwiki() === ''
+                               if ( $target->getText() == '' && !$target->isExternal()
                                        && !self::$commentLocal && self::$commentContextTitle
                                ) {
                                        $newTarget = clone ( self::$commentContextTitle );
@@ -2160,7 +2133,8 @@ class Linker {
                }
 
                wfProfileOut( __METHOD__ );
-               return self::$accesskeycache[$name] = $accesskey;
+               self::$accesskeycache[$name] = $accesskey;
+               return self::$accesskeycache[$name];
        }
 
        /**
@@ -2243,32 +2217,6 @@ class Linker {
 
        /* Deprecated methods */
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * This function is a shortcut to makeBrokenLinkObj(Title::newFromText($title),...). Do not call
-        * it if you already have a title object handy. See makeBrokenLinkObj for further documentation.
-        *
-        * @param string $title The text of the title
-        * @param string $text Link text
-        * @param string $query Optional query part
-        * @param string $trail Optional trail. Alphabetic characters at the start of this string will
-        *               be included in the link text. Other characters will be appended after
-        *               the end of the link.
-        * @return string
-        */
-       static function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               $nt = Title::newFromText( $title );
-               if ( $nt instanceof Title ) {
-                       return self::makeBrokenLinkObj( $nt, $text, $query, $trail );
-               } else {
-                       wfDebug( 'Invalid title passed to self::makeBrokenLink(): "' . $title . "\"\n" );
-                       return $text == '' ? $title : $text;
-               }
-       }
-
        /**
         * @deprecated since 1.16 Use link(); warnings since 1.21
         *
@@ -2342,63 +2290,6 @@ class Linker {
                return $ret;
        }
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * Make a red link to the edit page of a given title.
-        *
-        * @param $title Title object of the target page
-        * @param $text  String: Link text
-        * @param string $query Optional query part
-        * @param string $trail Optional trail. Alphabetic characters at the start of this string will
-        *                      be included in the link text. Other characters will be appended after
-        *                      the end of the link.
-        * @param string $prefix Optional prefix
-        * @return string
-        */
-       static function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               wfProfileIn( __METHOD__ );
-
-               list( $inside, $trail ) = self::splitTrail( $trail );
-               if ( $text === '' ) {
-                       $text = self::linkText( $title );
-               }
-
-               $ret = self::link( $title, "$prefix$text$inside", array(),
-                       wfCgiToArray( $query ), 'broken' ) . $trail;
-
-               wfProfileOut( __METHOD__ );
-               return $ret;
-       }
-
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * Make a coloured link.
-        *
-        * @param $nt Title object of the target page
-        * @param $colour Integer: colour of the link
-        * @param $text   String:  link text
-        * @param $query  String:  optional query part
-        * @param $trail  String:  optional trail. Alphabetic characters at the start of this string will
-        *                      be included in the link text. Other characters will be appended after
-        *                      the end of the link.
-        * @param string $prefix Optional prefix
-        * @return string
-        */
-       static function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               if ( $colour != '' ) {
-                       $style = self::getInternalLinkAttributesObj( $nt, $text, $colour );
-               } else {
-                       $style = '';
-               }
-               return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
-       }
-
        /**
         * Returns the attributes for the tooltip and access key.
         * @return array