Jonas Kress (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330230 )

Change subject: [WIP] Added support for CommonsDataType
......................................................................

[WIP] Added support for CommonsDataType

Bug: T57549
Change-Id: I25de2783205aa30b4e1a465dc4b7ad7eb859bed9
---
M client/WikibaseClient.datatypes.php
M composer.json
M lib/WikibaseLib.datatypes.php
M lib/i18n/en.json
M lib/i18n/qqq.json
M lib/includes/Formatters/WikibaseValueFormatterBuilders.php
M repo/resources/experts/getStore.js
M repo/resources/experts/resources.php
M repo/resources/parsers/getStore.js
9 files changed, 37 insertions(+), 1 deletion(-)


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

diff --git a/client/WikibaseClient.datatypes.php 
b/client/WikibaseClient.datatypes.php
index 2919d67..ab4b6fe 100644
--- a/client/WikibaseClient.datatypes.php
+++ b/client/WikibaseClient.datatypes.php
@@ -78,6 +78,12 @@
                                return $factory->newCommonsMediaFormatter( 
$format, $options );
                        },
                ],
+               'PT:commonsData' => [
+                       'formatter-factory-callback' => function( $format, 
FormatterOptions $options ) {
+                               $factory = 
WikibaseClient::getDefaultValueFormatterBuilders();
+                               return $factory->newCommonsDataFormatter( 
$format, $options );
+                       },
+               ],
                'VT:time' => [
                        'formatter-factory-callback' => function( $format, 
FormatterOptions $options ) {
                                $factory = 
WikibaseClient::getDefaultValueFormatterBuilders();
diff --git a/composer.json b/composer.json
index 5c69699..38d0730 100644
--- a/composer.json
+++ b/composer.json
@@ -32,7 +32,7 @@
                "data-values/data-types": "~1.0.0",
                "data-values/serialization": "~1.1",
                "data-values/javascript": "~0.8.3",
-               "data-values/value-view": "~0.18.0",
+               "data-values/value-view": "~0.18.1",
                "wikibase/data-model": "^6.3.1",
                "wikibase/data-model-serialization": "~2.2",
                "wikibase/internal-serialization": "~2.3",
diff --git a/lib/WikibaseLib.datatypes.php b/lib/WikibaseLib.datatypes.php
index 575403e..a4eb4d5 100644
--- a/lib/WikibaseLib.datatypes.php
+++ b/lib/WikibaseLib.datatypes.php
@@ -17,6 +17,7 @@
 
 return array(
        'PT:commonsMedia'      => array( 'value-type' => 'string' ),
+       'PT:commonsData'       => array( 'value-type' => 'string' ),
        'PT:globe-coordinate'  => array( 'value-type' => 'globecoordinate' ),
        'PT:monolingualtext'   => array( 'value-type' => 'monolingualtext' ),
        'PT:quantity'          => array( 'value-type' => 'quantity' ),
diff --git a/lib/i18n/en.json b/lib/i18n/en.json
index 876bf99..ad67091 100644
--- a/lib/i18n/en.json
+++ b/lib/i18n/en.json
@@ -73,6 +73,7 @@
        "datatypes-type-wikibase-item": "Item",
        "datatypes-type-wikibase-property": "Property",
        "datatypes-type-commonsMedia": "Commons media file",
+       "datatypes-type-commonsData": "Commons data file",
        "datatypes-type-external-id": "External identifier",
        "version-wikibase": "Wikibase",
        "wikibase-time-precision-Gannum": "$1 billion years CE",
diff --git a/lib/i18n/qqq.json b/lib/i18n/qqq.json
index 0ad24ef..90d4b50 100644
--- a/lib/i18n/qqq.json
+++ b/lib/i18n/qqq.json
@@ -83,6 +83,7 @@
        "datatypes-type-wikibase-item": "The name of a data type for items in 
Wikibase.\n{{Identical|Item}}",
        "datatypes-type-wikibase-property": "The name of a data type for 
properties in Wikibase.\n{{Identical|Property}}",
        "datatypes-type-commonsMedia": "The name of a data type for media files 
on Wikimedia Commons (proper name, capitalised in English; first letter 
capitalised anyway in this message and 
relatives).\n\n{{related|Datatypes-type}}",
+       "datatypes-type-commonsData": "The name of a data type for data files 
on Wikimedia Commons (proper name, capitalised in English; first letter 
capitalised anyway in this message and 
relatives).\n\n{{related|Datatypes-type}}",
        "datatypes-type-external-id": "The name of a data type for external 
identifiers in Wikibase.",
        "version-wikibase": "Name of the Wikibase extension collection, used on 
[[Special:Version]]",
        "wikibase-time-precision-Gannum": "Used to present a point in time with 
the precession of 1 billion of years. $1 is the point in time in billion years, 
rounded to billion years.\n{{Related|Wikibase-time-precision}}",
diff --git a/lib/includes/Formatters/WikibaseValueFormatterBuilders.php 
b/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
index 16dbbe9..6317da3 100644
--- a/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
+++ b/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
@@ -239,6 +239,23 @@
         *
         * @return ValueFormatter
         */
+       public function newCommonsDataFormatter( $format, FormatterOptions 
$options ) {
+               switch ( $this->getBaseFormat( $format ) ) {
+                       case SnakFormatter::FORMAT_HTML:
+                               return new CommonsLinkFormatter( $options );
+                       case SnakFormatter::FORMAT_WIKI:
+                               return new CommonsLinkFormatter( $options );
+                       default:
+                               return $this->newStringFormatter( $format, 
$options );
+               }
+       }
+
+       /**
+        * @param string $format The desired target format, see 
SnakFormatter::FORMAT_XXX
+        * @param FormatterOptions $options
+        *
+        * @return ValueFormatter
+        */
        public function newTimeFormatter( $format, FormatterOptions $options ) {
                // TODO: Add a wikitext formatter that shows the calendar model
                if ( $format === SnakFormatter::FORMAT_HTML_DIFF ) {
diff --git a/repo/resources/experts/getStore.js 
b/repo/resources/experts/getStore.js
index e9cf66e..2eebef1 100644
--- a/repo/resources/experts/getStore.js
+++ b/repo/resources/experts/getStore.js
@@ -43,6 +43,7 @@
 
        var dataTypeIdToExpertConstructor = {
                commonsMedia: vv.experts.CommonsMediaType,
+               commonsData: vv.experts.CommonsDataType,
                'external-id': vv.experts.StringValue,
                monolingualtext: vv.experts.MonolingualText,
                url: vv.experts.StringValue,
diff --git a/repo/resources/experts/resources.php 
b/repo/resources/experts/resources.php
index 57c8043..617150d4 100644
--- a/repo/resources/experts/resources.php
+++ b/repo/resources/experts/resources.php
@@ -33,6 +33,7 @@
                                'dataValues.values',
                                'jquery.valueview.ExpertStore',
                                'jquery.valueview.experts.CommonsMediaType',
+                               'jquery.valueview.experts.CommonsDataType',
                                'jquery.valueview.experts.GlobeCoordinateInput',
                                'jquery.valueview.experts.MonolingualText',
                                'jquery.valueview.experts.QuantityInput',
diff --git a/repo/resources/parsers/getStore.js 
b/repo/resources/parsers/getStore.js
index 957c48d..c74bfe6 100644
--- a/repo/resources/parsers/getStore.js
+++ b/repo/resources/parsers/getStore.js
@@ -51,6 +51,14 @@
        );
 
        parserStore.registerDataTypeParser(
+                       util.inherit(
+                               ApiBasedValueParser,
+                               { API_VALUE_PARSER_ID: 'commonsData' }
+                       ),
+                       'commonsData'
+       );
+       
+       parserStore.registerDataTypeParser(
                util.inherit(
                        ApiBasedValueParser,
                        { API_VALUE_PARSER_ID: 'url' }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25de2783205aa30b4e1a465dc4b7ad7eb859bed9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to