Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/62801


Change subject: Get repolinker via WikibaseClient factory class
......................................................................

Get repolinker via WikibaseClient factory class

Change-Id: If56da909d087c7bf372ea2de0d15d6eb0d87739a
---
M client/WikibaseClient.hooks.php
M client/includes/WikibaseClient.php
M client/includes/recentchanges/ExternalChangesLine.php
3 files changed, 24 insertions(+), 61 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/01/62801/1

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index 47bcce9..edfbc2a 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -188,12 +188,7 @@
                );
 
                if ( $itemId !== false ) {
-                       $repoLinker = new RepoLinker(
-                               Settings::get( 'repoUrl' ),
-                               Settings::get( 'repoArticlePath' ),
-                               Settings::get( 'repoScriptPath' ),
-                               Settings::get( 'repoNamespaces' )
-                       );
+                       $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                        $itemByTitle = 'Special:ItemByTitle/' . $globalId . '/' 
. $oldTitle->getPrefixedDBkey();
                        $itemByTitleLink = $repoLinker->repoArticleUrl( 
$itemByTitle );
@@ -521,12 +516,7 @@
                                                return true;
                                        }
 
-                                       $repoLinker = new RepoLinker(
-                                               Settings::get( 'repoUrl' ),
-                                               Settings::get( 
'repoArticlePath' ),
-                                               Settings::get( 'repoScriptPath' 
),
-                                               Settings::get( 'repoNamespaces' 
)
-                                       );
+                                       $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                                        // links to the associated item on the 
repo
                                        $template->data['language_urls'][] = 
array(
diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index 27cfc1e..7550341 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -183,6 +183,19 @@
                );
        }
 
+       /**
+        * @since 0.4
+        *
+        * @return RepoLinker
+        */
+       public function newRepoLinker() {
+               return new RepoLinker(
+                       $this->settings->getSetting( 'repoUrl' ),
+                       $this->settings->getSetting( 'repoArticlePath' ),
+                       $this->settings->getSetting( 'repoScriptPath' ),
+                       $this->settings->getSetting( 'repoNamespaces' )
+               );
+       }
 
        /**
         * Returns an instance of the default store, or an alternate store
@@ -283,4 +296,4 @@
                return $instance;
        }
 
-}
\ No newline at end of file
+}
diff --git a/client/includes/recentchanges/ExternalChangesLine.php 
b/client/includes/recentchanges/ExternalChangesLine.php
index d135025..d897846 100644
--- a/client/includes/recentchanges/ExternalChangesLine.php
+++ b/client/includes/recentchanges/ExternalChangesLine.php
@@ -72,12 +72,7 @@
                $line = '';
 
                if ( in_array( $changeType, array( 'remove', 'restore' ) ) ) {
-                       $repoLinker = new RepoLinker(
-                               Settings::get( 'repoUrl' ),
-                               Settings::get( 'repoArticlePath' ),
-                               Settings::get( 'repoScriptPath' ),
-                               Settings::get( 'repoNamespaces' )
-                       );
+                       $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                        $deletionLog = $repoLinker->repoLink( 
'Special:Log/delete', wfMessage( 'dellogpage' )->text() );
                        $line .= wfMessage( 'parentheses' )->rawParams( 
$deletionLog );
@@ -222,12 +217,7 @@
         * @return string
         */
        protected static function diffLink( $titleText, $entityData, $rc ) {
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                return $repoLinker->repoLink(
                        null,
@@ -257,12 +247,7 @@
         * @return string
         */
        protected static function historyLink( $titleText, $entityData ) {
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                $link = $repoLinker->repoLink(
                        null,
@@ -309,12 +294,7 @@
         * @return string
         */
        protected static function userLink( $userName ) {
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                // @todo: localise this once namespaces are localised on the 
repo
                $link = "User:$userName";
@@ -340,12 +320,7 @@
                        $text = wfMessage( 'contribslink' );
                }
 
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                return $repoLinker->repoLink( $link, $text );
        }
@@ -358,12 +333,7 @@
         * @return string
         */
        protected static function userTalkLink( $userName ) {
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                // @todo: localize this once we can localize namespaces on the 
repo
                $link = "User_talk:$userName";
@@ -414,12 +384,7 @@
                        return false;
                }
 
-               $repoLinker = new RepoLinker(
-                       Settings::get( 'repoUrl' ),
-                       Settings::get( 'repoArticlePath' ),
-                       Settings::get( 'repoScriptPath' ),
-                       Settings::get( 'repoNamespaces' )
-               );
+               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                return $repoLinker->repoLink( $entityText, $entityId, array( 
'class' => 'wb-entity-link' ) );
        }
@@ -451,12 +416,7 @@
                        $titleText = strtoupper( $entityId->getPrefixedId() );
 
                        if ( $includeNamespace ) {
-                               $repoLinker = new RepoLinker(
-                                       Settings::get( 'repoUrl' ),
-                                       Settings::get( 'repoArticlePath' ),
-                                       Settings::get( 'repoScriptPath' ),
-                                       Settings::get( 'repoNamespaces' )
-                               );
+                               $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
                                $ns = $repoLinker->getNamespace( 
$entityId->getEntityType() );
                                if ( !empty( $ns ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/62801
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If56da909d087c7bf372ea2de0d15d6eb0d87739a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to