Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / title / MediaWikiPageLinkRenderer.php
index 9ee4841..302c9e8 100644 (file)
@@ -62,14 +62,14 @@ class MediaWikiPageLinkRenderer implements PageLinkRenderer {
        /**
         * Returns the (partial) URL for the given page (including any section identifier).
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param array $params Any additional URL parameters.
         *
         * @return string
         */
-       public function getPageUrl( TitleValue $page, $params = array() ) {
-               //TODO: move the code from Linker::linkUrl here!
-               //The below is just a rough estimation!
+       public function getPageUrl( LinkTarget $page, $params = [] ) {
+               // TODO: move the code from Linker::linkUrl here!
+               // The below is just a rough estimation!
 
                $name = $this->formatter->getPrefixedText( $page );
                $name = str_replace( ' ', '_', $name );
@@ -93,20 +93,24 @@ class MediaWikiPageLinkRenderer implements PageLinkRenderer {
        /**
         * Returns an HTML link to the given page, using the given surface text.
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $linkTarget The link's target
         * @param string $text The link's surface text (will be derived from $page if not given).
         *
         * @return string
         */
-       public function renderHtmlLink( TitleValue $page, $text = null ) {
+       public function renderHtmlLink( LinkTarget $linkTarget, $text = null ) {
                if ( $text === null ) {
-                       $text = $this->formatter->getFullText( $page );
+                       $text = $this->formatter->getFullText( $linkTarget );
                }
 
                // TODO: move the logic implemented by Linker here,
                // using $this->formatter and $this->baseUrl, and
                // re-implement Linker to use a HtmlPageLinkRenderer.
-               $title = Title::newFromTitleValue( $page );
+               if ( $linkTarget instanceof Title ) {
+                       $title = $linkTarget;
+               } else {
+                       $title = Title::newFromLinkTarget( $linkTarget );
+               }
                $link = Linker::link( $title, htmlspecialchars( $text ) );
 
                return $link;
@@ -115,12 +119,12 @@ class MediaWikiPageLinkRenderer implements PageLinkRenderer {
        /**
         * Returns a wikitext link to the given page, using the given surface text.
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param string $text The link's surface text (will be derived from $page if not given).
         *
         * @return string
         */
-       public function renderWikitextLink( TitleValue $page, $text = null ) {
+       public function renderWikitextLink( LinkTarget $page, $text = null ) {
                if ( $text === null ) {
                        $text = $this->formatter->getFullText( $page );
                }