Aude has uploaded a new change for review.

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


Change subject: (bug 49105) Add toolbox link and js config var for connected 
wikibase item
......................................................................

(bug 49105) Add toolbox link and js config var for connected wikibase item

Change-Id: I57e11712f0551931e439085299a4f18f03c5e32b
---
M client/WikibaseClient.hooks.php
M client/WikibaseClient.i18n.php
M client/WikibaseClient.php
3 files changed, 62 insertions(+), 0 deletions(-)


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

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index b238502..6a40852 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -400,6 +400,56 @@
        }
 
        /**
+        * Add Wikibase item link in toolbox
+        *
+        * @since 0.4
+        *
+        * @param SkinTemplate &$sk
+        * @param array &$toolbox
+        *
+        * @return boolean
+        */
+       public static function onBaseTemplateToolbox( &$sk, &$toolbox ) {
+               $prefixedId = $sk->getSkin()->getOutput()->getProperty( 
'wikibase_item' );
+
+               if ( $prefixedId !== null ) {
+                       $entityIdParser = 
WikibaseClient::getDefaultInstance()->getEntityIdParser();
+                       $entityId = $entityIdParser->parse( $prefixedId );
+
+                       $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
+                       $itemLink = $repoLinker->repoItemUrl( $entityId );
+
+                       $toolbox['wikibase'] = array(
+                               'text' => $sk->getMsg( 'wikibase-dataitem' 
)->text(),
+                               'href' => $itemLink,
+                               'id' => 't-wikibase'
+                       );
+               }
+
+               return true;
+       }
+
+       /**
+        * Add the connected item prefixed id as a JS config variable, for 
gadgets etc.
+        *
+        * @param \OutputPage &$out
+        * @param \Skin &$skin
+        *
+        * @since 0.4
+        *
+        * @return bool
+        */
+       public static function onBeforePageDisplayAddJsConfig( \OutputPage 
&$out, \Skin &$skin ) {
+               $prefixedId = $out->getProperty( 'wikibase_item' );
+
+               if ( $prefixedId !== null ) {
+                       $out->addJsConfigVars( 'wgWikibaseItemId', $prefixedId 
);
+               }
+
+               return true;
+       }
+
+       /**
         * Adds css for the edit links sidebar link or JS to create a new item
         * or to link with an existing one.
         *
@@ -413,6 +463,12 @@
        public static function onBeforePageDisplay( \OutputPage &$out, \Skin 
&$skin ) {
                wfProfileIn( __METHOD__ );
 
+               $prefixedId = $out->getProperty( 'wikibase_item' );
+
+               if ( $prefixedId !== null ) {
+                       $out->addJsConfigVars( 'wgWikibaseItemId', $prefixedId 
);
+               }
+
                $title = $out->getTitle();
                $user = $skin->getContext()->getUser();
 
diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php
index 43c78c3..0a8813c 100644
--- a/client/WikibaseClient.i18n.php
+++ b/client/WikibaseClient.i18n.php
@@ -23,6 +23,7 @@
 $messages['en'] = array(
        'wikibase-client-desc' => 'Client for the Wikibase extension',
        'specialpages-group-wikibaseclient' => 'Wikidata client',
+       'tooltip-t-wikibase' => 'Link to connected data repository item',
        'wikibase-after-page-move' => 'You may also [$1 update] the associated 
Wikidata item to maintain language links on moved page.',
        'wikibase-comment-remove' => 'Associated Wikidata item deleted. 
Language links removed.',
        'wikibase-comment-linked' => 'A Wikidata item has been linked to this 
page.',
@@ -33,6 +34,7 @@
        'wikibase-comment-sitelink-change' => 'Language link changed from $1 to 
$2',
        'wikibase-comment-sitelink-remove' => 'Language link removed: $1',
        'wikibase-comment-multi' => '$1 {{PLURAL:$1|change|changes}}',
+       'wikibase-dataitem' => 'Data item',
        'wikibase-editlinks' => 'Edit links',
        'wikibase-editlinkstitle' => 'Edit interlanguage links',
        'wikibase-linkitem-addlinks' => 'Add links',
@@ -84,6 +86,7 @@
        'wikibase-client-desc' => '{{desc|name=Wikibase 
Client|url=http://www.mediawiki.org/wiki/Extension:Wikibase_Client}}
 See also [[d:Wikidata:Glossary#Wikidata|Wikidata]].',
        'specialpages-group-wikibaseclient' => '{{doc-special-group|that=is 
related to Wikidata clients|like=[[Special:UnconnectedPages]]}}',
+       'tooltip-t-wikibase' => 'Tooltip for toolbox link to connected Wikibase 
data repository item',
        'wikibase-after-page-move' => 'Message on [[Special:MovePage]] on 
submit and successfully move, inviting user to update associated Wikibase 
repository item to maintain language links on the moved page on the client.
 
 Parameters:
@@ -108,6 +111,7 @@
 
 Parameters:
 * $1 - the number of changes; is always at least 2.',
+       'wikibase-dataitem' => 'Toolbox link text for link to connected 
Wikibase data item',
        'wikibase-editlinks' => 
'[[Image:InterlanguageLinks-Sidebar-Monobook.png|right]]
        This is a link to the page on Wikidata where interlanguage links of the 
current page can be edited. See the image on the right for how it looks.
 {{Identical|Edit link}}',
diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php
index 5170bec..bdfa8d5 100644
--- a/client/WikibaseClient.php
+++ b/client/WikibaseClient.php
@@ -106,6 +106,7 @@
 
 // Hooks
 $wgHooks['UnitTestsList'][]                            = 
'\Wikibase\ClientHooks::registerUnitTests';
+$wgHooks['BaseTemplateToolbox'][]                      = 
'\Wikibase\ClientHooks::onBaseTemplateToolbox';
 $wgHooks['LoadExtensionSchemaUpdates'][]               = 
'\Wikibase\ClientHooks::onSchemaUpdate';
 $wgHooks['OldChangesListRecentChangesLine'][]          = 
'\Wikibase\ClientHooks::onOldChangesListRecentChangesLine';
 $wgHooks['OutputPageParserOutput'][]           = 
'\Wikibase\ClientHooks::onOutputPageParserOutput';
@@ -120,6 +121,7 @@
 $wgHooks['SpecialRecentChangesFilters'][]                      = 
'\Wikibase\ClientHooks::onSpecialRecentChangesFilters';
 $wgHooks['GetPreferences'][]                                           = 
'\Wikibase\ClientHooks::onGetPreferences';
 $wgHooks['BeforePageDisplay'][]                                = 
'\Wikibase\ClientHooks::onBeforePageDisplay';
+$wgHooks['BeforePageDisplay'][]             = 
'\Wikibase\ClientHooks::onBeforePageDisplayAddJsConfig';
 $wgHooks['ScribuntoExternalLibraries'][]      = 
'\Wikibase\ClientHooks::onScribuntoExternalLibraries';
 $wgHooks['SpecialWatchlistFilters'][]          = 
'\Wikibase\ClientHooks::onSpecialWatchlistFilters';
 

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

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

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

Reply via email to