dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change API result data structure to be cleaner in new formats
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiProtect.php
diff --git
a/includes/api/ApiProtect.php
b/includes/api/ApiProtect.php
index
f5786e8
..
c07aaca
100644
(file)
--- a/
includes/api/ApiProtect.php
+++ b/
includes/api/ApiProtect.php
@@
-29,6
+29,8
@@
*/
class ApiProtect extends ApiBase {
public function execute() {
*/
class ApiProtect extends ApiBase {
public function execute() {
+ global $wgContLang;
+
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
@@
-77,8
+79,8
@@
class ApiProtect extends ApiBase {
$this->dieUsageMsg( array( 'protect-invalidlevel', $p[1] ) );
}
$this->dieUsageMsg( array( 'protect-invalidlevel', $p[1] ) );
}
- if (
in_array( $expiry[$i], array( 'infinite', 'indefinite', 'infinity', 'never' )
) ) {
- $expiryarray[$p[0]] =
$db->getInfinity()
;
+ if (
wfIsInfinity( $expiry[$i]
) ) {
+ $expiryarray[$p[0]] =
'infinity'
;
} else {
$exp = strtotime( $expiry[$i] );
if ( $exp < 0 || !$exp ) {
} else {
$exp = strtotime( $expiry[$i] );
if ( $exp < 0 || !$exp ) {
@@
-93,10
+95,7
@@
class ApiProtect extends ApiBase {
}
$resultProtections[] = array(
$p[0] => $protections[$p[0]],
}
$resultProtections[] = array(
$p[0] => $protections[$p[0]],
- 'expiry' => ( $expiryarray[$p[0]] == $db->getInfinity()
- ? 'infinite'
- : wfTimestamp( TS_ISO_8601, $expiryarray[$p[0]] )
- )
+ 'expiry' => $wgContLang->formatExpiry( $expiryarray[$p[0]], TS_ISO_8601, 'infinite' ),
);
}
);
}
@@
-124,11
+123,11
@@
class ApiProtect extends ApiBase {
'reason' => $params['reason']
);
if ( $cascade ) {
'reason' => $params['reason']
);
if ( $cascade ) {
- $res['cascade'] =
''
;
+ $res['cascade'] =
true
;
}
$res['protections'] = $resultProtections;
$result = $this->getResult();
}
$res['protections'] = $resultProtections;
$result = $this->getResult();
-
$result->
setIndexedTagName( $res['protections'], 'protection' );
+
ApiResult::
setIndexedTagName( $res['protections'], 'protection' );
$result->addValue( null, $this->getModuleName(), $res );
}
$result->addValue( null, $this->getModuleName(), $res );
}
@@
-179,7
+178,7
@@
class ApiProtect extends ApiBase {
return 'csrf';
}
return 'csrf';
}
- p
ublic
function getExamplesMessages() {
+ p
rotected
function getExamplesMessages() {
return array(
'action=protect&title=Main%20Page&token=123ABC&' .
'protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never'
return array(
'action=protect&title=Main%20Page&token=123ABC&' .
'protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never'