Dragan Espenschied has uploaded a new change for review.

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

Change subject: https://phabricator.wikimedia.org/T90492
......................................................................

https://phabricator.wikimedia.org/T90492

Introduces new config variable $wgWBRepoSettings['commonsSiteId'] to
point to a wiki that acts as the commons file repository
for the commons data type.

Requires https://github.com/wmde/ValueView/pull/159 on the frontend.

Change-Id: I34d5991cbb4f6b24b4978d62eb1d037518ef2bf1
---
M lib/includes/formatters/CommonsLinkFormatter.php
M lib/includes/modules/RepoAccessModule.php
M repo/config/Wikibase.example.php
3 files changed, 14 insertions(+), 1 deletion(-)


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

diff --git a/lib/includes/formatters/CommonsLinkFormatter.php 
b/lib/includes/formatters/CommonsLinkFormatter.php
index e4bbb7e..06d7b9a 100644
--- a/lib/includes/formatters/CommonsLinkFormatter.php
+++ b/lib/includes/formatters/CommonsLinkFormatter.php
@@ -9,6 +9,9 @@
 use ValueFormatters\FormatterOptions;
 use ValueFormatters\ValueFormatter;
 
+use Wikibase\Repo\WikibaseRepo as WikibaseRepo;
+use SiteSQLStore;
+
 /**
  * Formats a StringValue as an HTML link.
  *
@@ -57,8 +60,13 @@
                        return htmlspecialchars( $fileName );
                }
 
+               // Construct URL of the image in the selected commons wiki.
+               $commonsSiteId = 
WikibaseRepo::getDefaultInstance()->getSettings()->getSetting( 'commonsSiteId' 
);
+               $commonsSitePaths = SiteSQLStore::newInstance()->getSite( 
$commonsSiteId )->getAllPaths();
+               $href = str_replace('$1', 'File:'.$title->getPartialURL(),  
$commonsSitePaths['page_path']);
+
                $attributes = array_merge( $this->attributes, array(
-                       'href' => '//commons.wikimedia.org/wiki/File:' . 
$title->getPartialURL()
+                       'href' => $href
                ) );
                $html = Html::element( 'a', $attributes, $title->getText() );
 
diff --git a/lib/includes/modules/RepoAccessModule.php 
b/lib/includes/modules/RepoAccessModule.php
index fd9c9d6..17b34dc 100644
--- a/lib/includes/modules/RepoAccessModule.php
+++ b/lib/includes/modules/RepoAccessModule.php
@@ -48,6 +48,8 @@
                        );
                }
 
+               $wbRepo['commonsSiteId'] = $settings->getSetting( 
'commonsSiteId' );
+
                return Xml::encodeJsCall( 'mediaWiki.config.set', array( 
'wbRepo', $wbRepo ) );
        }
 }
diff --git a/repo/config/Wikibase.example.php b/repo/config/Wikibase.example.php
index ec2558c..79ff7ab 100644
--- a/repo/config/Wikibase.example.php
+++ b/repo/config/Wikibase.example.php
@@ -65,6 +65,9 @@
 
        // these are the site_group codes as listed in the sites table
        $wgWBRepoSettings['specialSiteLinkGroups'] = array( 'commons', 
'wikidata' );
+
+       // use wikimedia commons as the default file repo site:
+       $wgWBRepoSettings['commonsSiteId'] = 'commonswiki';
 } );
 
 /*

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I34d5991cbb4f6b24b4978d62eb1d037518ef2bf1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Dragan Espenschied <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to