Pragunbhutani has uploaded a new change for review.

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


Change subject: Adds Entity ID to action=info
......................................................................

Adds Entity ID to action=info

Adds the Entity ID of the corresponding Wikibase Repo item to action=info of
the corresponding Wikibase Client article page.

Bug: 47726
Change-Id: Ifa6ca0f0e6180d1eacf4cfae3e1746b40cd34be0
---
M client/WikibaseClient.hooks.php
M client/WikibaseClient.i18n.php
M client/WikibaseClient.php
3 files changed, 38 insertions(+), 0 deletions(-)


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

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index 2e7edb2..a2bd19f 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -648,4 +648,38 @@
                }
                return true;
        }
+
+       /**
+        * Adds the Entity ID of the corresponding Wikidata item in action=info
+        *
+        * @param IContextSource $context
+        * @param array $pageInfo
+        *
+        * @return bool
+        */
+       public static function onInfoAction( $context, &$pageInfo ) {
+               $site = \Sites::singleton()->getSite( Settings::get( 
'siteGlobalID' ) );
+
+               $siteLinkLookup = 
WikibaseClient::getDefaultInstance()->getStore()->getSiteLinkTable();
+               $entityId = $siteLinkLookup->getEntityIdForSiteLink(
+                       new SiteLink( $site, 
$context->getTitle()->getFullText() )
+               );
+
+               if( isset( $entityId ) ) {
+                       $idFormatter = 
WikibaseClient::getDefaultInstance()->getEntityIdFormatter();
+                       $idString = $idFormatter->format( $entityId );
+
+                       //adding the entity ID to page info
+                       $pageInfo['header-basic'][] = array(
+                               $context->msg( 'pageinfo-entity-id' ),
+                               $idString
+                       );
+               } else {
+                       $pageInfo['header-basic'][] = array(
+                               $context->msg( 'pageinfo-entity-id' ),
+                               'N/A'
+                       );
+               }
+               return true;
+       }
 }
diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php
index 7c64bcc..36ccae3 100644
--- a/client/WikibaseClient.i18n.php
+++ b/client/WikibaseClient.i18n.php
@@ -65,6 +65,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 
interlanguagelinks',
        'wikibase-unconnectedpages-format-row' => '($1 interlanguagelinks on 
the page)',
+       'pageinfo-entity-id' => 'Item ID',
 );
 
 /** Message documentation (Message documentation)
@@ -167,6 +168,8 @@
 
 Parameters:
 * $1 - number of inter-language links',
+
+       'pageinfo-entity-id' => 'The Alpha-Numeric identifier of the 
corresponding Wikidata Item',
 );
 
 /** Afrikaans (Afrikaans)
diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php
index 61ef105..5170bec 100644
--- a/client/WikibaseClient.php
+++ b/client/WikibaseClient.php
@@ -126,6 +126,7 @@
 // extension hooks
 $wgHooks['WikibaseDeleteData'][]                                   = 
'\Wikibase\ClientHooks::onWikibaseDeleteData';
 $wgHooks['WikibaseRebuildData'][]                                  = 
'\Wikibase\ClientHooks::onWikibaseRebuildData';
+$wgHooks['InfoAction'][]                                                       
        = '\Wikibase\ClientHooks::onInfoAction';
 
 // api modules
 $wgAPIMetaModules['wikibase'] = 'Wikibase\ApiClientInfo';

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

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

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

Reply via email to