Jeroen De Dauw has submitted this change and it was merged.
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, 25 insertions(+), 61 deletions(-)
Approvals:
Jeroen De Dauw: Looks good to me, approved
jenkins-bot: Verified
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..70e4413 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -15,6 +15,7 @@
use Wikibase\Lib\PropertyDataTypeLookup;
use Wikibase\Lib\SnakFormatter;
use Wikibase\Lib\TypedValueFormatter;
+use Wikibase\RepoLinker;
use Wikibase\Settings;
use Wikibase\SettingsArray;
use Wikibase\Test\MockRepository;
@@ -183,6 +184,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 +297,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: merged
Gerrit-Change-Id: If56da909d087c7bf372ea2de0d15d6eb0d87739a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits