Merge "Deprecate no longer used Skin::getCommonStylePath."
[lhc/web/wiklou.git] / includes / api / ApiUndelete.php
index 509c1f8..c89f49a 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiBase.php" );
-}
-
 /**
  * @ingroup API
  */
@@ -39,14 +34,13 @@ class ApiUndelete extends ApiBase {
        }
 
        public function execute() {
-               global $wgUser;
                $params = $this->extractRequestParams();
 
-               if ( !$wgUser->isAllowed( 'undelete' ) ) {
+               if ( !$this->getUser()->isAllowed( 'undelete' ) ) {
                        $this->dieUsageMsg( 'permdenied-undelete' );
                }
 
-               if ( $wgUser->isBlocked() ) {
+               if ( $this->getUser()->isBlocked() ) {
                        $this->dieUsageMsg( 'blockedtext' );
                }
 
@@ -74,7 +68,7 @@ class ApiUndelete extends ApiBase {
 
                if ( $retval[1] ) {
                        wfRunHooks( 'FileUndeleteComplete',
-                               array( $titleObj, array(), $wgUser, $params['reason'] ) );
+                               array( $titleObj, array(), $this->getUser(), $params['reason'] ) );
                }
 
                $this->setWatch( $params['watchlist'], $titleObj );
@@ -82,7 +76,7 @@ class ApiUndelete extends ApiBase {
                $info['title'] = $titleObj->getPrefixedText();
                $info['revisions'] = intval( $retval[0] );
                $info['fileversions'] = intval( $retval[1] );
-               $info['reason'] = intval( $retval[2] );
+               $info['reason'] = $retval[2];
                $this->getResult()->addValue( null, $this->getModuleName(), $info );
        }
 
@@ -128,6 +122,17 @@ class ApiUndelete extends ApiBase {
                );
        }
 
+       public function getResultProperties() {
+               return array(
+                       '' => array(
+                               'title' => 'string',
+                               'revisions' => 'integer',
+                               'filerevisions' => 'integer',
+                               'reason' => 'string'
+                       )
+               );
+       }
+
        public function getDescription() {
                return array(
                        'Restore certain revisions of a deleted page. A list of deleted revisions (including timestamps) can be',
@@ -152,13 +157,17 @@ class ApiUndelete extends ApiBase {
                return '';
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
                        'api.php?action=undelete&title=Main%20Page&token=123ABC&reason=Restoring%20main%20page',
                        'api.php?action=undelete&title=Main%20Page&token=123ABC&timestamps=20070703220045|20070702194856'
                );
        }
 
+       public function getHelpUrls() {
+               return 'https://www.mediawiki.org/wiki/API:Undelete';
+       }
+
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }