diff --git a/MathWikidataHook.php b/MathWikidataHook.php index 04c488f82..62183dec6 100644 --- a/MathWikidataHook.php +++ b/MathWikidataHook.php @@ -3,14 +3,20 @@ use ValueFormatters\FormatterOptions; use ValueParsers\StringParser; use Wikibase\Repo\Parsers\WikibaseStringValueNormalizer; -use Wikibase\Repo\Validators\CompositeValidator; use Wikibase\Repo\WikibaseRepo; class MathWikidataHook { - /* + + /** * Add Datatype "Math" to the Wikibase Repository */ public static function onWikibaseRepoDataTypes( array &$dataTypeDefinitions ) { + global $wgMathEnableWikibaseDataType; + + if ( !$wgMathEnableWikibaseDataType ) { + return; + } + $dataTypeDefinitions['PT:math'] = array( 'value-type' => 'string', 'validator-factory-callback' => function() { @@ -42,6 +48,12 @@ class MathWikidataHook { * Add Datatype "Math" to the Wikibase Client */ public static function onWikibaseClientDataTypes( array &$dataTypeDefinitions ) { + global $wgMathEnableWikibaseDataType; + + if ( !$wgMathEnableWikibaseDataType ) { + return; + } + $dataTypeDefinitions['PT:math'] = array( 'value-type' => 'string', 'formatter-factory-callback' => function( $format, FormatterOptions $options ) { diff --git a/extension.json b/extension.json index b7fcf0c37..23a3c5b99 100644 --- a/extension.json +++ b/extension.json @@ -110,6 +110,7 @@ "source", "mathml" ], + "MathEnableWikibaseDataType": true, "Texvc": false, "TexvcBackgroundColor": "transparent" },