X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiTokens.php;h=7080f547f3c97a21890302a01d5726bf518aa934;hb=99d27d4e8a30166b00d937fa14c5af63ee5a082e;hp=2c9b482c283d4ff9b6d8981d687e42a48fb83f4e;hpb=1690388847edcdcb070427365751745f9706dd82;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php index 2c9b482c28..7080f547f3 100644 --- a/includes/api/ApiTokens.php +++ b/includes/api/ApiTokens.php @@ -24,25 +24,17 @@ * @file */ - /** * @ingroup API */ class ApiTokens extends ApiBase { - public function __construct( $main, $action ) { - parent::__construct( $main, $action ); - } - public function execute() { - wfProfileIn( __METHOD__ ); $params = $this->extractRequestParams(); $res = array(); $types = $this->getTokenTypes(); foreach ( $params['type'] as $type ) { - $type = strtolower( $type ); - $val = call_user_func( $types[$type], null, null ); if ( $val === false ) { @@ -53,7 +45,6 @@ class ApiTokens extends ApiBase { } $this->getResult()->addValue( null, $this->getModuleName(), $res ); - wfProfileOut( __METHOD__ ); } private function getTokenTypes() { @@ -62,11 +53,11 @@ class ApiTokens extends ApiBase { return $types; } wfProfileIn( __METHOD__ ); - $types = array( 'patrol' => 'ApiQueryRecentChanges::getPatrolToken' ); + $types = array( 'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' ) ); $names = array( 'edit', 'delete', 'protect', 'move', 'block', 'unblock', 'email', 'import', 'watch', 'options' ); foreach ( $names as $name ) { - $types[$name] = 'ApiQueryInfo::get' . ucfirst( $name ) . 'Token'; + $types[$name] = array( 'ApiQueryInfo', 'get' . ucfirst( $name ) . 'Token' ); } wfRunHooks( 'ApiTokensGetTokenTypes', array( &$types ) ); ksort( $types ); @@ -85,54 +76,13 @@ class ApiTokens extends ApiBase { } public function getResultProperties() { - return array( - '' => array( - 'patroltoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'edittoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'deletetoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'protecttoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'movetoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'blocktoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'unblocktoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'emailtoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'importtoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'watchtoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ), - 'optionstoken' => array( - ApiBase::PROP_TYPE => 'string', - ApiBase::PROP_NULLABLE => true - ) - ) + $props = array( + '' => array(), ); + + self::addTokenProperties( $props, $this->getTokenTypes() ); + + return $props; } public function getParamDescription() { @@ -151,8 +101,4 @@ class ApiTokens extends ApiBase { 'api.php?action=tokens&type=email|move' => 'Retrieve an email token and a move token' ); } - - public function getVersion() { - return __CLASS__ . ': $Id$'; - } }