(bug 12214) Add a predefined list of delete reasons to the file deletion form
authorHuji <huji@users.mediawiki.org>
Thu, 24 Jan 2008 15:35:44 +0000 (15:35 +0000)
committerHuji <huji@users.mediawiki.org>
Thu, 24 Jan 2008 15:35:44 +0000 (15:35 +0000)
RELEASE-NOTES
includes/FileDeleteForm.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 8ea891c..ee08a66 100644 (file)
@@ -142,6 +142,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   when using mailers that set the envelope sender to the From header value.
 * (bug 11897) Add alias [[Special:CreateAccount]] & [[Special:Userlogin/signup]]
   for Special:Userlogin?type=signup
+* (bug 12214) Add a predefined list of delete reasons to the file deletion form
 
 === Bug fixes in 1.12 ===
 
index 24586d4..c979d1a 100644 (file)
@@ -63,23 +63,31 @@ class FileDeleteForm {
                
                // Perform the deletion if appropriate
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
-                       $comment = $wgRequest->getText( 'wpReason' );
+                       $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
+                       $this->DeleteReason = $wgRequest->getText( 'wpReason' );
+                       $reason = $this->DeleteReasonList;
+                       if ( $reason != 'other' && $this->DeleteReason != '') {
+                               // Entry from drop down menu + additional comment
+                               $reason .= ': ' . $this->DeleteReason;
+                       } elseif ( $reason == 'other' ) {
+                               $reason = $this->DeleteReason;
+                       }
                        if( $this->oldimage ) {
-                               $status = $this->file->deleteOld( $this->oldimage, $comment );
+                               $status = $this->file->deleteOld( $this->oldimage, $reason );
                                if( $status->ok ) {
                                        // Need to do a log item
                                        $log = new LogPage( 'delete' );
                                        $logComment = wfMsg( 'deletedrevision', $this->oldimage );
-                                       if( trim( $comment ) != '' )
-                                               $logComment .= ": {$comment}";
+                                       if( trim( $reason ) != '' )
+                                               $logComment .= ": {$reason}";
                                        $log->addEntry( 'delete', $this->title, $logComment );
                                }
                        } else {
-                               $status = $this->file->delete( $comment );
+                               $status = $this->file->delete( $reason );
                                if( $status->ok ) {
                                        // Need to delete the associated article
                                        $article = new Article( $this->title );
-                                       $article->doDeleteArticle( $comment );
+                                       $article->doDeleteArticle( $reason );
                                }
                        }
                        if( !$status->isGood() )
@@ -103,15 +111,58 @@ class FileDeleteForm {
         */
        private function showForm() {
                global $wgOut, $wgUser, $wgRequest;
+               
+               $mDeletereasonother = Xml::label( wfMsg( 'filedelete-otherreason' ), 'wpReason' );
+               $mDeletereasonotherlist = wfMsgHtml( 'filedelete-reason-otherlist' );
+               $scDeleteReasonList = wfMsgForContent( 'filedelete-reason-dropdown' );
+               $mDeleteReasonList = '';
+               $delcom = Xml::label( wfMsg( 'filedelete-comment' ), 'wpDeleteReasonList' );
+               if ( $scDeleteReasonList != '' && $scDeleteReasonList != '-' ) {
+                       $deleteReasonList = "<option value=\"other\">$mDeletereasonotherlist</option>";
+                       $optgroup = "";
+                       foreach ( explode( "\n", $scDeleteReasonList ) as $option) {
+                               $value = trim( htmlspecialchars($option) );
+                               if ( $value == '' ) {
+                                       continue;
+                               } elseif ( substr( $value, 0, 1) == '*' && substr( $value, 1, 1) != '*' ) {
+                                       // A new group is starting ...
+                                       $value = trim( substr( $value, 1 ) );
+                                       $deleteReasonList .= "$optgroup<optgroup label=\"$value\">";
+                                       $optgroup = "</optgroup>";
+                               } elseif ( substr( $value, 0, 2) == '**' ) {
+                                       // groupmember
+                                       $selected = "";
+                                       $value = trim( substr( $value, 2 ) );
+                                       if ( $mDeleteReasonList === $value)
+                                       $selected = ' selected="selected"';
+                                       $deleteReasonList .= "<option value=\"$value\"$selected>$value</option>";
+                               } else {
+                                       // groupless delete reason
+                                       $selected = "";
+                                       if ( $this->DeleteReasonList === $value)
+                                               $selected = ' selected="selected"';
+                                       $deleteReasonList .= "$optgroup<option value=\"$value\"$selected>$value</option>";
+                                       $optgroup = "";
+                               }
+                       }
+                       $deleteReasonList .= $optgroup;
+               }
 
                $form  = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
                $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) );
                $form .= '<fieldset><legend>' . wfMsgHtml( 'filedelete-legend' ) . '</legend>';
+               $form .= '<table><tr>';
                $form .= $this->prepareMessage( 'filedelete-intro' );
-
-               $form .= '<p>' . Xml::inputLabel( wfMsg( 'filedelete-comment' ), 'wpReason', 'wpReason',
-                       60, $wgRequest->getText( 'wpReason' ) ) . '</p>';
+               $form .= "<td align=\"right\"> $delcom </td><td align=\"left\">";
+               $form .= "<select tabindex='2' id='wpDeleteReasonList' name=\"wpDeleteReasonList\">
+               $deleteReasonList
+</select>";
+               $form .= "</tr><tr><td align=\"right\"> $mDeletereasonother </td><td align=\"left\">";
+               $form .= "<input type='text' maxlength='255' size='60' name='wpReason' id='wpReason' ";
+               $form .= "value=\"". htmlspecialchars( $wgRequest->getText( 'wpReason' ) ) ."\" tabindex=\"1\" />";
+               $form .= '</td></tr><tr><td colspan=2>';
                $form .= '<p>' . Xml::submitButton( wfMsg( 'filedelete-submit' ), array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit' ) ) . '</p>';
+               $form .= '</tr></table>';
                $form .= '</fieldset>';
                $form .= '</form>';
 
index 235107d..3db1488 100644 (file)
@@ -1569,18 +1569,24 @@ PICT # misc.
 'filerevert-badversion'     => 'There is no previous local version of this file with the provided timestamp.',
 
 # File deletion
-'filedelete'             => 'Delete $1',
-'filedelete-backlink'    => '← $1', # only translate this message to other languages if you have to change it
-'filedelete-legend'      => 'Delete file',
-'filedelete-intro'       => "You are deleting '''[[Media:$1|$1]]'''.",
-'filedelete-intro-old'   => '<span class="plainlinks">You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].</span>',
-'filedelete-comment'     => 'Comment:',
-'filedelete-submit'      => 'Delete',
-'filedelete-success'     => "'''$1''' has been deleted.",
-'filedelete-success-old' => '<span class="plainlinks">The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.</span>',
-'filedelete-nofile'      => "'''$1''' does not exist on {{SITENAME}}.",
-'filedelete-nofile-old'  => "There is no archived version of '''$1''' with the specified attributes.",
-'filedelete-iscurrent'   => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
+'filedelete'                   => 'Delete $1',
+'filedelete-backlink'          => '← $1', # only translate this message to other languages if you have to change it
+'filedelete-legend'            => 'Delete file',
+'filedelete-intro'             => "You are deleting '''[[Media:$1|$1]]'''.",
+'filedelete-intro-old'         => '<span class="plainlinks">You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].</span>',
+'filedelete-comment'           => 'Reason for deletion:',
+'filedelete-submit'            => 'Delete',
+'filedelete-success'           => "'''$1''' has been deleted.",
+'filedelete-success-old'       => '<span class="plainlinks">The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.</span>',
+'filedelete-nofile'            => "'''$1''' does not exist on {{SITENAME}}.",
+'filedelete-nofile-old'        => "There is no archived version of '''$1''' with the specified attributes.",
+'filedelete-iscurrent'         => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
+'filedelete-otherreason'       => 'Other/additional reason:',
+'filedelete-reason-otherlist'  => 'Other reason',
+'filedelete-reason-dropdown'   => '
+*Common delete reasons
+** Copyright violation
+** Duplicated file',
 
 # MIME search
 'mimesearch'         => 'MIME search',
index 82005a7..87326f8 100644 (file)
@@ -962,6 +962,9 @@ $wgMessageStructure = array(
                'filedelete-nofile',
                'filedelete-nofile-old',
                'filedelete-iscurrent',
+               'filedelete-otherreason',
+               'filedelete-reason-otherlist',
+               'filedelete-reason-dropdown',
        ),
        'mimesearch' => array(
                'mimesearch',