Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7424759
ApiCentralNoticeQueryCampaign.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
ApiCentralNoticeQueryCampaign.php
View Options
<?php
use
MediaWiki\Api\ApiBase
;
/** @todo: This needs some major cleanup to work more like the rest of the API. */
class
ApiCentralNoticeQueryCampaign
extends
ApiBase
{
/**
* @var string sanitize campaign name
* FIXME: the string is apparently unrestricted in Special:CentralNotice
*/
private
const
CAMPAIGNS_FILTER
=
'/^[a-zA-Z0-9 _|
\-
]+$/'
;
public
function
execute
()
{
// Obtain the ApiResults object from the base
$result
=
$this
->
getResult
();
// Get our language/project/country
$params
=
$this
->
extractRequestParams
();
if
(
!
preg_match
(
self
::
CAMPAIGNS_FILTER
,
$params
[
'campaign'
]
)
)
{
return
;
}
$campaigns
=
explode
(
'|'
,
$params
[
'campaign'
]
);
foreach
(
$campaigns
as
$campaign
)
{
$settings
=
Campaign
::
getCampaignSettings
(
$campaign
);
if
(
$settings
)
{
$settings
[
'banners'
]
=
json_decode
(
$settings
[
'banners'
]
);
# TODO this should probably be pushed down:
$settings
[
'projects'
]
=
explode
(
', '
,
$settings
[
'projects'
]
);
$settings
[
'countries'
]
=
explode
(
', '
,
$settings
[
'countries'
]
);
$settings
[
'regions'
]
=
explode
(
', '
,
$settings
[
'regions'
]
);
$settings
[
'languages'
]
=
explode
(
', '
,
$settings
[
'languages'
]
);
$settings
[
'enabled'
]
=
(
bool
)
$settings
[
'enabled'
];
$settings
[
'preferred'
]
=
(
bool
)
$settings
[
'preferred'
];
$settings
[
'locked'
]
=
(
bool
)
$settings
[
'locked'
];
$settings
[
'geo'
]
=
(
bool
)
$settings
[
'geo'
];
}
$result
->
addValue
(
[
$this
->
getModuleName
()
],
$campaign
,
$settings
);
}
}
/** @inheritDoc */
public
function
getAllowedParams
()
{
return
[
'campaign'
=>
''
];
}
/**
* @inheritDoc
*/
protected
function
getExamplesMessages
()
{
return
[
'action=centralnoticequerycampaign&format=json&campaign=Plea_US'
=>
'apihelp-centralnoticequerycampaign-example-1'
,
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 07:33 (21 h, 2 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
75/3a/12c408574c4f0c267bb7ed7b643f
Default Alt Text
ApiCentralNoticeQueryCampaign.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment