Page Menu
Home
Miraheze
Search
Configure Global Search
Log In
Paste
P125
Draft for ManageWiki Query API
Active
Public
Actions
Authored by
Southparkfan
on Oct 2 2018, 16:46.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Flag For Later
Award Token
Tags
None
Referenced Files
F852556: Draft for ManageWiki Query API
Oct 2 2018, 16:46
2018-10-02 16:46:02 (UTC+0)
Subscribers
None
<?php
class
ApiQueryWikiConfig
extends
ApiQueryBase
{
public
function
__construct
(
$query
,
$moduleName
)
{
parent
::
__construct
(
$query
,
$moduleName
,
'wcf'
);
}
public
function
execute
()
{
$params
=
$this
->
extractRequestParams
();
$result
=
$this
->
getResult
();
$prop
=
array_flip
(
$params
[
'prop'
]
);
$data
=
[];
foreach
(
$params
[
'wikis'
]
as
$wiki
)
{
$wikiObj
=
RemoteWiki
::
newFromName
(
$wiki
);
$wikiData
=
[];
$wikiData
[
'name'
]
=
$wiki
;
if
(
isset
(
$prop
[
'sitename'
]
)
)
{
$wikiData
[
'sitename'
]
=
$wikiObj
->
getSitename
();
}
if
(
isset
(
$prop
[
'closed'
]
)
)
{
$wikiData
[
'closed'
]
=
(
$wikiObj
->
isClosed
()
==
true
)
?
1
:
0
;
}
if
(
isset
(
$prop
[
'inactive'
]
)
)
{
$wikiData
[
'inactive'
]
=
(
$wikiObj
->
isInactive
()
==
true
)
?
1
:
0
;
}
if
(
isset
(
$prop
[
'private'
]
)
)
{
$wikiData
[
'private'
]
=
(
$wikiObj
->
isPrivate
()
==
true
)
?
1
:
0
;
}
if
(
isset
(
$prop
[
'settings'
]
)
)
{
$wikiData
[
'settings'
]
=
$wikiObj
->
getSettings
();
}
if
(
isset
(
$prop
[
'extensions'
]
)
)
{
$extensions
=
explode
(
','
,
$wikiObj
->
getExtensions
()
);
// Delete dummy entry from extensions
$extensions
=
array_diff
(
$extensions
,
[
'zzzz'
]
);
$wikiData
[
'extensions'
]
=
$extensions
;
}
$data
[]
=
$wikiData
;
}
$result
->
setIndexedTagName
(
$data
,
'wikiconfig'
);
$result
->
addValue
(
'query'
,
$this
->
getModuleName
(),
$data
);
}
public
function
getAllowedParams
()
{
return
[
'prop'
=>
[
ApiBase
::
PARAM_ISMULTI
=>
true
,
ApiBase
::
PARAM_TYPE
=>
[
'sitename'
,
'inactive'
,
'closed'
,
'private'
,
'extensions'
,
'settings'
,
'permissions'
],
ApiBase
::
PARAM_DFLT
=>
'sitename|extensions|settings'
,
],
'wikis'
=>
[
ApiBase
::
PARAM_ISMULTI
=>
true
,
],
];
}
}
Event Timeline
Southparkfan
created this paste.
Oct 2 2018, 16:46
2018-10-02 16:46:02 (UTC+0)
Southparkfan
created this object with edit policy "
Southparkfan
".
Southparkfan
mentioned this in
T3631: Introduce ManageWiki API
.
Log In to Comment