WikidataBuilder has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349190 )
Change subject: New Wikidata Build - 2017-04-20T10:00:01+0000
......................................................................
New Wikidata Build - 2017-04-20T10:00:01+0000
Change-Id: Ibe118cd9591ea6d7324e7de235b7e50d6678256b
---
M composer.lock
M extensions/Constraints/extension.json
M extensions/Constraints/includes/ConstraintCheck/Checker/TypeChecker.php
M extensions/Constraints/includes/ConstraintCheck/Checker/ValueTypeChecker.php
M extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
M extensions/Constraints/includes/ConstraintReportFactory.php
M
extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
M
extensions/Constraints/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
M extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php
M extensions/Wikibase/client/WikibaseClient.datatypes.php
M extensions/Wikibase/client/config/WikibaseClient.default.php
M extensions/Wikibase/client/i18n/atj.json
M extensions/Wikibase/client/i18n/cs.json
M extensions/Wikibase/client/i18n/fa.json
M extensions/Wikibase/client/includes/WikibaseClient.php
M
extensions/Wikibase/client/tests/phpunit/includes/DataAccess/DataAccessSnakFormatterOutputFormatTest.php
M extensions/Wikibase/composer.json
M extensions/Wikibase/lib/WikibaseLib.datatypes.php
M extensions/Wikibase/lib/i18n/de.json
M extensions/Wikibase/lib/i18n/en.json
M extensions/Wikibase/lib/i18n/fa.json
M extensions/Wikibase/lib/i18n/lv.json
M extensions/Wikibase/lib/i18n/qqq.json
M extensions/Wikibase/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
M
extensions/Wikibase/lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php
M extensions/Wikibase/repo/Wikibase.i18n.alias.php
M extensions/Wikibase/repo/Wikibase.php
M extensions/Wikibase/repo/WikibaseRepo.datatypes.php
M extensions/Wikibase/repo/config/Wikibase.default.php
M extensions/Wikibase/repo/i18n/de.json
M extensions/Wikibase/repo/i18n/en.json
M extensions/Wikibase/repo/i18n/fa.json
M extensions/Wikibase/repo/i18n/qqq.json
M extensions/Wikibase/repo/includes/Content/ItemContent.php
M extensions/Wikibase/repo/includes/Content/ItemHandler.php
M extensions/Wikibase/repo/includes/Hooks/LinkBeginHookHandler.php
A extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php
A extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php
M extensions/Wikibase/repo/includes/ValidatorBuilders.php
M extensions/Wikibase/repo/includes/WikibaseRepo.php
M extensions/Wikibase/repo/resources/Resources.php
M extensions/Wikibase/repo/resources/experts/getStore.js
M extensions/Wikibase/repo/resources/experts/resources.php
M extensions/Wikibase/repo/resources/parsers/getStore.js
M extensions/Wikibase/repo/resources/wikibase.ui.entityViewInit.js
M extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemContentTest.php
M extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemHandlerTest.php
A
extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php
M extensions/Wikibase/repo/tests/phpunit/includes/ValidatorBuildersTest.php
M vendor/composer/autoload_classmap.php
M vendor/composer/autoload_static.php
M vendor/composer/installed.json
53 files changed, 800 insertions(+), 72 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata
refs/changes/90/349190/1
diff --git a/composer.lock b/composer.lock
index 97b8027..a45082e 100644
--- a/composer.lock
+++ b/composer.lock
@@ -935,7 +935,7 @@
"source": {
"type": "git",
"url":
"https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints",
- "reference": "75bf5aefb01f5b8eeda91931b86afcc999979be0"
+ "reference": "c2aa62f43030e3c57f7631f3e9cc4c750bd1de8e"
},
"require": {
"php": ">=5.5.9",
@@ -988,7 +988,7 @@
"support": {
"issues":
"https://phabricator.wikimedia.org/project/profile/1202/"
},
- "time": "2017-04-18 14:34:44"
+ "time": "2017-04-19 11:01:26"
},
{
"name": "wikibase/data-model",
@@ -1558,12 +1558,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "28fe263493776f3e2f5e46235dbfdd25a2f9ecc0"
+ "reference": "9d44440af6ab950d1fd60eea2f3b098cb2efba9b"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/28fe263493776f3e2f5e46235dbfdd25a2f9ecc0",
- "reference": "28fe263493776f3e2f5e46235dbfdd25a2f9ecc0",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/9d44440af6ab950d1fd60eea2f3b098cb2efba9b",
+ "reference": "9d44440af6ab950d1fd60eea2f3b098cb2efba9b",
"shasum": ""
},
"require": {
@@ -1576,7 +1576,7 @@
"data-values/number": "^0.8.2",
"data-values/serialization": "^1.2.0",
"data-values/time": "^0.8.4",
- "data-values/value-view": "^0.19.0",
+ "data-values/value-view": "^0.19.1",
"diff/diff": "^2.0.0",
"php": ">=5.5.9",
"wikibase/data-model": "^7.0.0",
@@ -1593,7 +1593,7 @@
},
"require-dev": {
"jakub-onderka/php-parallel-lint": ">=0.3 <0.10",
- "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8"
+ "mediawiki/mediawiki-codesniffer": ">=0.7 <0.8"
},
"type": "mediawiki-extension",
"autoload": {
@@ -1637,7 +1637,7 @@
"wikibaserepo",
"wikidata"
],
- "time": "2017-04-19 07:41:52"
+ "time": "2017-04-20 08:41:18"
},
{
"name": "wikibase/wikimedia-badges",
diff --git a/extensions/Constraints/extension.json
b/extensions/Constraints/extension.json
index 468bd3f..e1b8340 100644
--- a/extensions/Constraints/extension.json
+++ b/extensions/Constraints/extension.json
@@ -43,5 +43,9 @@
"scripts": "modules/SpecialConstraintReportPage.js"
}
},
+ "config": {
+ "WBQualityConstraintsInstanceOfId": "P31",
+ "WBQualityConstraintsSubclassOfId": "P279"
+ },
"manifest_version": 1
}
diff --git
a/extensions/Constraints/includes/ConstraintCheck/Checker/TypeChecker.php
b/extensions/Constraints/includes/ConstraintCheck/Checker/TypeChecker.php
index 5917be3..29ae4e0 100644
--- a/extensions/Constraints/includes/ConstraintCheck/Checker/TypeChecker.php
+++ b/extensions/Constraints/includes/ConstraintCheck/Checker/TypeChecker.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker;
+use Config;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Services\Lookup\EntityLookup;
use Wikibase\DataModel\Statement\StatementListProvider;
@@ -34,18 +35,22 @@
*/
private $typeCheckerHelper;
- const instanceId = 'P31';
- const subclassId = 'P279';
+ /**
+ * @var Config
+ */
+ private $config;
/**
* @param EntityLookup $lookup
* @param ConstraintParameterParser $helper
* @param TypeCheckerHelper $typeCheckerHelper
+ * @param Config $config
*/
- public function __construct( EntityLookup $lookup,
ConstraintParameterParser $helper, TypeCheckerHelper $typeCheckerHelper ) {
+ public function __construct( EntityLookup $lookup,
ConstraintParameterParser $helper, TypeCheckerHelper $typeCheckerHelper, Config
$config ) {
$this->entityLookup = $lookup;
$this->helper = $helper;
$this->typeCheckerHelper = $typeCheckerHelper;
+ $this->config = $config;
}
/**
@@ -87,9 +92,9 @@
* parameter $constraintParameters['relation'] must be either
'instance' or 'subclass'
*/
if ( $relation === 'instance' ) {
- $relationId = self::instanceId;
+ $relationId = $this->config->get(
'WBQualityConstraintsInstanceOfId' );
} elseif ( $relation === 'subclass' ) {
- $relationId = self::subclassId;
+ $relationId = $this->config->get(
'WBQualityConstraintsSubclassOfId' );
} else {
$message = wfMessage(
"wbqc-violation-message-type-relation-instance-or-subclass" )->escaped();
return new CheckResult( $entity->getId(), $statement,
$constraint->getConstraintTypeQid(), $constraint->getConstraintId(),
$parameters, CheckResult::STATUS_VIOLATION, $message );
diff --git
a/extensions/Constraints/includes/ConstraintCheck/Checker/ValueTypeChecker.php
b/extensions/Constraints/includes/ConstraintCheck/Checker/ValueTypeChecker.php
index 4e8fe69..dfde8fa 100644
---
a/extensions/Constraints/includes/ConstraintCheck/Checker/ValueTypeChecker.php
+++
b/extensions/Constraints/includes/ConstraintCheck/Checker/ValueTypeChecker.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker;
+use Config;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Services\Lookup\EntityLookup;
@@ -36,18 +37,22 @@
*/
private $typeCheckerHelper;
- const instanceId = 'P31';
- const subclassId = 'P279';
+ /**
+ * @var Config
+ */
+ private $config;
/**
* @param EntityLookup $lookup
* @param ConstraintParameterParser $helper
* @param TypeCheckerHelper $typeCheckerHelper
+ * @param Config $config
*/
- public function __construct( EntityLookup $lookup,
ConstraintParameterParser $helper, TypeCheckerHelper $typeCheckerHelper ) {
+ public function __construct( EntityLookup $lookup,
ConstraintParameterParser $helper, TypeCheckerHelper $typeCheckerHelper, Config
$config ) {
$this->entityLookup = $lookup;
$this->helper = $helper;
$this->typeCheckerHelper = $typeCheckerHelper;
+ $this->config = $config;
}
/**
@@ -113,9 +118,9 @@
* parameter $constraintParameters['relation'] must be either
'instance' or 'subclass'
*/
if ( $relation === 'instance' ) {
- $relationId = self::instanceId;
+ $relationId = $this->config->get(
'WBQualityConstraintsInstanceOfId' );
} elseif ( $relation === 'subclass' ) {
- $relationId = self::subclassId;
+ $relationId = $this->config->get(
'WBQualityConstraintsSubclassOfId' );
} else {
$message = wfMessage(
"wbqc-violation-message-type-relation-instance-or-subclass" )->escaped();
return new CheckResult( $entity->getId(), $statement,
$constraint->getConstraintTypeQid(), $constraint->getConstraintId(),
$parameters, CheckResult::STATUS_VIOLATION, $message );
diff --git
a/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
b/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
index f50ae57..7024352 100644
---
a/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
+++
b/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
+use Config;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\PropertyId;
@@ -22,16 +23,20 @@
class TypeCheckerHelper {
const MAX_DEPTH = 20;
- const instanceId = 'P31';
- const subclassId = 'P279';
/**
* @var EntityLookup $entityLookup
*/
private $entityLookup;
- public function __construct( EntityLookup $lookup ) {
+ /**
+ * @var Config
+ */
+ private $config;
+
+ public function __construct( EntityLookup $lookup, Config $config ) {
$this->entityLookup = $lookup;
+ $this->config = $config;
}
/**
@@ -52,8 +57,9 @@
return false; // lookup failed, probably because item
doesn't exist
}
+ $subclassId = $this->config->get(
'WBQualityConstraintsSubclassOfId' );
/** @var Statement $statement */
- foreach ( $item->getStatements()->getByPropertyId( new
PropertyId( self::subclassId ) ) as $statement ) {
+ foreach ( $item->getStatements()->getByPropertyId( new
PropertyId( $subclassId ) ) as $statement ) {
$mainSnak = $statement->getMainSnak();
if ( !( $this->hasCorrectType( $mainSnak ) ) ) {
diff --git a/extensions/Constraints/includes/ConstraintReportFactory.php
b/extensions/Constraints/includes/ConstraintReportFactory.php
index 270e30e..2c6ccc3 100644
--- a/extensions/Constraints/includes/ConstraintReportFactory.php
+++ b/extensions/Constraints/includes/ConstraintReportFactory.php
@@ -2,6 +2,8 @@
namespace WikibaseQuality\ConstraintReport;
+use Config;
+use MediaWiki\MediaWikiServices;
use Wikibase\DataModel\Services\Lookup\EntityLookup;
use Wikibase\Repo\WikibaseRepo;
use
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
@@ -63,6 +65,11 @@
private $statementGuidParser;
/**
+ * @var Config
+ */
+ private $config;
+
+ /**
* Returns the default instance.
* IMPORTANT: Use only when it is not feasible to inject an instance
properly.
*
@@ -72,7 +79,11 @@
static $instance = null;
if ( $instance === null ) {
- $instance = new self(
WikibaseRepo::getDefaultInstance()->getEntityLookup(),
WikibaseRepo::getDefaultInstance()->getStatementGuidParser() );
+ $instance = new self(
+
WikibaseRepo::getDefaultInstance()->getEntityLookup(),
+
WikibaseRepo::getDefaultInstance()->getStatementGuidParser(),
+
MediaWikiServices::getInstance()->getMainConfig()
+ );
}
return $instance;
@@ -82,9 +93,10 @@
* @param EntityLookup $lookup
* @param StatementGuidParser $statementGuidParser
*/
- public function __construct( EntityLookup $lookup, StatementGuidParser
$statementGuidParser ) {
+ public function __construct( EntityLookup $lookup, StatementGuidParser
$statementGuidParser, Config $config ) {
$this->lookup = $lookup;
$this->statementGuidParser = $statementGuidParser;
+ $this->config = $config;
}
/**
@@ -110,7 +122,7 @@
$constraintParameterParser = new
ConstraintParameterParser();
$connectionCheckerHelper = new
ConnectionCheckerHelper();
$rangeCheckerHelper = new RangeCheckerHelper();
- $typeCheckerHelper = new TypeCheckerHelper(
$this->lookup );
+ $typeCheckerHelper = new TypeCheckerHelper(
$this->lookup, $this->config );
$this->constraintCheckerMap = array(
'Conflicts with' => new ConflictsWithChecker(
$this->lookup, $constraintParameterParser, $connectionCheckerHelper ),
@@ -123,8 +135,8 @@
'Mandatory qualifiers' => new
MandatoryQualifiersChecker( $constraintParameterParser ),
'Range' => new RangeChecker(
$constraintParameterParser, $rangeCheckerHelper ),
'Diff within range' => new
DiffWithinRangeChecker( $constraintParameterParser, $rangeCheckerHelper ),
- 'Type' => new TypeChecker( $this->lookup,
$constraintParameterParser, $typeCheckerHelper ),
- 'Value type' => new ValueTypeChecker(
$this->lookup, $constraintParameterParser, $typeCheckerHelper ),
+ 'Type' => new TypeChecker( $this->lookup,
$constraintParameterParser, $typeCheckerHelper, $this->config ),
+ 'Value type' => new ValueTypeChecker(
$this->lookup, $constraintParameterParser, $typeCheckerHelper, $this->config ),
'Single value' => new SingleValueChecker(),
'Multi value' => new MultiValueChecker(),
'Unique value' => new UniqueValueChecker(),
diff --git
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
index c26efff..7f21855 100644
---
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
+++
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\Test\TypeChecker;
+use HashConfig;
use PHPUnit_Framework_TestCase;
use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Snak\PropertyValueSnak;
@@ -29,7 +30,10 @@
protected function setUp() {
parent::setUp();
- $this->helper = new TypeCheckerHelper( new
JsonFileEntityLookup( __DIR__ ) );
+ $this->helper = new TypeCheckerHelper(
+ new JsonFileEntityLookup( __DIR__ ),
+ new HashConfig( [ 'WBQualityConstraintsInstanceOfId' =>
'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] )
+ );
}
protected function tearDown() {
diff --git
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
index 8bd1060..fd844cb 100644
---
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
+++
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\Test\TypeChecker;
+use HashConfig;
use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\DataModel\Entity\EntityIdValue;
@@ -44,7 +45,10 @@
protected function setUp() {
parent::setUp();
$this->lookup = new JsonFileEntityLookup( __DIR__ );
- $this->checker = new TypeChecker( $this->lookup, new
ConstraintParameterParser(), new TypeCheckerHelper( $this->lookup ) );
+ $config = new HashConfig( [ 'WBQualityConstraintsInstanceOfId'
=> 'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] );
+ $this->checker = new TypeChecker(
+ $this->lookup, new ConstraintParameterParser(), new
TypeCheckerHelper( $this->lookup, $config ), $config
+ );
$this->typeStatement = new Statement( new PropertyValueSnak(
new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) );
}
diff --git
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
index 145fb7f..786d432 100644
---
a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
+++
b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\Test\TypeChecker;
+use HashConfig;
use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\DataModel\Entity\EntityIdValue;
@@ -47,7 +48,10 @@
protected function setUp() {
parent::setUp();
$this->lookup = new JsonFileEntityLookup( __DIR__ );
- $this->checker = new ValueTypeChecker( $this->lookup, new
ConstraintParameterParser(), new TypeCheckerHelper( $this->lookup ) );
+ $config = new HashConfig( [ 'WBQualityConstraintsInstanceOfId'
=> 'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] );
+ $this->checker = new ValueTypeChecker(
+ $this->lookup, new ConstraintParameterParser(), new
TypeCheckerHelper( $this->lookup, $config ), $config
+ );
$this->valueTypePropertyId = new PropertyId( 'P1234' );
}
diff --git
a/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php
b/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php
index 6105b20..9b32680 100644
--- a/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php
+++ b/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php
@@ -2,6 +2,7 @@
namespace WikibaseQuality\ConstraintReport\Test\ConstraintChecker;
+use HashConfig;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\ItemIdParser;
@@ -63,9 +64,11 @@
parent::setUp();
$this->lookup = $this->createEntityLookup();
$this->statementGuidParser = new StatementGuidParser( new
ItemIdParser() );
+ $config = new HashConfig( [ 'WBQualityConstraintsInstanceOfId'
=> 'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] );
$factory = new ConstraintReportFactory(
$this->lookup,
- $this->statementGuidParser
+ $this->statementGuidParser,
+ $config
);
$this->constraintChecker = $factory->getConstraintChecker();
@@ -292,7 +295,8 @@
public function testCheckAgainstConstraints_ByClaims() {
$factory = new ConstraintReportFactory(
$this->createEntityLookup(),
- $this->statementGuidParser
+ $this->statementGuidParser,
+ new HashConfig( [ 'WBQualityConstraintsInstanceOfId' =>
'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] )
);
$constraintChecker = $factory->getConstraintChecker();
@@ -305,7 +309,8 @@
public function
testCheckAgainstConstraintsDoesNotCrashWhenResultIsEmpty_ByClaims() {
$factory = new ConstraintReportFactory(
$this->createEntityLookup(),
- $this->statementGuidParser
+ $this->statementGuidParser,
+ new HashConfig( [ 'WBQualityConstraintsInstanceOfId' =>
'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] )
);
$constraintChecker = $factory->getConstraintChecker();
@@ -318,7 +323,8 @@
public function
testCheckAgainstConstraintsDoesNotCrashWhenClaimDoesNotExist() {
$factory = new ConstraintReportFactory(
$this->createEntityLookup(),
- $this->statementGuidParser
+ $this->statementGuidParser,
+ new HashConfig( [ 'WBQualityConstraintsInstanceOfId' =>
'P31', 'WBQualityConstraintsSubclassOfId' => 'P279' ] )
);
$constraintChecker = $factory->getConstraintChecker();
diff --git a/extensions/Wikibase/client/WikibaseClient.datatypes.php
b/extensions/Wikibase/client/WikibaseClient.datatypes.php
index 2f744e7..6a924de 100644
--- a/extensions/Wikibase/client/WikibaseClient.datatypes.php
+++ b/extensions/Wikibase/client/WikibaseClient.datatypes.php
@@ -84,6 +84,12 @@
return $factory->newGeoShapeFormatter( $format,
$options );
},
],
+ 'PT:tabular-data' => [
+ 'formatter-factory-callback' => function( $format,
FormatterOptions $options ) {
+ $factory =
WikibaseClient::getDefaultValueFormatterBuilders();
+ return $factory->newTabularDataFormatter(
$format, $options );
+ },
+ ],
'VT:time' => [
'formatter-factory-callback' => function( $format,
FormatterOptions $options ) {
$factory =
WikibaseClient::getDefaultValueFormatterBuilders();
diff --git a/extensions/Wikibase/client/config/WikibaseClient.default.php
b/extensions/Wikibase/client/config/WikibaseClient.default.php
index 873c4f7..3c57f69 100644
--- a/extensions/Wikibase/client/config/WikibaseClient.default.php
+++ b/extensions/Wikibase/client/config/WikibaseClient.default.php
@@ -215,5 +215,10 @@
// Special characters (e.g. space, percent, etc.) in URL should NOT be
encoded
$defaults['geoShapeStorageFrontendUrl'] =
'https://commons.wikimedia.org/wiki/';
+ // URL of tabular data storage frontend. Used primarily to build links
to the tabular data pages.
+ // URL will be concatenated with the page title, so should end up with
'/' or 'title='
+ // Special characters (e.g. space, percent, etc.) in URL should NOT be
encoded
+ $defaults['tabularDataStorageFrontendUrl'] =
'https://commons.wikimedia.org/wiki/';
+
return $defaults;
} );
diff --git a/extensions/Wikibase/client/i18n/atj.json
b/extensions/Wikibase/client/i18n/atj.json
index ee3b19b..2b895eb 100644
--- a/extensions/Wikibase/client/i18n/atj.json
+++ b/extensions/Wikibase/client/i18n/atj.json
@@ -5,11 +5,12 @@
"Benoit Rochon",
"Jean-paul echaquan",
"Nehirowisiw",
- "Jeannette Coocoo"
+ "Jeannette Coocoo",
+ "Ninmeka"
]
},
"tooltip-t-wikibase": "Ite ke ispitatc",
- "wikibase-comment-update": "Kekwan{{WBREPONAME}}ka ki
meckotcitakiniwok",
+ "wikibase-comment-update": "Kekwan{{WBREPONAME}}ka ki
meckotcitakaniwok",
"wikibase-dataitem": "{{WBREPONAME}} ka apatak",
"wikibase-editlinks": "Meckotona e ici tapitik",
"wikibase-editlinkstitle": "Meckotcita arimowewinik ka tapitiki",
diff --git a/extensions/Wikibase/client/i18n/cs.json
b/extensions/Wikibase/client/i18n/cs.json
index d8f4377..de0748e 100644
--- a/extensions/Wikibase/client/i18n/cs.json
+++ b/extensions/Wikibase/client/i18n/cs.json
@@ -50,6 +50,13 @@
"wikibase-rc-wikibase-edit-title": "Editace
{{grammar:2sg|{{WBREPONAME}}}}",
"wikibase-rcfilters-hide-wikibase-label": "Editace
{{GRAMMAR:2sg|{{WBREPONAME}}}}",
"wikibase-rcfilters-hide-wikibase-description": "Editace pocházející z
{{GRAMMAR:2sg|{{WBREPONAME}}}}.",
+ "wikibase-rcfilters-hide-wikibase-conflicts-ores": "Tento filtr je v
konfliktu s jedním nebo více filtry podle kvality příspěvků nebo úmyslu
uživatele. Odhad kvality nebo úmyslu není dostupný pro editace
{{GRAMMAR:2sg|{{WBREPONAME}}}}.",
+ "wikibase-rcfilters-hide-wikibase-conflicts-ores-global": "Filtr
„Editace {{GRAMMAR:2sg|{{WBREPONAME}}}}“ je v konfliktu s jedním nebo více
filtry podle kvality příspěvků nebo úmyslu uživatele. Odhad kvality nebo úmyslu
není dostupný pro editace {{GRAMMAR:2sg|{{WBREPONAME}}}}. Dotyčné filtry jsou
označeny nahoře, v prostoru „Aktivní filtry“.",
+ "wikibase-rcfilters-damaging-conflicts-hide-wikibase": "Odhad kvality
příspěvků není dostupný pro určité typy změn, tento filtr je proto v konfliktu
s {{PLURAL:$2|následujícím filtrem|následujícími filtry}} podle typu změny: $1",
+ "wikibase-rcfilters-goodfaith-conflicts-hide-wikibase": "Odhad úmyslu
uživatele není dostupný pro určité typy změn, tento filtr je proto v konfliktu
s {{PLURAL:$2|následujícím filtrem|následujícími filtry}} podle typu změny: $1",
+ "wikibase-rcfilters-hide-wikibase-conflicts-major-global": "Všechny
editace {{GRAMMAR:2sg|{{WBREPONAME}}}} jsou označeny jako „malé“, filtr
„Editace {{GRAMMAR:2sg|{{WBREPONAME}}}}“ je proto v konfliktu s filtrem „Nemalé
editace“.",
+ "wikibase-rcfilters-major-conflicts-hide-wikibase": "Všechny editace
{{GRAMMAR:2sg|{{WBREPONAME}}}} jsou označeny jako „malé“, filtr „Editace
{{GRAMMAR:2sg|{{WBREPONAME}}}}“ je proto v konfliktu s filtrem „Nemalé
editace“.",
+ "wikibase-rcfilters-hide-wikibase-conflicts-major": "Všechny editace
{{GRAMMAR:2sg|{{WBREPONAME}}}} jsou označeny jako „malé“, filtr „Editace
{{GRAMMAR:2sg|{{WBREPONAME}}}}“ je proto v konfliktu s filtrem „Nemalé
editace“.",
"wikibase-replicationnote": "Vezměte prosím na vědomí, že než se změny
projeví na všech wiki, může to trvat pár minut.",
"wikibase-watchlist-show-changes-pref": "Zobrazit změny
{{grammar:2sg|{{WBREPONAME}}}} ve sledovaných stránkách",
"wikibase-error-deserialize-error": "Nepodařilo se deserializovat
data.",
diff --git a/extensions/Wikibase/client/i18n/fa.json
b/extensions/Wikibase/client/i18n/fa.json
index 523abb3..7f58e1c 100644
--- a/extensions/Wikibase/client/i18n/fa.json
+++ b/extensions/Wikibase/client/i18n/fa.json
@@ -34,6 +34,9 @@
"apihelp-query+wblistentityusage-paramvalue-prop-url": "اگر نشانی
اینترنتی موجودیت فعال شود، به نتایج افزوده میشود.",
"apihelp-query+wblistentityusage-param-aspect": "فقط شناسههای موجودیتی
که در این زمینه استفاده شدهاند، بازگردانده شود.",
"apihelp-query+wblistentityusage-param-entities": "موجودیتهایی که
استقاده شدهاند.",
+ "apihelp-query+wblistentityusage-param-limit": "تعداد کاربردهای مورد که
میخواهید بازگردانده شود.",
+ "apihelp-query+wblistentityusage-example-simple": "دریافت صفحههایی که
از مورد <kbd>Q2</kbd> استفاده میکنند.",
+ "apihelp-query+wblistentityusage-example-url": "دریافت صفحههایی که از
مورد <kbd>Q2</kbd> استفاده میکنند، به همراه نشانی وب آنها.",
"apihelp-query+pageterms-description": "اصطلاحات مرتبط با یک صفحه را که
با آیتم مربوطه مرتبط شده است را دریافت کن.\nدر صفحهٔ ورودی ویکیبیس اصطلاحهای
ورودی به صورت مستقبم استفاده میشوند.",
"apihelp-query+pageterms-example-simple": "گرفتن همهٔ آیتمهای مرتبط با
صفحهٔ «لندن» به زبان کاربر.",
"apihelp-query+pageterms-example-label-en": "برچسبها و نامهای مستعار
مرتبط شده با صفحه 'London' در انگلیسی را دریافت کن",
@@ -110,5 +113,8 @@
"wikibase-otherprojects": "در دیگر پروژهها",
"wikibase-otherprojects-beta-message": "نوار کناری سایر پروژهها",
"wikibase-otherprojects-beta-description": "یک قسمت
«{{int:wikibase-otherprojects}}» به نوار کناری میافزاید که پیوندهایی به دیگر
پروژههای ویکیمدیا واقعشده در دادههای {{WBREPONAME}} میدهد.",
- "echo-category-title-wikibase-action": "تماس با {{WBREPONAME}}"
+ "echo-category-title-wikibase-action": "تماس با {{WBREPONAME}}",
+ "notification-link-text-view-item": "{{GENDER:$1|نمایش}} آیتم",
+ "notification-subject-page-connection": "صفحهای در {{SITENAME}} که شما
{{GENDER:$3|ایجاد کردید}} به آیتم {{WBREPONAME}} {{GENDER:$2|متصل بود}}",
+ "unresolved-property-category": "صفحات با خصوصیات نامشخص"
}
diff --git a/extensions/Wikibase/client/includes/WikibaseClient.php
b/extensions/Wikibase/client/includes/WikibaseClient.php
index 2666f5a..121fe73 100644
--- a/extensions/Wikibase/client/includes/WikibaseClient.php
+++ b/extensions/Wikibase/client/includes/WikibaseClient.php
@@ -273,6 +273,7 @@
new LanguageNameLookup(
$this->getUserLanguage()->getCode() ),
$this->getRepoItemUriParser(),
$settings->getSetting( 'geoShapeStorageFrontendUrl' ),
+ $settings->getSetting( 'tabularDataStorageFrontendUrl'
),
$entityTitleLookup
);
}
diff --git
a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/DataAccessSnakFormatterOutputFormatTest.php
b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/DataAccessSnakFormatterOutputFormatTest.php
index d54cdd8..dd79669 100644
---
a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/DataAccessSnakFormatterOutputFormatTest.php
+++
b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/DataAccessSnakFormatterOutputFormatTest.php
@@ -60,6 +60,7 @@
$siteId = $settings->getSetting( 'siteGlobalID' );
$settings->setSetting( 'geoShapeStorageFrontendUrl',
'https://media.something/view/' );
+ $settings->setSetting( 'tabularDataStorageFrontendUrl',
'https://tabular.data/view/' );
$this->setUpDummyData( $store, $siteId );
}
@@ -77,6 +78,7 @@
'P9' => 'wikibase-item',
'P10' => 'external-id', // with formatter
'P11' => 'geo-shape',
+ 'P12' => 'tabular-data',
];
foreach ( $dataTypeIds as $id => $dataTypeId ) {
@@ -285,7 +287,14 @@
new PropertyId( 'P11' ),
new StringValue( 'April 2017' )
)
- ]
+ ],
+ 'tabular-data' => [
+
'<span>[https://tabular.data/view/In_data_we_trust In data we trust]</span>',
+ new PropertyValueSnak(
+ new PropertyId( 'P12' ),
+ new StringValue( 'In data we trust' )
+ )
+ ],
];
foreach ( $genericSnaks as $testName => $case ) {
@@ -340,6 +349,13 @@
new PropertyId( 'P11' ),
new StringValue( 'April 2017' )
)
+ ],
+ 'tabular-data' => [
+ 'In data we trust',
+ new PropertyValueSnak(
+ new PropertyId( 'P12' ),
+ new StringValue( 'In data we trust' )
+ )
]
];
diff --git a/extensions/Wikibase/composer.json
b/extensions/Wikibase/composer.json
index 6c88971..697220b 100644
--- a/extensions/Wikibase/composer.json
+++ b/extensions/Wikibase/composer.json
@@ -31,7 +31,7 @@
"data-values/data-types": "^1.0.0",
"data-values/serialization": "^1.2.0",
"data-values/javascript": "^0.8.3",
- "data-values/value-view": "^0.19.0",
+ "data-values/value-view": "^0.19.1",
"wikibase/data-model": "^7.0.0",
"wikibase/data-model-serialization": "^2.1.0",
"wikibase/internal-serialization": "^2.2.0",
@@ -44,7 +44,7 @@
},
"require-dev": {
"jakub-onderka/php-parallel-lint": ">=0.3 <0.10",
- "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8"
+ "mediawiki/mediawiki-codesniffer": ">=0.7 <0.8"
},
"conflict": {
"mediawiki/mediawiki": "<1.25"
diff --git a/extensions/Wikibase/lib/WikibaseLib.datatypes.php
b/extensions/Wikibase/lib/WikibaseLib.datatypes.php
index 52bada2..ee1df73 100644
--- a/extensions/Wikibase/lib/WikibaseLib.datatypes.php
+++ b/extensions/Wikibase/lib/WikibaseLib.datatypes.php
@@ -22,6 +22,7 @@
'PT:monolingualtext' => array( 'value-type' => 'monolingualtext' ),
'PT:quantity' => array( 'value-type' => 'quantity' ),
'PT:string' => array( 'value-type' => 'string' ),
+ 'PT:tabular-data' => array( 'value-type' => 'string' ),
'PT:time' => array( 'value-type' => 'time' ),
'PT:url' => array( 'value-type' => 'string' ),
'PT:external-id' => array( 'value-type' => 'string' ),
diff --git a/extensions/Wikibase/lib/i18n/de.json
b/extensions/Wikibase/lib/i18n/de.json
index f7998b6..add6fe7 100644
--- a/extensions/Wikibase/lib/i18n/de.json
+++ b/extensions/Wikibase/lib/i18n/de.json
@@ -82,6 +82,7 @@
"datatypes-type-wikibase-property": "Eigenschaft",
"datatypes-type-commonsMedia": "Mediendatei auf Commons",
"datatypes-type-geo-shape": "Geografische Form",
+ "datatypes-type-tabular-data": "Tabellarische Daten",
"datatypes-type-external-id": "Externer Identifikator",
"version-wikibase": "Wikibase-Erweiterungen",
"wikibase-time-precision-Gannum": "$1 Milliarden Jahre n. Chr.",
diff --git a/extensions/Wikibase/lib/i18n/en.json
b/extensions/Wikibase/lib/i18n/en.json
index a73e880..f284db5 100644
--- a/extensions/Wikibase/lib/i18n/en.json
+++ b/extensions/Wikibase/lib/i18n/en.json
@@ -74,6 +74,7 @@
"datatypes-type-wikibase-property": "Property",
"datatypes-type-commonsMedia": "Commons media file",
"datatypes-type-geo-shape": "Geographic shape",
+ "datatypes-type-tabular-data": "Tabular data",
"datatypes-type-external-id": "External identifier",
"version-wikibase": "Wikibase",
"wikibase-time-precision-Gannum": "$1 billion years CE",
diff --git a/extensions/Wikibase/lib/i18n/fa.json
b/extensions/Wikibase/lib/i18n/fa.json
index 358c0ea..50bc733 100644
--- a/extensions/Wikibase/lib/i18n/fa.json
+++ b/extensions/Wikibase/lib/i18n/fa.json
@@ -14,7 +14,8 @@
"Pouyana",
"Alirezaaa",
"Macofe",
- "Nojan Madinehi"
+ "Nojan Madinehi",
+ "Huji"
]
},
"wikibase-lib-desc": "نگهداری قابلیتهای اساسی برای ویکیبیس و
افزونههای کارخواه ویکیبیس",
@@ -29,7 +30,7 @@
"wikibase-error-remove-connection": "هنگام حذفکردن خطایی رخ داد. به
این خاطر تغییراتتان کامل نشد. خواهشمندیم اتصال اینترنتی خود را بررسی کنید.",
"wikibase-error-save-timeout": "در حال حاضر با مشکلات فنیای روبهرو
شدهایم. «ذخیرهسازی» شما کامل نشد.",
"wikibase-error-remove-timeout": "در حال حاضر با مشکلات فنییای روبهرو
شدهایم. «حذفکردن» شما کامل نشد.",
- "wikibase-error-autocomplete-connection": "امکان پرسمان از واسط
برنامهنویسی کاربردی وبگاه وجود نداشت. لطفاً بعداً امتحان کنید.",
+ "wikibase-error-autocomplete-connection": "امکان پرسمان از واسط
برنامهنویسی وبگاه وجود نداشت. لطفاً بعداً امتحان کنید.",
"wikibase-error-autocomplete-response": "پاسخ سرور: $1",
"wikibase-error-ui-no-external-page": "مقالهٔ یادشده در وبگاه مربوطه
پیدا نشد.",
"wikibase-error-ui-edit-conflict": "تعارض ویرایشی رخ داده است.
خواهشمندیم تغییراتتان را به صورت محلی ذخیره کنید از نو صفحه بارگذاری و ذخیره
کنید.",
diff --git a/extensions/Wikibase/lib/i18n/lv.json
b/extensions/Wikibase/lib/i18n/lv.json
index 37854f3..1f49aa6 100644
--- a/extensions/Wikibase/lib/i18n/lv.json
+++ b/extensions/Wikibase/lib/i18n/lv.json
@@ -51,6 +51,9 @@
"wikibase-entity-summary-wbsetlabel-set": "Izmainīja [$2] nosaukumu",
"wikibase-entity-summary-wbsetdescription-set": "Izmainīja [$2]
aprakstu",
"wikibase-entity-summary-wbsetdescription-remove": "Nodzēsa [$2]
aprakstu",
+ "wikibase-entity-summary-wbsetsitelink-add": "Pievienota saite uz [$2]",
+ "wikibase-entity-summary-wbsetsitelink-set": "Mainīta saite uz [$2]",
+ "wikibase-entity-summary-wbsetsitelink-remove": "Noņemta saite uz [$2]",
"wikibase-item-summary-wbeditentity-create": "Izveidots jauns ieraksts",
"wikibase-item-summary-wblinktitles-connect": "Pievienoja valodas
saiti, lai savienotu lapas"
}
diff --git a/extensions/Wikibase/lib/i18n/qqq.json
b/extensions/Wikibase/lib/i18n/qqq.json
index b01a18a..739a442 100644
--- a/extensions/Wikibase/lib/i18n/qqq.json
+++ b/extensions/Wikibase/lib/i18n/qqq.json
@@ -84,6 +84,7 @@
"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-geo-shape": "The name of a data type for
geo-shapes\n{{Identical|Geographic shape}}",
+ "datatypes-type-tabular-data": "The name of a data type for
tabular-data\n{{Identical|Tabular data}}",
"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/extensions/Wikibase/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
b/extensions/Wikibase/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
index adb954e..d7d4f84 100644
---
a/extensions/Wikibase/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
+++
b/extensions/Wikibase/lib/includes/Formatters/WikibaseValueFormatterBuilders.php
@@ -78,11 +78,17 @@
);
/**
+ * @var string
+ */
+ private $tabularDataStorageFrontendUrl;
+
+ /**
* @param Language $defaultLanguage
* @param FormatterLabelDescriptionLookupFactory
$labelDescriptionLookupFactory
* @param LanguageNameLookup $languageNameLookup
* @param EntityIdParser $repoItemUriParser
* @param string $geoShapeStorageFrontendUrl
+ * @param string $tabularDataStorageFrontendUrl
* @param EntityTitleLookup|null $entityTitleLookup
*/
public function __construct(
@@ -91,6 +97,7 @@
LanguageNameLookup $languageNameLookup,
EntityIdParser $repoItemUriParser,
$geoShapeStorageFrontendUrl,
+ $tabularDataStorageFrontendUrl,
EntityTitleLookup $entityTitleLookup = null
) {
Assert::parameterType(
@@ -99,12 +106,19 @@
'$geoShapeStorageFrontendUrl'
);
+ Assert::parameterType(
+ 'string',
+ $tabularDataStorageFrontendUrl,
+ '$tabularDataStorageFrontendUrl'
+ );
+
$this->defaultLanguage = $defaultLanguage;
$this->labelDescriptionLookupFactory =
$labelDescriptionLookupFactory;
$this->languageNameLookup = $languageNameLookup;
$this->repoItemUriParser = $repoItemUriParser;
$this->geoShapeStorageFrontendUrl = $geoShapeStorageFrontendUrl;
$this->entityTitleLookup = $entityTitleLookup;
+ $this->tabularDataStorageFrontendUrl =
$tabularDataStorageFrontendUrl;
}
private function newPlainEntityIdFormatter( FormatterOptions $options )
{
@@ -271,6 +285,23 @@
*
* @return ValueFormatter
*/
+ public function newTabularDataFormatter( $format, FormatterOptions
$options ) {
+ switch ( $this->getBaseFormat( $format ) ) {
+ case SnakFormatter::FORMAT_HTML:
+ return new InterWikiLinkHtmlFormatter(
$this->tabularDataStorageFrontendUrl );
+ case SnakFormatter::FORMAT_WIKI:
+ return new InterWikiLinkWikitextFormatter(
$this->tabularDataStorageFrontendUrl );
+ 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/extensions/Wikibase/lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php
b/extensions/Wikibase/lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php
index a6082ed..e414d0e 100644
---
a/extensions/Wikibase/lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php
+++
b/extensions/Wikibase/lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php
@@ -46,6 +46,8 @@
const GEO_SHAPE_STORAGE_FRONTEND_URL = '//commons.wikimedia.org/wiki/';
+ const TABULAR_DATA_STORAGE_FRONTEND_URL =
'//commons2.wikimedia.org/wiki/';
+
protected function setUp() {
parent::setUp();
@@ -91,6 +93,7 @@
$languageNameLookup,
new ItemIdParser(),
self::GEO_SHAPE_STORAGE_FRONTEND_URL,
+ self::TABULAR_DATA_STORAGE_FRONTEND_URL,
$entityTitleLookup
);
}
@@ -156,6 +159,7 @@
'newUrlFormatter',
'newCommonsMediaFormatter',
'newGeoShapeFormatter',
+ 'newTabularDataFormatter',
'newEntityIdFormatter',
'newMonolingualFormatter',
'newTimeFormatter',
@@ -311,6 +315,31 @@
'@' ) .
'@',
),
+ // tabular-data
+ 'plain tabular-data' => array(
+ 'TabularData',
+ SnakFormatter::FORMAT_PLAIN,
+ $this->newFormatterOptions(),
+ new StringValue( 'Data:TabularData.tab' ),
+ '@^Data:TabularData.tab$@',
+ ),
+ 'html tabular-data' => array(
+ 'TabularData',
+ SnakFormatter::FORMAT_HTML,
+ $this->newFormatterOptions(),
+ new StringValue( 'Data:TabularData.tab' ),
+ '@^<a class="extiw"
href="//commons2\.wikimedia\.org/wiki/Data:TabularData\.tab">Data:TabularData\.tab</a>$@',
+ ),
+ 'wikitext tabular-data' => array(
+ 'TabularData',
+ SnakFormatter::FORMAT_WIKI,
+ $this->newFormatterOptions(),
+ new StringValue( 'Data:TabularData.tab' ),
+ '@' . preg_quote(
+
'[//commons2.wikimedia.org/wiki/Data:TabularData.tab Data:TabularData.tab]',
+ '@'
+ ) . '@',
+ ),
// GlobeCoordinate
'plain coordinate' => array(
'GlobeCoordinate',
diff --git a/extensions/Wikibase/repo/Wikibase.i18n.alias.php
b/extensions/Wikibase/repo/Wikibase.i18n.alias.php
index f8450da..06b8938 100644
--- a/extensions/Wikibase/repo/Wikibase.i18n.alias.php
+++ b/extensions/Wikibase/repo/Wikibase.i18n.alias.php
@@ -12,6 +12,7 @@
/** English (English) */
$specialPageAliases['en'] = array(
+ 'AvailableBadges' => array( 'AvailableBadges' ),
'DispatchStats' => array( 'DispatchStats' ),
'EntitiesWithoutDescription' => array( 'EntitiesWithoutDescription' ),
'EntitiesWithoutLabel' => array( 'EntitiesWithoutLabel' ),
diff --git a/extensions/Wikibase/repo/Wikibase.php
b/extensions/Wikibase/repo/Wikibase.php
index cfb8947..9893290 100644
--- a/extensions/Wikibase/repo/Wikibase.php
+++ b/extensions/Wikibase/repo/Wikibase.php
@@ -842,6 +842,15 @@
)
);
};
+ $wgSpecialPages['AvailableBadges'] = function() {
+ $wikibaseRepo =
Wikibase\Repo\WikibaseRepo::getDefaultInstance();
+
+ return new Wikibase\Repo\Specials\SpecialAvailableBadges(
+ $wikibaseRepo->getPrefetchingTermLookup(),
+ $wikibaseRepo->getEntityTitleLookup(),
+ $wikibaseRepo->getSettings()->getSetting( 'badgeItems' )
+ );
+ };
// Jobs
$wgJobClasses['UpdateRepoOnMove'] =
Wikibase\Repo\UpdateRepo\UpdateRepoOnMoveJob::class;
diff --git a/extensions/Wikibase/repo/WikibaseRepo.datatypes.php
b/extensions/Wikibase/repo/WikibaseRepo.datatypes.php
index a72fcce..cf56d21 100644
--- a/extensions/Wikibase/repo/WikibaseRepo.datatypes.php
+++ b/extensions/Wikibase/repo/WikibaseRepo.datatypes.php
@@ -50,6 +50,7 @@
use Wikibase\Repo\Parsers\TimeParserFactory;
use Wikibase\Repo\Parsers\WikibaseStringValueNormalizer;
use Wikibase\Repo\Rdf\Values\GeoShapeRdfBuilder;
+use Wikibase\Repo\Rdf\Values\TabularDataRdfBuilder;
use Wikibase\Repo\WikibaseRepo;
use Wikimedia\Purtle\RdfWriter;
@@ -134,6 +135,30 @@
return new GeoShapeRdfBuilder();
},
),
+ 'PT:tabular-data' => array(
+ 'validator-factory-callback' => function() {
+ $factory =
WikibaseRepo::getDefaultValidatorBuilders();
+ // Don't go for commons during unit tests.
+ return $factory->buildTabularDataValidators(
+ defined( 'MW_PHPUNIT_TEST' ) ?
'doNotCheckExistence' : 'checkExistence'
+ );
+ },
+ 'parser-factory-callback' => $newStringParser,
+ 'formatter-factory-callback' => function( $format,
FormatterOptions $options ) {
+ $factory =
WikibaseRepo::getDefaultValueFormatterBuilders();
+ return $factory->newTabularDataFormatter(
$format, $options );
+ },
+ 'rdf-builder-factory-callback' => function (
+ $flags,
+ RdfVocabulary $vocab,
+ RdfWriter $writer,
+ EntityMentionListener $tracker,
+ DedupeBag $dedupe
+ ) {
+ // TODO: Implement proper RDF mapping, see
T159517
+ return new TabularDataRdfBuilder();
+ },
+ ),
'VT:globecoordinate' => array(
'validator-factory-callback' => function() {
$factory =
WikibaseRepo::getDefaultValidatorBuilders();
diff --git a/extensions/Wikibase/repo/config/Wikibase.default.php
b/extensions/Wikibase/repo/config/Wikibase.default.php
index 8952526..6050679 100644
--- a/extensions/Wikibase/repo/config/Wikibase.default.php
+++ b/extensions/Wikibase/repo/config/Wikibase.default.php
@@ -191,6 +191,7 @@
'pagePropertiesRdf' => [
'wb-sitelinks' => [ 'name' => 'sitelinks', 'type' => 'integer'
],
'wb-claims' => [ 'name' => 'statements', 'type' => 'integer' ],
+ 'wb-identifiers' => [ 'name' => 'identifiers', 'type' =>
'integer' ],
],
// Map of foreign repository names to repository-specific settings such
as "supportedEntityTypes"
@@ -207,6 +208,14 @@
// Special characters (e.g. space, percent, etc.) in URL should NOT be
encoded
'geoShapeStorageFrontendUrl' => 'https://commons.wikimedia.org/wiki/',
+ // URL of tabular data storage API endpoint
+ 'tabularDataStorageApiEndpointUrl' =>
'https://commons.wikimedia.org/w/api.php',
+
+ // URL of tabular data storage frontend. Used primarily to build links
to the data.
+ // URL will be concatenated with the page title, so should end up with
'/' or 'title='
+ // Special characters (e.g. space, percent, etc.) in URL should NOT be
encoded
+ 'tabularDataStorageFrontendUrl' =>
'https://commons.wikimedia.org/wiki/',
+
// Name of the lock manager for dispatch changes coordinator
'dispatchingLockManager' => null,
diff --git a/extensions/Wikibase/repo/i18n/de.json
b/extensions/Wikibase/repo/i18n/de.json
index 4bdd8bd..ad4072c 100644
--- a/extensions/Wikibase/repo/i18n/de.json
+++ b/extensions/Wikibase/repo/i18n/de.json
@@ -143,6 +143,7 @@
"wikibase-validator-label-no-entityid": "Die Bezeichnung darf keine
gültige Objektkennung sein.",
"wikibase-validator-illegal-file-chars": "Dateinamen dürfen bestimmte
Zeichen wie Doppelpunkte oder Schrägstriche nicht enthalten. Bitte nur den
Dateinamen nach „Datei:“ einfügen.",
"wikibase-validator-illegal-geo-shape-title": "Der Wert muss mit
„Data:“ beginnen und mit „.map“ enden. Zusätzlich sollte der Titel bestimmte
Zeichen wie Doppelpunkte, Rauten oder senkrechte Striche nicht enthalten.",
+ "wikibase-validator-illegal-tabular-data-title": "Der Wert muss mit
„Data:“ beginnen und mit „.tab“ enden. Zusätzlich sollte der Titel bestimmte
Zeichen wie Doppelpunkte, Rauten oder senkrechte Striche nicht enthalten.",
"wikibase-validator-no-such-media": "Die Datei „$1“ ist nicht auf
[https://commons.wikimedia.org/ Wikimedia Commons] vorhanden.",
"wikibase-validator-no-such-sitelink": "Beim Versuch, die
Auszeichnungen zu bearbeiten, konnte kein Websitelink zu „$1“ gefunden werden.",
"wikibase-validator-page-not-exists": "Die Seite „$1“ ist nicht
vorhanden.",
@@ -296,7 +297,6 @@
"wikibase-entitieswithoutlabel-legend": "Hole Liste von Entitäten ohne
Bezeichnung",
"wikibase-entitieswithoutlabel-label-language": "Sprachcode:",
"wikibase-entitieswithoutlabel-label-type": "Typ:",
- "wikibase-entitieswithoutlabel-label-alltypes": "alle",
"wikibase-entitieswithoutlabel-submit": "Finden",
"wikibase-entitieswithoutlabel-invalid-language": "„$1“ ist kein
gültiger Sprachcode.",
"wikibase-entitieswithoutlabel-invalid-type": "„$1“ ist kein gültiger
Objekttyp.",
@@ -348,6 +348,8 @@
"wikibase-listdatatypes-globe-coordinate-body": "Literale Daten für
eine geografische Position, die als Breitengrad-Längengrad-Paar in GMS oder
Dezimalgrad für den Sternenkörper angegeben ist. Standards sind „Erde“,
anschließend „WGS84“. Es wird eine Auflösung und ein Bereich hinzugefügt.\n*
latitude – impliziter erster Teil (float, dms, dm, dd) der Koordinatenkette.
Die Richtung wird entweder mit einem Präfixzeichen oder mit dem Postfix „N/S“
angegeben.\n* longitude – impliziter zweiter Teil (float, dms, dm, dd) der
Koordinatenkette. Die Richtung wird entweder mit einem Präfixzeichen oder mit
dem Postfix „O/W“ angegeben.\n* globe – ausdrücklicher (?) Datenwert, angegeben
als Sternenkörper, dessen Standards auf Erde sind
\"http://www.wikidata.org/entity/Q2\"\n* precision – numerische Genauigkeit der
Koordinate",
"wikibase-listdatatypes-geo-shape-head": "Geografische Form",
"wikibase-listdatatypes-geo-shape-body": "Link auf die geografischen
Kartendaten, die auf Wikimedia Commons oder einem anderen konfigurierten Wiki
gespeichert sind. Siehe https://www.mediawiki.org/wiki/Help:Map_Data für
weitere Dokumentationen über Kartendaten.",
+ "wikibase-listdatatypes-tabular-data-head": "Tabellarische Daten",
+ "wikibase-listdatatypes-tabular-data-body": "Link auf tabellarische
Daten, die auf Wikimedia Commons (oder einem anderen konfigurierten Wiki)
gespeichert sind. Siehe https://www.mediawiki.org/wiki/Help:Tabular_Data für
weitere Dokumentationen über tabellarische Daten.",
"wikibase-listdatatypes-quantity-head": "Menge",
"wikibase-listdatatypes-quantity-body": "Literales Datenfeld für eine
Menge, die sich auf eine Art klar definierte Einheit bezieht. Die tatsächliche
Einheit geht in die Datenwerte, die eingegeben werden.\n* amount – impliziter
Teil der Zeichenkette (Mapping des Einheitspräfixes ist unklar).\n* unit –
impliziter Teil der Zeichenkette, dessen Standards auf „1“ sind (Mapping zum
Standardisieren des Körpers ist unklar).\n* upperbound – Obergrenze der
Menge\n* lowerbound – Untergrenze der Menge",
"wikibase-listdatatypes-monolingualtext-head": "Einsprachiger Text",
diff --git a/extensions/Wikibase/repo/i18n/en.json
b/extensions/Wikibase/repo/i18n/en.json
index eb628bc..900a426 100644
--- a/extensions/Wikibase/repo/i18n/en.json
+++ b/extensions/Wikibase/repo/i18n/en.json
@@ -131,6 +131,7 @@
"wikibase-validator-label-no-entityid": "The label must not be a valid
entity ID.",
"wikibase-validator-illegal-file-chars": "File names are not allowed to
contain characters like colons or slashes. Only paste the file name after
\"File:\", please.",
"wikibase-validator-illegal-geo-shape-title": "Value must start with
\"Data:\" and end with \".map\". In addition title should not contain
characters like colon, hash or pipe.",
+ "wikibase-validator-illegal-tabular-data-title": "Value must start with
\"Data:\" and end with \".tab\". In addition title should not contain
characters like colon, hash or pipe.",
"wikibase-validator-no-such-media": "The file \"$1\" does not exist on
[https://commons.wikimedia.org/ Wikimedia Commons].",
"wikibase-validator-no-such-sitelink": "Could not find a sitelink to
\"$1\" when trying to edit badges.",
"wikibase-validator-page-not-exists": "The page \"$1\" does not exist.",
@@ -147,6 +148,8 @@
"wikibase-wikibaserepopage-invalid-id": "The ID \"$1\" is unknown to
the system. Please use a valid entity ID.",
"wikibase-wikibaserepopage-unresolved-redirect": "$1 is a redirect.",
"wikibase-wikibaserepopage-storage-exception": "An error occurred while
trying to load $1: $2.",
+ "special-availablebadges": "Available badges",
+ "wikibase-availablebadges-emptylist": "There are no badges configured
on this wiki.",
"special-itembytitle": "Item by title",
"wikibase-itembytitle-lookup-fieldset": "Search for items by site and
title",
"wikibase-itembytitle-lookup-site": "Site:",
@@ -377,6 +380,8 @@
"wikibase-listdatatypes-globe-coordinate-body": "Literal data for a
geographical position given as a latitude-longitude pair in gms or decimal
degrees for the given stellar body. Defaults to \"Earth\" and then \"WGS84\".
It adds a resolution and range.\n* latitude – implicit first part (float, dms,
dm, dd) of the coordinate string, direction is either given by prefixed sign or
by postfixed N/S\n* longitude – implicit second part (float, dms, dm, dd) of
the coordinate string, direction is either given by prefixed sign or by
postfixed E/W\n* globe – explicit (?) data value, given as stellar body that
defaults to Earth \"http://www.wikidata.org/entity/Q2\"\n* precision - numeric
precision of the coordinate",
"wikibase-listdatatypes-geo-shape-head": "Geographic shape",
"wikibase-listdatatypes-geo-shape-body": "Link to geographic map data
stored on Wikimedia Commons (or other configured wiki). See
\"https://www.mediawiki.org/wiki/Help:Map_Data\" for more documentation about
map data.",
+ "wikibase-listdatatypes-tabular-data-head": "Tabular data",
+ "wikibase-listdatatypes-tabular-data-body": "Link to tabular data
stored on Wikimedia Commons (or other configured wiki). See
\"https://www.mediawiki.org/wiki/Help:Tabular_Data\" for more documentation
about tabular data.",
"wikibase-listdatatypes-quantity-head": "Quantity",
"wikibase-listdatatypes-quantity-body": "Literal data field for a
quantity that relates to some kind of well-defined unit. The actual unit goes
in the data values that is entered.\n* amount – implicit part of the string
(mapping of unit prefix is unclear)\n* unit – implicit part of the string that
defaults to \"1\" (mapping to standardizing body is unclear)\n* upperbound -
quantity's upper bound\n* lowerbound - quantity's lower bound",
"wikibase-listdatatypes-monolingualtext-head": "Monolingual text",
diff --git a/extensions/Wikibase/repo/i18n/fa.json
b/extensions/Wikibase/repo/i18n/fa.json
index 3c153b0..b9848c6 100644
--- a/extensions/Wikibase/repo/i18n/fa.json
+++ b/extensions/Wikibase/repo/i18n/fa.json
@@ -30,7 +30,7 @@
"wikibase-entity": "جوهره",
"wikibase-entity-item": "آیتم",
"wikibase-entity-property": "خصوصیت",
- "wikibase-entity-query": "کوئری",
+ "wikibase-entity-query": "پرسمان",
"wikibase-edit": "ویرایش",
"wikibase-save": "ذخیره",
"wikibase-cancel": "لغو",
@@ -57,6 +57,7 @@
"wikibase-description-edit-placeholder-language-aware": "توصیف را در $1
وارد کنید",
"wikibase-aliases-edit-placeholder": "وارد کردن تعدادی نام مستعار",
"wikibase-aliases-edit-placeholder-language-aware": "وارد کردن تعدادی
نام مستعار در $1",
+ "wikibase-aliases-edit-label": "نامهای مستعار جداشده توسط خط عمود:",
"wikibase-diffview-reference": "منبع",
"wikibase-diffview-rank": "رتبه",
"wikibase-diffview-rank-preferred": "رتبهٔ مورد نظر",
@@ -177,7 +178,6 @@
"wikibase-newentity-language": "زبان:",
"wikibase-newentity-label": "نام:",
"wikibase-newentity-description": "توضیحات:",
- "wikibase-newentity-aliases": "نامهای مستعار جداشده توسط خط عمود:",
"wikibase-newentity-submit": "ایجاد",
"special-setlabel": "گذاشتن یک نام",
"wikibase-setlabel-introfull": "شما در حال گذاشتن نام به $2 برای [[$1]]
هستید.",
@@ -269,7 +269,6 @@
"wikibase-entitieswithoutlabel-legend": "گرفتن فهرستی از موضوعهای بدون
نام",
"wikibase-entitieswithoutlabel-label-language": "کد زبان:",
"wikibase-entitieswithoutlabel-label-type": "نوع:",
- "wikibase-entitieswithoutlabel-label-alltypes": "همه",
"wikibase-entitieswithoutlabel-submit": "یافتن",
"wikibase-entitieswithoutlabel-invalid-language": "«$1» یک کد زبان
نامعتبر است.",
"wikibase-entitieswithoutlabel-invalid-type": "\"$1\" به دلیل نوع ورودی
قابل پذیرش نیست",
@@ -333,7 +332,7 @@
"datatypes-type-url": "نشانی",
"content-model-wikibase-item": "آیتم ویکیبیس",
"content-model-wikibase-property": "خصوصیت ویکیبیس",
- "content-model-wikibase-query": "کوئری ویکیبیس",
+ "content-model-wikibase-query": "پرسمان ویکیبیس",
"right-item-term": "تغییر جزئیات آیتم (برچسب، توضیحات، نام مستعار)",
"right-item-merge": "ادغام آیتمها",
"right-item-redirect": "ایجاد تغییرمسیر آیتمها",
diff --git a/extensions/Wikibase/repo/i18n/qqq.json
b/extensions/Wikibase/repo/i18n/qqq.json
index 8fb3d5c..aee69df 100644
--- a/extensions/Wikibase/repo/i18n/qqq.json
+++ b/extensions/Wikibase/repo/i18n/qqq.json
@@ -163,6 +163,7 @@
"wikibase-validator-label-no-entityid": "Error message shown when a
user tries to save an item that has a valid entity id as label. Parameters:\n*
$1 is the label.",
"wikibase-validator-illegal-file-chars": "Validator error message shown
when a user tries to link to a Wikimedia Commons media file, but the file name
contains illegal special characters such as slashes or colons.",
"wikibase-validator-illegal-geo-shape-title": "Validator error message
shown when a user tries to link to a geo-shape page, but the page title
contains illegal special characters such as hash.",
+ "wikibase-validator-illegal-tabular-data-title": "Validator error
message shown when a user tries to link to a tabular-data page, but the page
title contains illegal special characters such as hash.",
"wikibase-validator-no-such-media": "Error message shown when a user
tries to add a link to a Wikimedia Commons media file which does not exist.
Parameters:\n* $1 is the name of the file.",
"wikibase-validator-no-such-sitelink": "Error message shown when a user
tries to edit a badges for the site on which the item has no sitelink.
Parameters:\n* $1 - the site id\n\nSee also:\n*
{{msg-mw|wikibase-api-no-such-sitelink}}",
"wikibase-validator-page-not-exists": "Error message shown when a user
tries to add a link to a Wiki page which does not exist. Parameters:\n* $1 is
the name of the page.",
@@ -179,6 +180,8 @@
"wikibase-wikibaserepopage-invalid-id": "Response informing that the
selected entity ID is not valid.\n\nParameters:\n* $1 - the invalid ID",
"wikibase-wikibaserepopage-unresolved-redirect": "Error message shown
when the user supplied an entity ID that refers to a redirect.\nParameters:\n*
$1 - the entity ID",
"wikibase-wikibaserepopage-storage-exception": "Error message shown
when an entity could not be loaded due to a storage layer
exception.\nParameters:\n* $1 - the entity ID\n* $2 - the (unlocalized and
possibly technical) error message.",
+ "special-availablebadges": "{{doc-special|AvailableBadges}}\nTitle of
the page containing a list of all available badges",
+ "wikibase-availablebadges-emptylist": "Message indicating that there
are no available badges.",
"special-itembytitle": "{{doc-special|ItemByTitle}}\nThe item is
identified through use of the site and title, but the lookup failed and further
qualification must be done. See also the Wikidata glossary for
[[d:Wikidata:Glossary#languageattribute-label|label]] and
[[d:Wikidata:Glossary#Items|items]].",
"wikibase-itembytitle-lookup-fieldset": "This is the title for the
fieldset on the special page for further refining the search. This is the
search by site and title.",
"wikibase-itembytitle-lookup-site": "Label for the textfield holding
the site id. See also the Wikidata glossary for
[[d:Wikidata:Glossary#sitelinks|sitelinks]].\n{{Identical|Site}}",
@@ -409,6 +412,8 @@
"wikibase-listdatatypes-globe-coordinate-body":
"{{Wikibase-datatype-body|Globe coordinate}}",
"wikibase-listdatatypes-geo-shape-head": "{{Wikibase-datatype-head|Geo
shape|geo-shape}}\n{{Identical|Geographic shape}}",
"wikibase-listdatatypes-geo-shape-body": "{{Wikibase-datatype-body|Geo
shape}}",
+ "wikibase-listdatatypes-tabular-data-head":
"{{Wikibase-datatype-head|Tabular data|tabular-data}}\n{{Identical|Tabular
data}}",
+ "wikibase-listdatatypes-tabular-data-body":
"{{Wikibase-datatype-body|Tabular data}}",
"wikibase-listdatatypes-quantity-head":
"{{Wikibase-datatype-head|Quantity}}\n{{Identical|Quantity}}",
"wikibase-listdatatypes-quantity-body":
"{{Wikibase-datatype-body|Quantity}}",
"wikibase-listdatatypes-monolingualtext-head":
"{{Wikibase-datatype-head|Monolingual
text|monolingualtext}}\n{{Identical|Monolingual text}}",
diff --git a/extensions/Wikibase/repo/includes/Content/ItemContent.php
b/extensions/Wikibase/repo/includes/Content/ItemContent.php
index 6aa8dce..2789569 100644
--- a/extensions/Wikibase/repo/includes/Content/ItemContent.php
+++ b/extensions/Wikibase/repo/includes/Content/ItemContent.php
@@ -47,8 +47,6 @@
* @param EntityHolder|null $itemHolder
* @param EntityRedirect|null $entityRedirect
* @param Title|null $redirectTitle Title of the redirect target.
- *
- * @throws InvalidArgumentException
*/
public function __construct(
EntityHolder $itemHolder = null,
@@ -229,6 +227,8 @@
$item = $this->getItem();
$properties['wb-claims'] =
$item->getStatements()->count();
$properties['wb-sitelinks'] =
$item->getSiteLinkList()->count();
+ $properties['wb-identifiers'] =
$this->getContentHandler()
+ ->getIdentifiersCount( $item->getStatements() );
}
return $properties;
diff --git a/extensions/Wikibase/repo/includes/Content/ItemHandler.php
b/extensions/Wikibase/repo/includes/Content/ItemHandler.php
index 34b0daa..6205c7d 100644
--- a/extensions/Wikibase/repo/includes/Content/ItemHandler.php
+++ b/extensions/Wikibase/repo/includes/Content/ItemHandler.php
@@ -11,6 +11,9 @@
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\EntityIdParser;
+use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup;
+use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookupException;
+use Wikibase\DataModel\Statement\StatementList;
use Wikibase\EditEntityAction;
use Wikibase\EntityContent;
use Wikibase\HistoryEntityAction;
@@ -53,6 +56,11 @@
private $labelLookupFactory;
/**
+ * @var PropertyDataTypeLookup
+ */
+ private $dataTypeLookup;
+
+ /**
* @param EntityPerPage $entityPerPage
* @param TermIndex $termIndex
* @param EntityContentDataCodec $contentCodec
@@ -63,6 +71,7 @@
* @param EntityIdLookup $entityIdLookup
* @param LanguageFallbackLabelDescriptionLookupFactory
$labelLookupFactory
* @param ItemFieldDefinitions $itemFieldDefinitions
+ * @param PropertyDataTypeLookup $dataTypeLookup
* @param callable|null $legacyExportFormatDetector
*/
public function __construct(
@@ -76,6 +85,7 @@
EntityIdLookup $entityIdLookup,
LanguageFallbackLabelDescriptionLookupFactory
$labelLookupFactory,
ItemFieldDefinitions $itemFieldDefinitions,
+ PropertyDataTypeLookup $dataTypeLookup,
$legacyExportFormatDetector = null
) {
parent::__construct(
@@ -93,6 +103,7 @@
$this->entityIdLookup = $entityIdLookup;
$this->labelLookupFactory = $labelLookupFactory;
$this->siteLinkStore = $siteLinkStore;
+ $this->dataTypeLookup = $dataTypeLookup;
}
/**
@@ -216,4 +227,25 @@
return new ItemId( $id );
}
+ /**
+ * @param StatementList $statementList
+ * @return int
+ */
+ public function getIdentifiersCount( StatementList $statementList ) {
+ $identifiers = 0;
+ foreach ( $statementList->getPropertyIds() as
$propertyIdSerialization => $propertyId ) {
+ try {
+ $dataType =
$this->dataTypeLookup->getDataTypeIdForProperty( $propertyId );
+ } catch ( PropertyDataTypeLookupException $e ) {
+ continue;
+ }
+
+ if ( $dataType === 'external-id' ) {
+ $identifiers +=
$statementList->getByPropertyId( $propertyId )->count();
+ }
+ }
+
+ return $identifiers;
+ }
+
}
diff --git a/extensions/Wikibase/repo/includes/Hooks/LinkBeginHookHandler.php
b/extensions/Wikibase/repo/includes/Hooks/LinkBeginHookHandler.php
index bd3d266..439bf26 100644
--- a/extensions/Wikibase/repo/includes/Hooks/LinkBeginHookHandler.php
+++ b/extensions/Wikibase/repo/includes/Hooks/LinkBeginHookHandler.php
@@ -172,9 +172,10 @@
$outTitle = $out->getTitle();
$targetIsForeignEntityPage = $this->isForeignEntityPage(
$target );
+ $isLocal = !$targetIsForeignEntityPage;
- if ( !$targetIsForeignEntityPage &&
- !$this->entityNamespaceLookup->isEntityNamespace(
$target->getNamespace() )
+ if ( $isLocal
+ && !$this->entityNamespaceLookup->isEntityNamespace(
$target->getNamespace() )
) {
return;
}
@@ -200,11 +201,10 @@
if ( SpecialPageFactory::exists( $targetText ) ) {
$target = Title::makeTitle( NS_SPECIAL, $targetText );
$html = $this->linkRenderer->makeKnownLink( $target );
-
return;
}
- if ( !$targetIsForeignEntityPage && !$target->exists() ) {
+ if ( $isLocal && !$target->exists() ) {
// The link points to a non-existing item.
return;
}
@@ -256,11 +256,8 @@
*/
private function isForeignEntityPage( LinkTarget $target ) {
$interwiki = $target->getInterwiki();
- if ( $interwiki === '' ) {
- return false;
- }
- if ( !$this->interwikiLookup->isValidInterwiki( $interwiki ) ) {
+ if ( $interwiki === '' ||
!$this->interwikiLookup->isValidInterwiki( $interwiki ) ) {
return false;
}
@@ -284,16 +281,19 @@
*/
private function getEntityIdFromTarget( Title $target ) {
if ( $this->isForeignEntityPage( $target ) ) {
+ $interwiki = $target->getInterwiki();
$idPart = substr( $target->getText(), strlen(
'Special:EntityPage/' ) );
- // FIXME: This assumes repository name is equal to
interwiki. This assumption might become invalid
+
try {
+ // FIXME: This assumes repository name is equal
to interwiki. This assumption might
+ // become invalid
return $this->entityIdParser->parse(
- EntityId::joinSerialization( [
$target->getInterwiki(), '', $idPart ] )
+ EntityId::joinSerialization( [
$interwiki, '', $idPart ] )
);
} catch ( EntityIdParsingException $ex ) {
}
- return null;
+ return null;
}
return $this->entityIdLookup->getEntityIdForTitle( $target );
diff --git
a/extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php
b/extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php
new file mode 100644
index 0000000..95844cb
--- /dev/null
+++ b/extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Wikibase\Repo\Rdf\Values;
+
+use Wikibase\DataModel\Snak\PropertyValueSnak;
+use Wikibase\Rdf\ValueSnakRdfBuilder;
+use Wikimedia\Purtle\RdfWriter;
+
+/**
+ * @license GPL-2.0+
+ * @author Thiemo Mättig
+ */
+class TabularDataRdfBuilder implements ValueSnakRdfBuilder {
+
+ /**
+ * @param RdfWriter $writer
+ * @param string $propertyValueNamespace
+ * @param string $propertyValueLName
+ * @param string $dataType
+ * @param PropertyValueSnak $snak
+ */
+ public function addValue(
+ RdfWriter $writer,
+ $propertyValueNamespace,
+ $propertyValueLName,
+ $dataType,
+ PropertyValueSnak $snak
+ ) {
+ // TODO: Implement proper RDF mapping, see T159517
+ }
+
+}
diff --git
a/extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php
b/extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php
new file mode 100644
index 0000000..efa26e8
--- /dev/null
+++ b/extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php
@@ -0,0 +1,107 @@
+<?php
+
+namespace Wikibase\Repo\Specials;
+
+use Html;
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\DataModel\Entity\ItemIdParser;
+use Wikibase\Lib\Store\EntityTitleLookup;
+use Wikibase\Lib\Store\PrefetchingTermLookup;
+
+/**
+ * Page for listing all available badges.
+ *
+ * @license GPL-2.0+
+ * @author Victor Barbu < [email protected] >
+ * @author Amir Sarabadani <[email protected]>
+ */
+class SpecialAvailableBadges extends SpecialWikibasePage {
+
+ /**
+ * @var PrefetchingTermLookup
+ */
+ private $prefetchingTermLookup;
+
+ /**
+ * @var EntityTitleLookup
+ */
+ private $entityTitleLookup;
+
+ /**
+ * @var string[]
+ */
+ private $badgeItems;
+
+ public function __construct(
+ PrefetchingTermLookup $prefetchingTermLookup,
+ EntityTitleLookup $entityTitleLookup,
+ array $badgeItems
+ ) {
+ parent::__construct( 'AvailableBadges' );
+
+ $this->prefetchingTermLookup = $prefetchingTermLookup;
+ $this->entityTitleLookup = $entityTitleLookup;
+ $this->badgeItems = $badgeItems;
+ }
+
+ public function execute( $subPage ) {
+ parent::execute( $subPage );
+
+ $this->displayResult();
+ }
+
+ private function displayResult() {
+ $out = $this->getOutput();
+ // XXX: Maybe we should use PrefixMappingEntityIdParser for
federation?
+ $itemIdParser = new ItemIdParser();
+
+ $itemIds = array_map( function( $item ) use ( $itemIdParser ) {
+ return $itemIdParser->parse( $item );
+ }, array_keys( $this->badgeItems ) );
+
+ if ( empty( $itemIds ) ) {
+ $out->addHTML( Html::element(
+ 'p',
+ [],
+ $this->msg(
'wikibase-availablebadges-emptylist' )->text()
+ ) );
+
+ return;
+ }
+
+ $this->prefetchingTermLookup->prefetchTerms( $itemIds );
+
+ $out->addHTML( Html::openElement( 'ol' ) );
+ foreach ( $itemIds as $item ) {
+ $this->displayRow( $item,
$this->badgeItems[$item->getSerialization()] );
+ }
+ $out->addHTML( Html::closeElement( 'ol' ) );
+ }
+
+ /**
+ * Render one badge.
+ *
+ * @param ItemId $item Item ID to render
+ * @param string $badgeClass The given badge class
+ */
+ private function displayRow( ItemId $item, $badgeClass ) {
+ $out = $this->getOutput();
+
+ $title = $this->entityTitleLookup->getTitleForId( $item );
+ $description = $this->prefetchingTermLookup->getDescription(
+ $item,
+ $this->getLanguage()->getCode()
+ );
+
+ $out->addHTML( Html::openElement( 'li' ) );
+ $out->addHTML( Html::element( 'span', [
+ 'class' => 'wb-badge ' . $badgeClass,
+ ] ) );
+ $out->addHTML( $this->getLinkRenderer()->makeLink( $title ) );
+ if ( $description !== null ) {
+ $out->addHTML( ' - ' . $description );
+ }
+ $out->addHTML( Html::closeElement( 'li' ) );
+ }
+
+}
diff --git a/extensions/Wikibase/repo/includes/ValidatorBuilders.php
b/extensions/Wikibase/repo/includes/ValidatorBuilders.php
index f11a072..6764660 100644
--- a/extensions/Wikibase/repo/includes/ValidatorBuilders.php
+++ b/extensions/Wikibase/repo/includes/ValidatorBuilders.php
@@ -98,6 +98,11 @@
private $geoShapeStorageApiUrl;
/**
+ * @var string
+ */
+ private $tabularDataStorageApiUrl;
+
+ /**
* @param EntityLookup $lookup
* @param EntityIdParser $idParser
* @param string[] $urlSchemes
@@ -107,6 +112,7 @@
* @param array $supportedEntityTypes map of repository names to lists
of supported entity types
* @param MediaWikiPageNameNormalizer $mediaWikiPageNameNormalizer
* @param string $geoShapeStorageApiUrl
+ * @param string $tabularDataStorageApiUrl
*/
public function __construct(
EntityLookup $lookup,
@@ -117,7 +123,8 @@
CachingCommonsMediaFileNameLookup
$cachingCommonsMediaFileNameLookup,
array $supportedEntityTypes,
MediaWikiPageNameNormalizer $mediaWikiPageNameNormalizer,
- $geoShapeStorageApiUrl
+ $geoShapeStorageApiUrl,
+ $tabularDataStorageApiUrl
) {
$this->entityLookup = $lookup;
$this->entityIdParser = $idParser;
@@ -128,6 +135,7 @@
$this->supportedEntityTypes = $supportedEntityTypes;
$this->mediaWikiPageNameNormalizer =
$mediaWikiPageNameNormalizer;
$this->geoShapeStorageApiUrl = $geoShapeStorageApiUrl;
+ $this->tabularDataStorageApiUrl = $tabularDataStorageApiUrl;
}
/**
@@ -240,6 +248,32 @@
}
/**
+ * @param string $checkExistence Either 'checkExistence' or
'doNotCheckExistence'
+ *
+ * @return ValueValidator[]
+ */
+ public function buildTabularDataValidators( $checkExistence =
'checkExistence' ) {
+ $validators = $this->getCommonStringValidators( 240 );
+ $validators[] = new RegexValidator(
+ '/^Data:[^\\[\\]#\\\:{|}]+\.tab$/u',
+ false,
+ 'illegal-tabular-data-title'
+ );
+ if ( $checkExistence === 'checkExistence' ) {
+ $validators[] = new InterWikiLinkExistsValidator(
+ $this->mediaWikiPageNameNormalizer,
+ $this->tabularDataStorageApiUrl
+ );
+ }
+
+ $topValidator = new DataValueValidator(
+ new CompositeValidator( $validators )
+ );
+
+ return array( new TypeValidator( DataValue::class ),
$topValidator );
+ }
+
+ /**
* @return ValueValidator[]
*/
public function buildStringValidators() {
diff --git a/extensions/Wikibase/repo/includes/WikibaseRepo.php
b/extensions/Wikibase/repo/includes/WikibaseRepo.php
index f742288..0ca08a9 100644
--- a/extensions/Wikibase/repo/includes/WikibaseRepo.php
+++ b/extensions/Wikibase/repo/includes/WikibaseRepo.php
@@ -412,7 +412,8 @@
$this->getCachingCommonsMediaFileNameLookup(),
$this->repositoryDefinitions->getEntityTypesPerRepository(),
new MediaWikiPageNameNormalizer(),
- $this->settings->getSetting(
'geoShapeStorageApiEndpointUrl' )
+ $this->settings->getSetting(
'geoShapeStorageApiEndpointUrl' ),
+ $this->settings->getSetting(
'tabularDataStorageApiEndpointUrl' )
);
}
@@ -448,6 +449,7 @@
$this->getLanguageNameLookup(),
$this->getLocalItemUriParser(),
$this->getSettings()->getSetting(
'geoShapeStorageFrontendUrl' ),
+ $this->getSettings()->getSetting(
'tabularDataStorageFrontendUrl' ),
$this->getEntityTitleLookup()
);
}
@@ -1493,6 +1495,7 @@
$this->getEntityIdLookup(),
$this->getLanguageFallbackLabelDescriptionLookupFactory(),
$this->getItemFieldDefinitions(),
+ $this->getPropertyDataTypeLookup(),
$legacyFormatDetector
);
diff --git a/extensions/Wikibase/repo/resources/Resources.php
b/extensions/Wikibase/repo/resources/Resources.php
index 33975fd..89940bf 100644
--- a/extensions/Wikibase/repo/resources/Resources.php
+++ b/extensions/Wikibase/repo/resources/Resources.php
@@ -64,6 +64,16 @@
},
],
+ 'mw.config.values.wbTabularDataStorageApiEndpoint' =>
$moduleTemplate + [
+ 'class' => MediaWikiConfigModule::class,
+ 'getconfigvalueprovider' => function () {
+ return
WikibaseRepo::getDefaultInstance()->getSettingsValueProvider(
+ 'wbTabularDataStorageApiEndpoint',
+ 'tabularDataStorageApiEndpointUrl'
+ );
+ },
+ ],
+
'wikibase.dataTypeStore' => $moduleTemplate + array(
'scripts' => array(
'dataTypes/wikibase.dataTypeStore.js',
diff --git a/extensions/Wikibase/repo/resources/experts/getStore.js
b/extensions/Wikibase/repo/resources/experts/getStore.js
index 7dbc361..e153006 100644
--- a/extensions/Wikibase/repo/resources/experts/getStore.js
+++ b/extensions/Wikibase/repo/resources/experts/getStore.js
@@ -44,6 +44,7 @@
var dataTypeIdToExpertConstructor = {
commonsMedia: vv.experts.CommonsMediaType,
'geo-shape': vv.experts.GeoShape,
+ 'tabular-data': vv.experts.TabularData,
'external-id': vv.experts.StringValue,
monolingualtext: vv.experts.MonolingualText,
url: vv.experts.StringValue,
diff --git a/extensions/Wikibase/repo/resources/experts/resources.php
b/extensions/Wikibase/repo/resources/experts/resources.php
index b6ab8c8..2706b6e 100644
--- a/extensions/Wikibase/repo/resources/experts/resources.php
+++ b/extensions/Wikibase/repo/resources/experts/resources.php
@@ -38,6 +38,7 @@
'jquery.valueview.experts.MonolingualText',
'jquery.valueview.experts.QuantityInput',
'jquery.valueview.experts.StringValue',
+ 'jquery.valueview.experts.TabularData',
'jquery.valueview.experts.TimeInput',
'jquery.valueview.experts.UnDeserializableValue',
'jquery.valueview.experts.UnsupportedValue',
diff --git a/extensions/Wikibase/repo/resources/parsers/getStore.js
b/extensions/Wikibase/repo/resources/parsers/getStore.js
index 3908ba9..255393d 100644
--- a/extensions/Wikibase/repo/resources/parsers/getStore.js
+++ b/extensions/Wikibase/repo/resources/parsers/getStore.js
@@ -59,6 +59,14 @@
parserStore.registerDataTypeParser(
util.inherit(
ApiBasedValueParser,
+ { API_VALUE_PARSER_ID: 'tabular-data' }
+ ),
+ 'tabular-data'
+ );
+
+ parserStore.registerDataTypeParser(
+ util.inherit(
+ ApiBasedValueParser,
{ API_VALUE_PARSER_ID: 'url' }
),
'url'
diff --git a/extensions/Wikibase/repo/resources/wikibase.ui.entityViewInit.js
b/extensions/Wikibase/repo/resources/wikibase.ui.entityViewInit.js
index b4e0890..2312bf3 100644
--- a/extensions/Wikibase/repo/resources/wikibase.ui.entityViewInit.js
+++ b/extensions/Wikibase/repo/resources/wikibase.ui.entityViewInit.js
@@ -104,7 +104,8 @@
parserStore,
userLanguages,
repoApiUrl,
- mw.config.get( 'wbGeoShapeStorageApiEndpoint' )
+ mw.config.get( 'wbGeoShapeStorageApiEndpoint' ),
+ mw.config.get(
'wbTabularDataStorageApiEndpoint' )
],
startEditingCallback = function() {
return $.Deferred().resolve().promise();
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemContentTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemContentTest.php
index 41f74ce..8f353e8 100644
---
a/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemContentTest.php
+++
b/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemContentTest.php
@@ -2,23 +2,30 @@
namespace Wikibase\Repo\Tests\Content;
+use DataValues\StringValue;
use Diff\DiffOp\Diff\Diff;
use Diff\DiffOp\DiffOpAdd;
use Diff\DiffOp\DiffOpRemove;
use InvalidArgumentException;
use Title;
+use Wikibase\Content\EntityInstanceHolder;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityRedirect;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\Services\Diff\EntityDiff;
+use Wikibase\DataModel\Services\Lookup\InMemoryDataTypeLookup;
+use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup;
use Wikibase\DataModel\SiteLink;
use Wikibase\DataModel\SiteLinkList;
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
+use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\EntityContent;
use Wikibase\ItemContent;
use Wikibase\Repo\Content\EntityContentDiff;
+use Wikibase\Repo\Content\ItemHandler;
+use Wikibase\Repo\Search\Elastic\Fields\ItemFieldDefinitions;
use Wikibase\Repo\WikibaseRepo;
/**
@@ -160,6 +167,64 @@
/**
* @return EntityContent
*/
+ private function getItemContentWithIdentifierClaims() {
+
+ $item = new Item( new ItemId( 'Q2' ) );
+ $snak = new PropertyValueSnak( new PropertyId( 'P11' ), new
StringValue( 'Tehran' ) );
+ $guid = $item->getId()->getSerialization() .
'$D8404CDA-25E4-4334-AG93-A3290BCD9C0P';
+ $item->getStatements()->addNewStatement( $snak, null, null,
$guid );
+
+ $itemContent = $this->getMockBuilder( ItemContent::class )
+ ->setConstructorArgs( [ new EntityInstanceHolder( $item
) ] )
+ ->setMethods( [ 'getContentHandler' ] )
+ ->getMock();
+
+ $handler = $this->getItemHandler();
+ $itemContent->expects( $this->any() )
+ ->method( 'getContentHandler' )
+ ->will( $this->returnValue( $handler ) );
+
+ return $itemContent;
+ }
+
+ /**
+ * @return PropertyDataTypeLookup
+ */
+ private function getPropertyDataTypeLookup() {
+ $dataTypeLookup = new InMemoryDataTypeLookup();
+
+ $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P11'
), 'external-id' );
+
+ return $dataTypeLookup;
+ }
+
+ /**
+ * @return ItemHandler
+ */
+ private function getItemHandler() {
+ $wikibaseRepo = WikibaseRepo::getDefaultInstance();
+ $itemFieldDefinitions = $this->getMockBuilder(
ItemFieldDefinitions::class )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ return new ItemHandler(
+ $wikibaseRepo->getStore()->newEntityPerPage(),
+ $wikibaseRepo->getStore()->getTermIndex(),
+ $wikibaseRepo->getEntityContentDataCodec(),
+ $wikibaseRepo->getEntityConstraintProvider(),
+ $wikibaseRepo->getValidatorErrorLocalizer(),
+ $wikibaseRepo->getEntityIdParser(),
+ $wikibaseRepo->getStore()->newSiteLinkStore(),
+ $wikibaseRepo->getEntityIdLookup(),
+
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory(),
+ $itemFieldDefinitions,
+ $this->getPropertyDataTypeLookup()
+ );
+ }
+
+ /**
+ * @return EntityContent
+ */
private function getItemContentWithSiteLink() {
$itemContent = $this->newEmpty();
$item = $itemContent->getItem();
@@ -177,6 +242,7 @@
// expect wb-sitelinks => 0 for all inherited cases
foreach ( $cases as &$case ) {
$case[1]['wb-sitelinks'] = 0;
+ $case[1]['wb-identifiers'] = 0;
}
$cases['redirect'] = array(
@@ -191,6 +257,7 @@
$this->getItemContentWithClaim(),
array(
'wb-claims' => 1,
+ 'wb-identifiers' => 0,
'wb-sitelinks' => 0,
)
);
@@ -199,10 +266,20 @@
$this->getItemContentWithSiteLink(),
array(
'wb-claims' => 0,
+ 'wb-identifiers' => 0,
'wb-sitelinks' => 1,
)
);
+ $cases['identifiers'] = [
+ $this->getItemContentWithIdentifierClaims(),
+ [
+ 'wb-claims' => 1,
+ 'wb-identifiers' => 1,
+ 'wb-sitelinks' => 0,
+ ]
+ ];
+
return $cases;
}
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemHandlerTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemHandlerTest.php
index 9841a08..2e2d843 100644
---
a/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemHandlerTest.php
+++
b/extensions/Wikibase/repo/tests/phpunit/includes/Content/ItemHandlerTest.php
@@ -2,6 +2,7 @@
namespace Wikibase\Repo\Tests\Content;
+use DataValues\StringValue;
use MWException;
use Wikibase\Content\EntityInstanceHolder;
use Wikibase\DataModel\Entity\EntityDocument;
@@ -10,10 +11,17 @@
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\PropertyId;
+use Wikibase\DataModel\Services\Lookup\InMemoryDataTypeLookup;
+use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup;
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
+use Wikibase\DataModel\Snak\PropertyValueSnak;
+use Wikibase\DataModel\Statement\Statement;
+use Wikibase\DataModel\Statement\StatementList;
use Wikibase\EntityContent;
use Wikibase\ItemContent;
use Wikibase\Repo\Content\ItemHandler;
+use Wikibase\Repo\Search\Elastic\Fields\ItemFieldDefinitions;
+use Wikibase\Repo\WikibaseRepo;
use Wikibase\SettingsArray;
/**
@@ -189,4 +197,82 @@
return [ 'label_count', 'statement_count', 'sitelink_count' ];
}
+ /**
+ * @return PropertyDataTypeLookup
+ */
+ private function getPropertyDataTypeLookup() {
+ $dataTypeLookup = new InMemoryDataTypeLookup();
+
+ $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P11'
), 'external-id' );
+ $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P12'
), 'string' );
+ $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P13'
), 'item' );
+
+ return $dataTypeLookup;
+ }
+
+ /**
+ * @return ItemHandler
+ */
+ private function getItemHandlerWithMockedPropertyDataTypeLookup() {
+ $wikibaseRepo = WikibaseRepo::getDefaultInstance();
+ $itemFieldDefinitions = $this->getMockBuilder(
ItemFieldDefinitions::class )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ return new ItemHandler(
+ $wikibaseRepo->getStore()->newEntityPerPage(),
+ $wikibaseRepo->getStore()->getTermIndex(),
+ $wikibaseRepo->getEntityContentDataCodec(),
+ $wikibaseRepo->getEntityConstraintProvider(),
+ $wikibaseRepo->getValidatorErrorLocalizer(),
+ $wikibaseRepo->getEntityIdParser(),
+ $wikibaseRepo->getStore()->newSiteLinkStore(),
+ $wikibaseRepo->getEntityIdLookup(),
+
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory(),
+ $itemFieldDefinitions,
+ $this->getPropertyDataTypeLookup()
+ );
+ }
+
+ /**
+ * @dataProvider provideGetIdentifiersCount
+ */
+ public function testGetIdentifiersCount( StatementList $statementList,
$expected ) {
+ $handler =
$this->getItemHandlerWithMockedPropertyDataTypeLookup();
+
+ $this->assertSame( $expected, $handler->getIdentifiersCount(
$statementList ) );
+ }
+
+ public function provideGetIdentifiersCount() {
+
+ $statementIdentifier = new Statement(
+ new PropertyValueSnak( new PropertyId( 'P11' ), new
StringValue( 'xyz123' ) )
+ );
+ $statementString = new Statement(
+ new PropertyValueSnak( new PropertyId( 'P12' ), new
StringValue( 'Athena' ) )
+ );
+ $statementItem = new Statement( new PropertyNoValueSnak( new
PropertyId( 'P13' ) ) );
+
+ $statementListNoIdentifier = new StatementList( [
$statementString ] );
+ $statementListOneIdentifier = new StatementList( [
$statementIdentifier ] );
+ $statementListOneIdentifierAndMore = new StatementList(
+ [ $statementIdentifier, $statementString,
$statementItem ]
+ );
+ $statementListTwoIdentifiers = new StatementList(
+ [ $statementIdentifier, $statementIdentifier ]
+ );
+ $statementListTwoIdentifiersAndMore = new StatementList(
+ [ $statementIdentifier, $statementIdentifier,
$statementString, $statementItem ]
+ );
+
+ return [
+ 'empty' => [ new StatementList(), 0 ],
+ 'no identifier' => [ $statementListNoIdentifier, 0 ],
+ 'one identifier' => [ $statementListOneIdentifier, 1 ],
+ 'one identifier and more statements' => [
$statementListOneIdentifierAndMore, 1 ],
+ 'two identifiers' => [ $statementListTwoIdentifiers, 2
],
+ 'two identifiers and more statements' => [
$statementListTwoIdentifiersAndMore, 2 ],
+ ];
+ }
+
}
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php
new file mode 100644
index 0000000..8765146
--- /dev/null
+++
b/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Wikibase\Repo\Tests\Specials;
+
+use Language;
+use SpecialPageTestBase;
+use Title;
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Lib\Store\EntityTitleLookup;
+use Wikibase\Lib\Store\PrefetchingTermLookup;
+use Wikibase\Repo\Specials\SpecialAvailableBadges;
+
+/**
+ * @covers Wikibase\Repo\Specials\SpecialAvailableBadges
+ *
+ * @group Wikibase
+ * @group SpecialPage
+ * @group WikibaseSpecialPage
+ *
+ * @license GPL-2.0+
+ * @author Amir Sarabadani <[email protected]>
+ */
+class SpecialAvailableBadgesTest extends SpecialPageTestBase {
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( [ 'wgContLang' => Language::factory( 'qqx'
) ] );
+ }
+
+ protected function newSpecialPage() {
+ $prefetchingTermLookup = $this->getMockBuilder(
PrefetchingTermLookup::class )->getMock();
+ $prefetchingTermLookup->expects( $this->any() )
+ ->method( 'getDescription' )
+ ->willReturn( 'Test badge item' );
+
+ $entityTitleLookup = $this->getMockBuilder(
EntityTitleLookup::class )->getMock();
+ $entityTitleLookup->expects( $this->any() )
+ ->method( 'getTitleForId' )
+ ->willReturnCallback( function ( ItemId $itemId ) {
+ return Title::makeTitle( 0,
$itemId->getSerialization() );
+ } );
+
+ $badgeItems = [ 'Q4' => 'test-badge' ];
+ return new SpecialAvailableBadges(
+ $prefetchingTermLookup,
+ $entityTitleLookup,
+ $badgeItems
+ );
+ }
+
+ public function testExecute() {
+ list( $output, ) = $this->executeSpecialPage( '' );
+
+ $this->assertInternalType( 'string', $output );
+ $this->assertContains( 'mw-specialpage-summary', $output );
+ $this->assertContains( 'wikibase-availablebadges-summary',
$output );
+
+ $this->assertContains( '<li><span class="wb-badge
test-badge"></span>', $output );
+ $this->assertContains( 'Q4', $output );
+ $this->assertContains( 'Test badge item', $output );
+ }
+
+}
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/ValidatorBuildersTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/ValidatorBuildersTest.php
index 31d8f8d..023d3f5 100644
--- a/extensions/Wikibase/repo/tests/phpunit/includes/ValidatorBuildersTest.php
+++ b/extensions/Wikibase/repo/tests/phpunit/includes/ValidatorBuildersTest.php
@@ -41,6 +41,8 @@
const GEO_SHAPE_STORAGE_API_URL = 'http://some.wiki/api.php';
+ const TABULAR_DATA_STORAGE_API_URL = 'http://another.wiki/api.php';
+
private function newValidatorBuilders() {
return new ValidatorBuilders(
$this->getEntityLookup(),
@@ -54,7 +56,8 @@
'foo' => [ Item::ENTITY_TYPE ]
],
$this->getMediaWikiPageNameNormalizer(),
- self::GEO_SHAPE_STORAGE_API_URL
+ self::GEO_SHAPE_STORAGE_API_URL,
+ self::TABULAR_DATA_STORAGE_API_URL
);
}
@@ -183,6 +186,41 @@
public function testGeoShapeValidation( $geoShapeTitle, $expected ) {
$value = new StringValue( $geoShapeTitle );
$validators =
$this->newValidatorBuilders()->buildGeoShapeValidators();
+
+ $this->assertValidation( $expected, $validators, $value );
+ }
+
+ public function provideTabularDataValidation() {
+ return [
+ 'Should not be empty' => [ '', false ],
+ 'Too long' => [ 'Data:' . str_repeat( 'x', 232 ) .
'.tab', false ],
+ 'Should have extension' => [ 'Data:Foo', false ],
+ 'Extension too short' => [ 'Data:Foo.a', false ],
+ 'This should be good' => [ 'Data:Foo.tab', true ],
+ 'Should have Data namespace' => [ 'Foo.tab', false ],
+ 'Illegal character: newline' => [ "Data:a\na.tab",
false ],
+ 'Illegal character: open square bracket' => [
'Data:a[a.tab', false ],
+ 'Illegal character: close square bracket' => [
'Data:a]a.tab', false ],
+ 'Illegal character: open curly bracket' => [
'Data:a{a.tab', false ],
+ 'Illegal character: close curly bracket' => [
'Data:a}a.tab', false ],
+ 'Illegal character: pipe' => [ 'Data:a|a.tab', false ],
+ 'Illegal character: hash' => [ 'Data:Foo#bar.tab',
false ],
+ 'Illegal character: colon' => [ 'Data:Foo:bar.tab',
false ],
+ 'Allowed character: slash' => [ 'Data:Foo/bar.tab',
true ],
+ 'Illegal character: backslash' => [ 'Data:Foo\bar.tab',
false ],
+ 'Unicode support' => [ 'Data:Äöü.tab', true ],
+ 'Leading space' => [ ' Data:Foo.tab', false ],
+ 'Trailing space' => [ 'Data:Foo.tab ', false ],
+ 'Not found' => [ 'Data:Foo-NOT-FOUND.tab', false ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideTabularDataValidation
+ */
+ public function testTabularDataValidation( $tabularDataTitle, $expected
) {
+ $value = new StringValue( $tabularDataTitle );
+ $validators =
$this->newValidatorBuilders()->buildTabularDataValidators();
$this->assertValidation( $expected, $validators, $value );
}
@@ -380,6 +418,18 @@
'GeoShape expected StringValue, string supplied' => [
'geo-shape', 'Foo.map', false ],
'GeoShape expected StringValue, NumberValue supplied'
=> [ 'geo-shape', new NumberValue( 7 ), false ],
+ //tabular-data
+ 'TabularData expected StringValue, string supplied' => [
+ 'tabular-data',
+ 'Foo.tab',
+ false
+ ],
+ 'TabularData expected StringValue, NumberValue
supplied' => [
+ 'tabular-data',
+ new NumberValue( 7 ),
+ false
+ ],
+
//string
'String expects StringValue, got string' => [ 'string',
'Foo', false ],
'String expects StringValue' => [ 'string', new
NumberValue( 7 ), false ],
@@ -426,6 +476,7 @@
'monolingualtext' => array( $builders,
'buildMonolingualTextValidators' ),
'quantity' => array( $builders,
'buildQuantityValidators' ),
'string' => array( $builders,
'buildStringValidators' ),
+ 'tabular-data' => array( $builders,
'buildTabularDataValidators' ),
'time' => array( $builders,
'buildTimeValidators' ),
'url' => array( $builders,
'buildUrlValidators' ),
'wikibase-entity' => array( $builders,
'buildEntityValidators' ),
diff --git a/vendor/composer/autoload_classmap.php
b/vendor/composer/autoload_classmap.php
index 1493843..169c544 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -1305,6 +1305,7 @@
'Wikibase\\Repo\\PidLock' => $baseDir .
'/extensions/Wikibase/repo/includes/PidLock.php',
'Wikibase\\Repo\\PropertyDataTypeChanger' => $baseDir .
'/extensions/Wikibase/repo/includes/PropertyDataTypeChanger.php',
'Wikibase\\Repo\\Rdf\\Values\\GeoShapeRdfBuilder' => $baseDir .
'/extensions/Wikibase/repo/includes/Rdf/Values/GeoShapeRdfBuilder.php',
+ 'Wikibase\\Repo\\Rdf\\Values\\TabularDataRdfBuilder' => $baseDir .
'/extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\AllLabelsField' => $baseDir .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/AllLabelsField.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\DescriptionsProviderFieldDefinitions'
=> $baseDir .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/DescriptionProviderFieldDefinitions.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\FieldDefinitions' => $baseDir .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/FieldDefinitions.php',
@@ -1324,6 +1325,7 @@
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLContentLanguageField' => $baseDir
.
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLContentLanguageField.php',
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLItemReferenceField' => $baseDir .
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLItemReferenceField.php',
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLTrimmedTextField' => $baseDir .
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLTrimmedTextField.php',
+ 'Wikibase\\Repo\\Specials\\SpecialAvailableBadges' => $baseDir .
'/extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php',
'Wikibase\\Repo\\Specials\\SpecialDispatchStats' => $baseDir .
'/extensions/Wikibase/repo/includes/Specials/SpecialDispatchStats.php',
'Wikibase\\Repo\\Specials\\SpecialEntitiesWithoutPage' => $baseDir .
'/extensions/Wikibase/repo/includes/Specials/SpecialEntitiesWithoutPage.php',
'Wikibase\\Repo\\Specials\\SpecialEntitiesWithoutPageFactory' => $baseDir
.
'/extensions/Wikibase/repo/includes/Specials/SpecialEntitiesWithoutPageFactory.php',
@@ -1612,6 +1614,7 @@
'Wikibase\\Repo\\Tests\\Specials\\HTMLForm\\HTMLContentLanguageFieldTest'
=> $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HTMLForm/HTMLContentLanguageFieldTest.php',
'Wikibase\\Repo\\Tests\\Specials\\HTMLForm\\HTMLItemReferenceFieldTest' =>
$baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HTMLForm/HTMLItemReferenceFieldTest.php',
'Wikibase\\Repo\\Tests\\Specials\\HtmlAssertionHelpers' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HtmlAssertionHelpers.php',
+ 'Wikibase\\Repo\\Tests\\Specials\\SpecialAvailableBadgesTest' => $baseDir
.
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntitiesWithoutPageTest' =>
$baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntityDataTest' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntityPageTest' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntityPageTest.php',
diff --git a/vendor/composer/autoload_static.php
b/vendor/composer/autoload_static.php
index 885fa9a..c9a6f68 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -1623,6 +1623,7 @@
'Wikibase\\Repo\\PidLock' => __DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/PidLock.php',
'Wikibase\\Repo\\PropertyDataTypeChanger' => __DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/PropertyDataTypeChanger.php',
'Wikibase\\Repo\\Rdf\\Values\\GeoShapeRdfBuilder' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/includes/Rdf/Values/GeoShapeRdfBuilder.php',
+ 'Wikibase\\Repo\\Rdf\\Values\\TabularDataRdfBuilder' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/includes/Rdf/Values/TabularDataRdfBuilder.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\AllLabelsField' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/AllLabelsField.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\DescriptionsProviderFieldDefinitions'
=> __DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/DescriptionProviderFieldDefinitions.php',
'Wikibase\\Repo\\Search\\Elastic\\Fields\\FieldDefinitions' => __DIR__
. '/../..' .
'/extensions/Wikibase/repo/includes/Search/Elastic/Fields/FieldDefinitions.php',
@@ -1642,6 +1643,7 @@
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLContentLanguageField' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLContentLanguageField.php',
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLItemReferenceField' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLItemReferenceField.php',
'Wikibase\\Repo\\Specials\\HTMLForm\\HTMLTrimmedTextField' => __DIR__
. '/../..' .
'/extensions/Wikibase/repo/includes/Specials/HTMLForm/HTMLTrimmedTextField.php',
+ 'Wikibase\\Repo\\Specials\\SpecialAvailableBadges' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/includes/Specials/SpecialAvailableBadges.php',
'Wikibase\\Repo\\Specials\\SpecialDispatchStats' => __DIR__ . '/../..'
. '/extensions/Wikibase/repo/includes/Specials/SpecialDispatchStats.php',
'Wikibase\\Repo\\Specials\\SpecialEntitiesWithoutPage' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/includes/Specials/SpecialEntitiesWithoutPage.php',
'Wikibase\\Repo\\Specials\\SpecialEntitiesWithoutPageFactory' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/includes/Specials/SpecialEntitiesWithoutPageFactory.php',
@@ -1930,6 +1932,7 @@
'Wikibase\\Repo\\Tests\\Specials\\HTMLForm\\HTMLContentLanguageFieldTest' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HTMLForm/HTMLContentLanguageFieldTest.php',
'Wikibase\\Repo\\Tests\\Specials\\HTMLForm\\HTMLItemReferenceFieldTest' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HTMLForm/HTMLItemReferenceFieldTest.php',
'Wikibase\\Repo\\Tests\\Specials\\HtmlAssertionHelpers' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/HtmlAssertionHelpers.php',
+ 'Wikibase\\Repo\\Tests\\Specials\\SpecialAvailableBadgesTest' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntitiesWithoutPageTest' =>
__DIR__ . '/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntityDataTest' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php',
'Wikibase\\Repo\\Tests\\Specials\\SpecialEntityPageTest' => __DIR__ .
'/../..' .
'/extensions/Wikibase/repo/tests/phpunit/includes/Specials/SpecialEntityPageTest.php',
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 203a9d4..336250e 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1358,12 +1358,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "28fe263493776f3e2f5e46235dbfdd25a2f9ecc0"
+ "reference": "9d44440af6ab950d1fd60eea2f3b098cb2efba9b"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/28fe263493776f3e2f5e46235dbfdd25a2f9ecc0",
- "reference": "28fe263493776f3e2f5e46235dbfdd25a2f9ecc0",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/9d44440af6ab950d1fd60eea2f3b098cb2efba9b",
+ "reference": "9d44440af6ab950d1fd60eea2f3b098cb2efba9b",
"shasum": ""
},
"require": {
@@ -1376,7 +1376,7 @@
"data-values/number": "^0.8.2",
"data-values/serialization": "^1.2.0",
"data-values/time": "^0.8.4",
- "data-values/value-view": "^0.19.0",
+ "data-values/value-view": "^0.19.1",
"diff/diff": "^2.0.0",
"php": ">=5.5.9",
"wikibase/data-model": "^7.0.0",
@@ -1393,9 +1393,9 @@
},
"require-dev": {
"jakub-onderka/php-parallel-lint": ">=0.3 <0.10",
- "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8"
+ "mediawiki/mediawiki-codesniffer": ">=0.7 <0.8"
},
- "time": "2017-04-19 07:41:52",
+ "time": "2017-04-20 08:41:18",
"type": "mediawiki-extension",
"installation-source": "dist",
"autoload": {
@@ -1780,7 +1780,7 @@
"source": {
"type": "git",
"url":
"https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints",
- "reference": "75bf5aefb01f5b8eeda91931b86afcc999979be0"
+ "reference": "c2aa62f43030e3c57f7631f3e9cc4c750bd1de8e"
},
"require": {
"php": ">=5.5.9",
@@ -1793,7 +1793,7 @@
"phpunit/phpunit": "^3.7.37|~4.5",
"satooshi/php-coveralls": "master-dev"
},
- "time": "2017-04-18 14:34:30",
+ "time": "2017-04-07 17:00:07",
"type": "mediawiki-extension",
"installation-source": "source",
"autoload": {
--
To view, visit https://gerrit.wikimedia.org/r/349190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe118cd9591ea6d7324e7de235b7e50d6678256b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: WikidataBuilder <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits