Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4117043
WikibaseHook.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
WikibaseHook.php
View Options
<?php
namespace
MediaWiki\Extension\Math
;
use
ValueFormatters\FormatterOptions
;
use
Wikibase\Repo\Rdf\DedupeBag
;
use
Wikibase\Repo\Rdf\EntityMentionListener
;
use
Wikibase\Repo\Rdf\RdfVocabulary
;
use
Wikibase\Repo\WikibaseRepo
;
use
Wikimedia\Purtle\RdfWriter
;
class
WikibaseHook
{
/**
* Add Datatype "Math" to the Wikibase Repository
* @param array[] &$dataTypeDefinitions
*/
public
static
function
onWikibaseRepoDataTypes
(
array
&
$dataTypeDefinitions
)
{
global
$wgMathEnableWikibaseDataType
;
if
(
!
$wgMathEnableWikibaseDataType
)
{
return
;
}
$dataTypeDefinitions
[
'PT:math'
]
=
[
'value-type'
=>
'string'
,
'validator-factory-callback'
=>
static
function
()
{
// load validator builders
$factory
=
WikibaseRepo
::
getDefaultValidatorBuilders
();
// initialize an array with string validators
// returns an array of validators
// that add basic string validation such as preventing empty strings
$validators
=
$factory
->
buildStringValidators
();
$validators
[]
=
new
MathValidator
();
return
$validators
;
},
'formatter-factory-callback'
=>
static
function
(
$format
,
FormatterOptions
$options
)
{
return
new
MathFormatter
(
$format
);
},
'rdf-builder-factory-callback'
=>
static
function
(
$mode
,
RdfVocabulary
$vocab
,
RdfWriter
$writer
,
EntityMentionListener
$tracker
,
DedupeBag
$dedupe
)
{
return
new
MathMLRdfBuilder
();
},
];
}
/**
* Add Datatype "Math" to the Wikibase Client
* @param array[] &$dataTypeDefinitions
*/
public
static
function
onWikibaseClientDataTypes
(
array
&
$dataTypeDefinitions
)
{
global
$wgMathEnableWikibaseDataType
;
if
(
!
$wgMathEnableWikibaseDataType
)
{
return
;
}
$dataTypeDefinitions
[
'PT:math'
]
=
[
'value-type'
=>
'string'
,
'formatter-factory-callback'
=>
static
function
(
$format
,
FormatterOptions
$options
)
{
return
new
MathFormatter
(
$format
);
},
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 01:59 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e5/35/bb2fbd8900041fddc4823a7ae3ad
Default Alt Text
WikibaseHook.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment