Merge "Check validity and availability of usernames during signup via AJAX"
[lhc/web/wiklou.git] / includes / api / ApiDelete.php
index aea1048..acc2eb8 100644 (file)
@@ -31,7 +31,6 @@
  * @ingroup API
  */
 class ApiDelete extends ApiBase {
-
        /**
         * Extracts the title, token, and reason from the request parameters and invokes
         * the local delete() function with these as arguments. It does not make use of
@@ -52,7 +51,14 @@ class ApiDelete extends ApiBase {
                $user = $this->getUser();
 
                if ( $titleObj->getNamespace() == NS_FILE ) {
-                       $status = self::deleteFile( $pageObj, $user, $params['token'], $params['oldimage'], $reason, false );
+                       $status = self::deleteFile(
+                               $pageObj,
+                               $user,
+                               $params['token'],
+                               $params['oldimage'],
+                               $reason,
+                               false
+                       );
                } else {
                        $status = self::delete( $pageObj, $user, $params['token'], $reason );
                }
@@ -121,20 +127,23 @@ class ApiDelete extends ApiBase {
                }
 
                $error = '';
+
                // Luckily, Article.php provides a reusable delete function that does the hard work for us
                return $page->doDeleteArticleReal( $reason, false, 0, true, $error );
        }
 
        /**
-        * @param $page WikiPage|Page object to work on
-        * @param $user User doing the action
-        * @param $token
-        * @param $oldimage
-        * @param $reason
-        * @param $suppress bool
+        * @param Page $page Object to work on
+        * @param User $user User doing the action
+        * @param string $token Delete token (same as edit token)
+        * @param string $oldimage Archive name
+        * @param string $reason Reason for the deletion. Autogenerated if null.
+        * @param bool $suppress Whether to mark all deleted versions as restricted
         * @return Status|array
         */
-       public static function deleteFile( Page $page, User $user, $token, $oldimage, &$reason = null, $suppress = false ) {
+       public static function deleteFile( Page $page, User $user, $token, $oldimage,
+               &$reason = null, $suppress = false
+       ) {
                $title = $page->getTitle();
                $errors = self::getPermissionsError( $title, $user, $token );
                if ( count( $errors ) ) {
@@ -159,6 +168,7 @@ class ApiDelete extends ApiBase {
                if ( is_null( $reason ) ) { // Log and RC don't like null reasons
                        $reason = '';
                }
+
                return FileDeleteForm::doDelete( $title, $file, $oldimage, $reason, $suppress, $user );
        }
 
@@ -204,13 +214,16 @@ class ApiDelete extends ApiBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'title' => "Title of the page you want to delete. Cannot be used together with {$p}pageid",
                        'pageid' => "Page ID of the page you want to delete. Cannot be used together with {$p}title",
                        'token' => 'A delete token previously retrieved through prop=info',
-                       'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used',
+                       'reason'
+                               => 'Reason for the deletion. If not set, an automatically generated reason will be used',
                        'watch' => 'Add the page to your watchlist',
-                       'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
+                       'watchlist' => 'Unconditionally add or remove the page from your ' .
+                               'watchlist, use preferences or do not change watch',
                        'unwatch' => 'Remove the page from your watchlist',
                        'oldimage' => 'The name of the old image to delete as provided by iiprop=archivename'
                );
@@ -227,7 +240,7 @@ class ApiDelete extends ApiBase {
        }
 
        public function getDescription() {
-               return 'Delete a page';
+               return 'Delete a page.';
        }
 
        public function getPossibleErrors() {
@@ -255,7 +268,8 @@ class ApiDelete extends ApiBase {
        public function getExamples() {
                return array(
                        'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Delete the Main Page',
-                       'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Delete the Main Page with the reason "Preparing for move"',
+                       'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
+                               => 'Delete the Main Page with the reason "Preparing for move"',
                );
        }