Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4100004
QueryTranslationStatsActionApi.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
QueryTranslationStatsActionApi.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\Statistics
;
use
ApiBase
;
use
ApiMain
;
use
Wikimedia\ParamValidator\ParamValidator
;
use
Wikimedia\ParamValidator\TypeDef\IntegerDef
;
/**
* Api module for querying translation statistics
* @ingroup API TranslateAPI
* @since 2020.09
* @author Abijeet Patro
* @license GPL-2.0-or-later
*/
class
QueryTranslationStatsActionApi
extends
ApiBase
{
private
TranslationStatsDataProvider
$dataProvider
;
public
function
__construct
(
ApiMain
$mainModule
,
$moduleName
,
TranslationStatsDataProvider
$dataProvider
)
{
parent
::
__construct
(
$mainModule
,
$moduleName
);
$this
->
dataProvider
=
$dataProvider
;
}
public
function
execute
()
{
$params
=
$this
->
extractRequestParams
();
$graphOpts
=
new
TranslationStatsGraphOptions
();
$graphOpts
->
bindArray
(
$params
);
$language
=
$this
->
getLanguage
();
[
$labels
,
$data
]
=
$this
->
dataProvider
->
getGraphData
(
$graphOpts
,
$language
);
$output
=
[
'labels'
=>
$labels
,
'data'
=>
$data
];
$this
->
getResult
()->
addValue
(
null
,
$this
->
getModuleName
(),
$output
);
}
protected
function
getAllowedParams
()
{
return
[
'count'
=>
[
ParamValidator
::
PARAM_TYPE
=>
$this
->
dataProvider
->
getGraphTypes
(),
ParamValidator
::
PARAM_REQUIRED
=>
true
,
],
'days'
=>
[
ParamValidator
::
PARAM_TYPE
=>
'integer'
,
ParamValidator
::
PARAM_REQUIRED
=>
true
,
ParamValidator
::
PARAM_DEFAULT
=>
30
,
IntegerDef
::
PARAM_MIN
=>
1
,
IntegerDef
::
PARAM_MAX
=>
10000
,
ApiBase
::
PARAM_RANGE_ENFORCE
=>
true
],
'group'
=>
[
ParamValidator
::
PARAM_TYPE
=>
'string'
,
ParamValidator
::
PARAM_ISMULTI
=>
true
],
'language'
=>
[
ParamValidator
::
PARAM_TYPE
=>
'string'
,
ParamValidator
::
PARAM_ISMULTI
=>
true
],
'scale'
=>
[
ParamValidator
::
PARAM_TYPE
=>
TranslationStatsGraphOptions
::
VALID_SCALES
,
ParamValidator
::
PARAM_DEFAULT
=>
'days'
],
'start'
=>
[
ParamValidator
::
PARAM_TYPE
=>
'timestamp'
]
];
}
protected
function
getExamplesMessages
()
{
return
[
'action=translationstats&count=edits&days=30'
=>
'apihelp-translationstats-example-1'
,
'action=translationstats&count=edits&days=30&language=en|fr'
=>
'apihelp-translationstats-example-2'
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 16:10 (3 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a2/9f/4a9722f07d102985ee6913f40d0b
Default Alt Text
QueryTranslationStatsActionApi.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment