Provide short URL to file description page in imageinfo API
[lhc/web/wiklou.git] / includes / api / ApiUndelete.php
index 07aad9f..469fe7f 100644 (file)
 class ApiUndelete extends ApiBase {
 
        public function execute() {
-               $params = $this->extractRequestParams();
+               $this->useTransactionalTimeLimit();
 
-               if ( !$this->getUser()->isAllowed( 'undelete' ) ) {
+               $params = $this->extractRequestParams();
+               $user = $this->getUser();
+               if ( !$user->isAllowed( 'undelete' ) ) {
                        $this->dieUsageMsg( 'permdenied-undelete' );
                }
 
-               if ( $this->getUser()->isBlocked() ) {
-                       $this->dieUsageMsg( 'blockedtext' );
+               if ( $user->isBlocked() ) {
+                       $this->dieBlocked( $user->getBlock() );
                }
 
                $titleObj = Title::newFromText( $params['title'] );
@@ -69,7 +71,7 @@ class ApiUndelete extends ApiBase {
                }
 
                if ( $retval[1] ) {
-                       wfRunHooks( 'FileUndeleteComplete',
+                       Hooks::run( 'FileUndeleteComplete',
                                array( $titleObj, $params['fileids'], $this->getUser(), $params['reason'] ) );
                }
 
@@ -117,39 +119,17 @@ class ApiUndelete extends ApiBase {
                );
        }
 
-       public function getParamDescription() {
-               return array(
-                       'title' => 'Title of the page you want to restore',
-                       'reason' => 'Reason for restoring',
-                       'timestamps' => array(
-                               'Timestamps of the revisions to restore.',
-                               'If both timestamps and fileids are empty, all will be restored.',
-                       ),
-                       'fileids' => array(
-                               'IDs of the file revisions to restore.',
-                               'If both timestamps and fileids are empty, all will be restored.',
-                       ),
-                       'watchlist' => 'Unconditionally add or remove the page from your ' .
-                               'watchlist, use preferences or do not change watch',
-               );
-       }
-
-       public function getDescription() {
-               return array(
-                       'Restore certain revisions of a deleted page. A list of deleted revisions ',
-                       '(including timestamps) can be retrieved through list=deletedrevs, and a list',
-                       'of deleted file ids can be retrieved through list=filearchive.'
-               );
-       }
-
        public function needsToken() {
                return 'csrf';
        }
 
-       public function getExamples() {
+       protected function getExamplesMessages() {
                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'
+                       'action=undelete&title=Main%20Page&token=123ABC&reason=Restoring%20main%20page'
+                               => 'apihelp-undelete-example-page',
+                       'action=undelete&title=Main%20Page&token=123ABC' .
+                               '&timestamps=2007-07-03T22:00:45Z|2007-07-02T19:48:56Z'
+                               => 'apihelp-undelete-example-revisions',
                );
        }