32 parent::__construct( $main, $format );
33 $this->isRaw = ( $format ===
'rawfm' );
35 if ( $this->
getMain()->getCheck(
'callback' ) ) {
36 # T94015: jQuery appends a useless '_' parameter in jsonp mode.
37 # Mark the parameter as used in that case to avoid a warning that's
38 # outside the control of the end user.
39 # (and do it here because ApiMain::reportUnusedParams() gets called
40 # before our ::execute())
41 $this->
getMain()->markParamsUsed(
'_' );
49 return 'text/javascript';
52 return 'application/json';
60 $opt |= FormatJson::ALL_OK;
63 switch (
$params[
'formatversion'] ) {
65 $opt |=
$params[
'utf8'] ? FormatJson::ALL_OK : FormatJson::XMLMETA_OK;
68 'Types' => [
'AssocAsObject' =>
true ],
75 $opt |=
$params[
'ascii'] ? FormatJson::XMLMETA_OK : FormatJson::ALL_OK;
77 'Types' => [
'AssocAsObject' =>
true ],
85 $this->
dieDebug( __METHOD__,
'Unknown value for \'formatversion\'' );
91 if ( $json ===
false ) {
95 $this->
dieDebug( __METHOD__,
'Unable to encode API result as JSON' );
102 if (
preg_match(
'/<\s*cross-domain-policy(?=\s|>)/i', $json ) ) {
104 '/<(\s*cross-domain-policy(?=\s|>))/i',
'\\u003C$1', $json
110 # Prepend a comment to try to avoid attacks against content
111 # sniffers, such as T70187.
112 $this->
printText(
"/**/$callback($json)" );
119 if ( $this->isRaw ) {
120 return parent::getAllowedParams();
123 $ret = parent::getAllowedParams() + [
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
This is the main API class, used for both external and internal processing.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)