Aude has uploaded a new change for review.

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

Change subject: Add {{REPONAME}} magic word, remove references to Wikidata
......................................................................

Add {{REPONAME}} magic word, remove references to Wikidata

DEPLOY new magic word

Change-Id: Ide94af740194788fff9f15b1878af961d5e0ce06
---
M client/WikibaseClient.hooks.php
M client/WikibaseClient.i18n.magic.php
M client/WikibaseClient.i18n.php
M client/WikibaseClient.php
M client/config/WikibaseClient.default.php
M client/includes/recentchanges/RecentChangesFilterOptions.php
M client/tests/phpunit/includes/recentchanges/RecentChangesFilterOptionsTest.php
M docs/options.wiki
8 files changed, 85 insertions(+), 34 deletions(-)


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

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index d92fab2..452ba6b 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -1,4 +1,5 @@
 <?php
+
 namespace Wikibase;
 
 use Action;
@@ -596,7 +597,7 @@
        }
 
        /**
-        * Adds a toggle for showing/hiding Wikidata entries in recent changes
+        * Adds a toggle for showing/hiding Wikibase entries in recent changes
         *
         * @param SpecialRecentChanges $special
         * @param array &$filters
@@ -607,11 +608,38 @@
                $context = $special->getContext();
 
                if ( $context->getRequest()->getBool( 'enhanced', 
$context->getUser()->getOption( 'usenewrc' ) ) === false ) {
+                       // backwards compat
                        $showWikidata = $special->getUser()->getOption( 
'rcshowwikidata' );
-                       $default = $showWikidata ? false : true;
+                       $showWikibase = $special->getUser()->getOption( 
'rcshowwikibase' );
+
+                       $default = ( $showWikibase || $showWikidata );
+
                        if ( $context->getUser()->getOption( 'usenewrc' ) === 0 
) {
-                               $filters['hidewikidata'] = array( 'msg' => 
'wikibase-rc-hide-wikidata', 'default' => $default );
+                               $settings = 
WikibaseClient::getDefaultInstance()->getSettings();
+                               $repoName = $settings->getSetting( 
'repoSiteName' );
+
+                               $filters['hidewikibase'] = array(
+                                       'msg' => 'wikibase-rc-hide-wikibase',
+                                       'default' => $default
+                               );
                        }
+               }
+
+               return true;
+       }
+
+       /**
+        * @param User $user
+        * @param &$options $options
+        *
+        * @return boolean
+        */
+       public static function onUserLoadOptions( User $user, array &$options ) 
{
+               if ( !isset( $options['rcshowwikibase'] ) && isset( 
$options['rcshowwikidata'] ) ) {
+                       $options['rcshowwikibase'] = $options['rcshowwikidata'];
+
+                       // backwards compat
+                       $user->setOption( 'rcshowwikibase', 
$options['rcshowwikidata'] );
                }
 
                return true;
@@ -626,9 +654,12 @@
         * @return bool
         */
        public static function onGetPreferences( User $user, array &$prefs ) {
-               $prefs['rcshowwikidata'] = array(
+               $settings = WikibaseClient::getDefaultInstance()->getSettings();
+               $repoName = $settings->getSetting( 'repoSiteName' );
+
+               $prefs['rcshowwikibase'] = array(
                        'type' => 'toggle',
-                       'label-message' => 'wikibase-rc-show-wikidata-pref',
+                       'label-message' => array( 
'wikibase-rc-show-wikibase-pref', $repoName ),
                        'section' => 'rc/advancedrc',
                );
 
@@ -664,6 +695,8 @@
         */
        public static function onMagicWordwgVariableIDs( &$aCustomVariableIds ) 
{
                $aCustomVariableIds[] = 'noexternallanglinks';
+               $aCustomVariableIds[] = 'reponame';
+
                return true;
        }
 
@@ -671,8 +704,13 @@
         * Apply the magic word.
         */
        public static function onParserGetVariableValueSwitch( &$parser, 
&$cache, &$magicWordId, &$ret ) {
-               if( $magicWordId == 'noexternallanglinks' ) {
+               if ( $magicWordId == 'noexternallanglinks' ) {
                        NoLangLinkHandler::handle( $parser, '*' );
+               } elseif ( $magicWordId == 'reponame' ) {
+                       $wikibaseClient = WikibaseClient::getDefaultInstance();
+                       $settings = $wikibaseClient->getSettings();
+
+                       $ret = $settings->getSetting( 'repoSiteName' );
                }
 
                return true;
@@ -696,7 +734,7 @@
                        $user->getOption( 'usenewrc' ) ) === false ) {
                        // Allow toggling wikibase changes in case the enhanced 
watchlist is disabled
                        $filters['hideWikibase'] = array(
-                               'msg' => 'wikibase-rc-hide-wikidata',
+                               'msg' => 'wikibase-rc-hide-wikibase',
                                'default' => !$user->getBoolOption( 
'wlshowwikibase' )
                        );
                }
diff --git a/client/WikibaseClient.i18n.magic.php 
b/client/WikibaseClient.i18n.magic.php
index 283c634..95fff6b 100644
--- a/client/WikibaseClient.i18n.magic.php
+++ b/client/WikibaseClient.i18n.magic.php
@@ -14,6 +14,7 @@
 $magicWords['en'] = array(
        'noexternallanglinks' => array( 0, 'noexternallanglinks' ),
        'property' => array( 0, 'property' ),
+       'reponame' => array( 0, 'reponame' ),
 );
 
 /** Arabic (العربية) */
@@ -142,4 +143,4 @@
 $magicWords['zh-hant'] = array(
        'noexternallanglinks' => array( 0, '隱藏跨語言連結' ),
        'property' => array( 0, '屬性' ),
-);
\ No newline at end of file
+);
diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php
index 2ee3678..23ce0b8 100644
--- a/client/WikibaseClient.i18n.php
+++ b/client/WikibaseClient.i18n.php
@@ -20,17 +20,17 @@
  */
 $messages['en'] = array(
        'wikibase-client-desc' => 'Client for the Wikibase extension',
-       'specialpages-group-wikibaseclient' => 'Wikidata client',
+       'specialpages-group-wikibaseclient' => '{{REPONAME}} client',
        'tooltip-t-wikibase' => 'Link to connected data repository item',
        'accesskey-t-wikibase' => 'g',
-       'wikibase-after-page-move' => 'You may also [$1 update] the associated 
Wikidata item to maintain language links on moved page.',
-       'wikibase-after-page-move-queued' => 'The [$1 Wikidata item] associated 
with this page will be automatically updated soon.',
-       'wikibase-comment-add' => 'A Wikidata item has been created.',
-       'wikibase-comment-remove' => 'Associated Wikidata item deleted. 
Language links removed.',
-       'wikibase-comment-linked' => 'A Wikidata item has been linked to this 
page.',
-       'wikibase-comment-unlink' => 'This page has been unlinked from Wikidata 
item. Language links removed.',
-       'wikibase-comment-restore' => 'Associated Wikidata item undeleted. 
Language links restored.',
-       'wikibase-comment-update' => 'Wikidata item changed',
+       'wikibase-after-page-move' => 'You may also [$1 update] the associated 
{{REPONAME}} item to maintain language links on moved page.',
+       'wikibase-after-page-move-queued' => 'The [$1 {{REPONAME}} item] 
associated with this page will be automatically updated soon.',
+       'wikibase-comment-add' => 'A {{REPONAME}} item has been created.',
+       'wikibase-comment-remove' => 'Associated {{REPONAME}} item deleted. 
Language links removed.',
+       'wikibase-comment-linked' => 'A {{REPONAME}} item has been linked to 
this page.',
+       'wikibase-comment-unlink' => 'This page has been unlinked from 
{{REPONAME}} item. Language links removed.',
+       'wikibase-comment-restore' => 'Associated {{REPONAME}} item undeleted. 
Language links restored.',
+       'wikibase-comment-update' => '{{REPONAME}} item changed',
        'wikibase-comment-sitelink-add' => 'Language link added: $1',
        'wikibase-comment-sitelink-change' => 'Language link changed from $1 to 
$2',
        'wikibase-comment-sitelink-remove' => 'Language link removed: $1',
@@ -54,13 +54,13 @@
        'wikibase-linkitem-success-link' => 'The pages have successfully been 
linked. You can find the item containing the links in our [$1 central data 
repository].',
        'wikibase-property-notfound' => '$1 property not found.',
        'wikibase-property-notsupportedyet' => 'Wikibase does not yet support 
property type for $1 property.',
-       'wikibase-rc-hide-wikidata' => '$1 Wikidata',
-       'wikibase-rc-hide-wikidata-hide' => 'Hide',
-       'wikibase-rc-hide-wikidata-show' => 'Show',
-       'wikibase-rc-show-wikidata-pref' => 'Show Wikidata edits in recent 
changes',
+       'wikibase-rc-hide-wikibase' => '$1 {{REPONAME}}',
+       'wikibase-rc-hide-wikibase-hide' => 'Hide',
+       'wikibase-rc-hide-wikibase-show' => 'Show',
+       'wikibase-rc-show-wikibase-pref' => 'Show {{REPONAME}} edits in recent 
changes',
        'wikibase-rc-wikibase-edit-letter' => 'D',
-       'wikibase-rc-wikibase-edit-title' => 'Wikidata edit',
-       'wikibase-watchlist-show-changes-pref' => 'Show Wikidata edits in your 
watchlist',
+       'wikibase-rc-wikibase-edit-title' => '{{REPONAME}} edit',
+       'wikibase-watchlist-show-changes-pref' => 'Show {{REPONAME}} edits in 
your watchlist',
        'wikibase-error-serialize-error' => 'Failed to serialize data.',
        'wikibase-error-invalid-entity-id' => 'The ID entered is unknown to the 
system. Please use a valid entity ID.',
        'special-unconnectedpages' => 'Pages not connected to items',
@@ -71,7 +71,7 @@
        'wikibase-unconnectedpages-page-warning' => 'The page title could not 
be used for the query and is ignored.',
        'wikibase-unconnectedpages-iwdata-label' => 'Only pages with 
interlanguage links',
        'wikibase-unconnectedpages-format-row' => '($1 
{{PLURAL:$1|interlanguage link|interlanguage links}} on the page)',
-       'wikibase-pageinfo-entity-id' => 'Wikidata Item ID',
+       'wikibase-pageinfo-entity-id' => '{{REPONAME}} Item ID',
        'wikibase-pageinfo-entity-id-none' => 'None',
        'wikibase-property-render-error' => 'Failed to render property $1: $2'
 );
diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php
index a898993..6e30b3c 100644
--- a/client/WikibaseClient.php
+++ b/client/WikibaseClient.php
@@ -81,6 +81,7 @@
        $wgHooks['SpecialRecentChangesQuery'][]                         = 
'\Wikibase\ClientHooks::onSpecialRecentChangesQuery';
        $wgHooks['SpecialRecentChangesFilters'][]                       = 
'\Wikibase\ClientHooks::onSpecialRecentChangesFilters';
        $wgHooks['GetPreferences'][]                                            
= '\Wikibase\ClientHooks::onGetPreferences';
+       $wgHooks['UserLoadOptions'][]                           = 
'Wikibase\ClientHooks::onUserLoadOptions';
        $wgHooks['BeforePageDisplay'][]                         = 
'\Wikibase\ClientHooks::onBeforePageDisplay';
        $wgHooks['BeforePageDisplay'][]             = 
'\Wikibase\ClientHooks::onBeforePageDisplayAddJsConfig';
        $wgHooks['ScribuntoExternalLibraries'][]      = 
'\Wikibase\ClientHooks::onScribuntoExternalLibraries';
diff --git a/client/config/WikibaseClient.default.php 
b/client/config/WikibaseClient.default.php
index 488b3c3..396d606 100644
--- a/client/config/WikibaseClient.default.php
+++ b/client/config/WikibaseClient.default.php
@@ -16,7 +16,7 @@
  */
 
 return call_user_func( function() {
-       global $wgLanguageCode, $wgDBname;
+       global $wgLanguageCode, $wgDBname, $wgSitename;
 
        $defaults = array(
                'namespaces' => array(), // by default, include all namespaces; 
deprecated as of 0.4
@@ -179,6 +179,11 @@
                return defined( 'WB_VERSION' );
        };
 
+       $defaults['repoSiteName'] = function ( SettingsArray $settings ) {
+               // use $wgSitename if this wiki is the repo
+               return $settings->getSetting( 'thisWikiIsTheRepo' ) ? 
$GLOBALS['wgSitename'] : 'Wikidata';
+       };
+
        $defaults['repoUrl'] = function ( SettingsArray $settings ) {
                // use $wgServer if this wiki is the repo, otherwise default to 
wikidata.org
                return $settings->getSetting( 'thisWikiIsTheRepo' ) ? 
$GLOBALS['wgServer'] : '//www.wikidata.org';
diff --git a/client/includes/recentchanges/RecentChangesFilterOptions.php 
b/client/includes/recentchanges/RecentChangesFilterOptions.php
index b5facbd..6fe1d22 100644
--- a/client/includes/recentchanges/RecentChangesFilterOptions.php
+++ b/client/includes/recentchanges/RecentChangesFilterOptions.php
@@ -1,6 +1,8 @@
 <?php
 
 namespace Wikibase;
+
+use FormOptions;
 use Wikibase\Client\WikibaseClient;
 
 /**
@@ -14,7 +16,7 @@
 
        protected $opts;
 
-       public function __construct( \FormOptions $opts ) {
+       public function __construct( FormOptions $opts ) {
                $this->opts = $opts;
        }
 
@@ -38,18 +40,19 @@
        }
 
        /**
-        * Is hidewikidata filter selected?
+        * Is hidewikibase filter selected?
         *
         * @since 0.4
         *
         * @return bool
         */
        protected function hideWikibase() {
-               // @TODO: Remve naming inconsistency (hideWikibase <> 
hideWikidata)
-               if ( isset( $this->opts['hidewikidata'] ) && 
$this->opts['hidewikidata'] === true ) {
-                       return true;
-               }
-               return false;
+               // backwards compat
+               $hideWikidata = isset( $this->opts['hidewikidata'] ) && 
$this->opts['hidewikidata'] === true;
+
+               $hideWikibase = isset( $this->opts['hidewikibase'] ) && 
$this->opts['hidewikibase'] === true;
+
+               return ( $hideWikibase || $hideWikidata );
        }
 
        /**
diff --git 
a/client/tests/phpunit/includes/recentchanges/RecentChangesFilterOptionsTest.php
 
b/client/tests/phpunit/includes/recentchanges/RecentChangesFilterOptionsTest.php
index aa010a9..667caeb 100644
--- 
a/client/tests/phpunit/includes/recentchanges/RecentChangesFilterOptionsTest.php
+++ 
b/client/tests/phpunit/includes/recentchanges/RecentChangesFilterOptionsTest.php
@@ -18,6 +18,7 @@
  * @author Marius Hoch < h...@online.de >
  */
 class RecentChangesFilterOptionsTest extends \MediaWikiTestCase {
+
        /**
         * @dataProvider provideShowWikibaseEdits
         *
@@ -45,8 +46,9 @@
 
        public function provideShowWikibaseEdits() {
                return array(
+                       // hidewikibase is false, but showExternalRecentChanges 
is true
                        array( true, true, false ),
-                       // hidewikidata set
+                       // hidewikibase set to true
                        array( false, true, true ),
                        // showExternalRecentChanges is false
                        array( false, false, false ),
@@ -54,4 +56,4 @@
                        array( false, false, true ),
                );
        }
-}
\ No newline at end of file
+}
diff --git a/docs/options.wiki b/docs/options.wiki
index 5c5fc9c..eaf6f57 100644
--- a/docs/options.wiki
+++ b/docs/options.wiki
@@ -82,6 +82,7 @@
 ;siteLocalID: This site's local ID resp. language code (e.g. 
<code>'it'</code>). Default: <code>$wgLanguageCode</code>. '''Note:''' this 
setting will be removed once we can take this information from the sites table.
 ;siteGroup: This site's site group (e.g. <code>'wikipedia'</code> or 
<code>'wikivoyage'</code>) as used in the sites table. The setting is optional 
and falls back to site store lookup. For performance reasons, it may be 
desireable to set this explicitly to avoid lookups.
 ;repoSiteId: Site id of connected repository wiki. Default is to assume client 
and repo, so this setting defaults to siteGlobalID.
+;repoSiteName: Site name of the connected repository wiki.  Default is to 
assume client and repo are same wiki, so defaults to global $wgSitename 
setting.  If not the same wiki, defaults to 'Wikidata'.
 ;repoDatabase: The logical name of the repository database, in a form that 
LBFactory can understand. If not <code>null</code>, the client wiki will access 
the repository's database directly, instead of locally caching information 
received via change notifications. Default: <node>null</code>. Note that 
<code>false</code> would mean "this wiki's database"! '''Note:''' this is 
currently required to be not <code>null</code>, since local caching is not 
fully implemented.
        // default for repo items in main namespace
 ;repoNamespaces: An array telling the client wiki which namespaces on the 
repository are used for which kind of entity. This is given as an associative 
array mapping entity type IDs such as Item::ENTITY_TYPE, to namespace names. 
This information is used when constructing links to entities on the repository. 
Default:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide94af740194788fff9f15b1878af961d5e0ce06
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