Fixes bug 9633: Add a predefined list of delete reasons to the deletion form
authorHuji <huji@users.mediawiki.org>
Sun, 25 Nov 2007 17:02:28 +0000 (17:02 +0000)
committerHuji <huji@users.mediawiki.org>
Sun, 25 Nov 2007 17:02:28 +0000 (17:02 +0000)
RELEASE-NOTES
includes/Article.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 73ba3f2..c25bbd2 100644 (file)
@@ -79,6 +79,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * dumpTextPass.php can spawn fetchText.php as a subprocess, which should restart
   cleanly if database connections fail unpleasantly.
 * (bug 12028) Add Special:Listbots as shortcut for Special:Listusers/bot
+* (bug 9633) Add a predefined list of delete reasons to the deletion form
 
 === Bug fixes in 1.12 ===
 
index 0e2a992..56070b2 100644 (file)
@@ -1925,7 +1925,15 @@ class Article {
                global $wgUser, $wgOut, $wgRequest;
                $confirm = $wgRequest->wasPosted() &&
                        $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
-               $reason = $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;
+               }
 
                # This code desperately needs to be totally rewritten
 
@@ -2034,18 +2042,63 @@ class Article {
                $formaction = $this->mTitle->escapeLocalURL( 'action=delete' . $par );
 
                $confirm = htmlspecialchars( wfMsg( 'deletepage' ) );
-               $delcom = htmlspecialchars( wfMsg( 'deletecomment' ) );
+               $delcom = Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' );
                $token = htmlspecialchars( $wgUser->editToken() );
                $watch = Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(), array( 'tabindex' => '2' ) );
-
+               
+               $mDeletereasonother = Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' );
+               $mDeletereasonotherlist = wfMsgHtml( 'deletereasonotherlist' );
+               $scDeleteReasonList = wfMsgForContent( 'deletereason-dropdown' );
+
+               $deleteReasonList = '';
+               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 ( $this->DeleteReasonList === $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;
+               }
                $wgOut->addHTML( "
 <form id='deleteconfirm' method='post' action=\"{$formaction}\">
        <table border='0'>
                <tr>
                        <td align='right'>
-                               <label for='wpReason'>{$delcom}:</label>
+                               $delcom:
                        </td>
                        <td align='left'>
+                               <select tabindex='2' id='wpDeleteReasonList' name=\"wpDeleteReasonList\">
+                                       $deleteReasonList
+                               </select>
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                               $mDeletereasonother
+                       </td>
+                       <td align='right'>
                                <input type='text' maxlength='255' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" tabindex=\"1\" />
                        </td>
                </tr>
index 74eb01e..4fb26fa 100644 (file)
@@ -1891,6 +1891,13 @@ See $2 for a record of recent deletions.',
 'deletionlog'                 => 'deletion log',
 'reverted'                    => 'Reverted to earlier revision',
 'deletecomment'               => 'Reason for deletion',
+'deleteotherreason'           => 'Other/additional reason:',
+'deletereasonotherlist'       => 'Other reason',
+'deletereason-dropdown'       => '
+*Common delete reasons
+** Author request
+** Copyright violation
+** Vandalism',
 'rollback'                    => 'Roll back edits',
 'rollback_short'              => 'Rollback',
 'rollbacklink'                => 'rollback',
index 3ac762f..c2bd6aa 100644 (file)
@@ -1208,6 +1208,9 @@ $wgMessageStructure = array(
                'deletionlog',
                'reverted',
                'deletecomment',
+               'deleteotherreason',
+               'deletereasonotherlist',
+               'deletereason-dropdown',
                'rollback',
                'rollback_short',
                'rollbacklink',