Merge "Move wgContLang from config to injectable"
[lhc/web/wiklou.git] / includes / Title.php
index 3fd4631..7887890 100644 (file)
@@ -21,6 +21,7 @@
  *
  * @file
  */
+use MediaWiki\Linker\LinkTarget;
 
 /**
  * Represents a title within MediaWiki.
@@ -255,7 +256,9 @@ class Title implements LinkTarget {
                return self::makeTitle(
                        $linkTarget->getNamespace(),
                        $linkTarget->getText(),
-                       $linkTarget->getFragment() );
+                       $linkTarget->getFragment(),
+                       $linkTarget->getInterwiki()
+               );
        }
 
        /**
@@ -870,7 +873,9 @@ class Title implements LinkTarget {
                                $this->mTitleValue = new TitleValue(
                                        $this->getNamespace(),
                                        $this->getDBkey(),
-                                       $this->getFragment() );
+                                       $this->getFragment(),
+                                       $this->getInterwiki()
+                               );
                        } catch ( InvalidArgumentException $ex ) {
                                wfDebug( __METHOD__ . ': Can\'t create a TitleValue for [[' .
                                        $this->getPrefixedText() . ']]: ' . $ex->getMessage() . "\n" );
@@ -1376,7 +1381,8 @@ class Title implements LinkTarget {
         * specified fragment before setting, so it assumes you're passing it with
         * an initial "#".
         *
-        * Deprecated for public use, use Title::makeTitle() with fragment parameter.
+        * Deprecated for public use, use Title::makeTitle() with fragment parameter,
+        * or Title::createFragmentTarget().
         * Still in active use privately.
         *
         * @private
@@ -1386,6 +1392,23 @@ class Title implements LinkTarget {
                $this->mFragment = strtr( substr( $fragment, 1 ), '_', ' ' );
        }
 
+       /**
+        * Creates a new Title for a different fragment of the same page.
+        *
+        * @since 1.27
+        * @param string $fragment
+        * @return Title
+        */
+       public function createFragmentTarget( $fragment ) {
+               return self::makeTitle(
+                       $this->getNamespace(),
+                       $this->getText(),
+                       $fragment,
+                       $this->getInterwiki()
+               );
+
+       }
+
        /**
         * Prefix some arbitrary text with the namespace or interwiki prefix
         * of this object