r30122 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30121‎ | r30122 | r30123 >
Date:15:35, 24 January 2008
Author:huji
Status:old
Tags:
Comment:
(bug 12214) Add a predefined list of delete reasons to the file deletion form
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -962,6 +962,9 @@
963963 'filedelete-nofile',
964964 'filedelete-nofile-old',
965965 'filedelete-iscurrent',
 966+ 'filedelete-otherreason',
 967+ 'filedelete-reason-otherlist',
 968+ 'filedelete-reason-dropdown',
966969 ),
967970 'mimesearch' => array(
968971 'mimesearch',
Index: trunk/phase3/includes/FileDeleteForm.php
@@ -63,23 +63,31 @@
6464
6565 // Perform the deletion if appropriate
6666 if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
67 - $comment = $wgRequest->getText( 'wpReason' );
 67+ $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
 68+ $this->DeleteReason = $wgRequest->getText( 'wpReason' );
 69+ $reason = $this->DeleteReasonList;
 70+ if ( $reason != 'other' && $this->DeleteReason != '') {
 71+ // Entry from drop down menu + additional comment
 72+ $reason .= ': ' . $this->DeleteReason;
 73+ } elseif ( $reason == 'other' ) {
 74+ $reason = $this->DeleteReason;
 75+ }
6876 if( $this->oldimage ) {
69 - $status = $this->file->deleteOld( $this->oldimage, $comment );
 77+ $status = $this->file->deleteOld( $this->oldimage, $reason );
7078 if( $status->ok ) {
7179 // Need to do a log item
7280 $log = new LogPage( 'delete' );
7381 $logComment = wfMsg( 'deletedrevision', $this->oldimage );
74 - if( trim( $comment ) != '' )
75 - $logComment .= ": {$comment}";
 82+ if( trim( $reason ) != '' )
 83+ $logComment .= ": {$reason}";
7684 $log->addEntry( 'delete', $this->title, $logComment );
7785 }
7886 } else {
79 - $status = $this->file->delete( $comment );
 87+ $status = $this->file->delete( $reason );
8088 if( $status->ok ) {
8189 // Need to delete the associated article
8290 $article = new Article( $this->title );
83 - $article->doDeleteArticle( $comment );
 91+ $article->doDeleteArticle( $reason );
8492 }
8593 }
8694 if( !$status->isGood() )
@@ -103,15 +111,58 @@
104112 */
105113 private function showForm() {
106114 global $wgOut, $wgUser, $wgRequest;
 115+
 116+ $mDeletereasonother = Xml::label( wfMsg( 'filedelete-otherreason' ), 'wpReason' );
 117+ $mDeletereasonotherlist = wfMsgHtml( 'filedelete-reason-otherlist' );
 118+ $scDeleteReasonList = wfMsgForContent( 'filedelete-reason-dropdown' );
 119+ $mDeleteReasonList = '';
 120+ $delcom = Xml::label( wfMsg( 'filedelete-comment' ), 'wpDeleteReasonList' );
 121+ if ( $scDeleteReasonList != '' && $scDeleteReasonList != '-' ) {
 122+ $deleteReasonList = "<option value=\"other\">$mDeletereasonotherlist</option>";
 123+ $optgroup = "";
 124+ foreach ( explode( "\n", $scDeleteReasonList ) as $option) {
 125+ $value = trim( htmlspecialchars($option) );
 126+ if ( $value == '' ) {
 127+ continue;
 128+ } elseif ( substr( $value, 0, 1) == '*' && substr( $value, 1, 1) != '*' ) {
 129+ // A new group is starting ...
 130+ $value = trim( substr( $value, 1 ) );
 131+ $deleteReasonList .= "$optgroup<optgroup label=\"$value\">";
 132+ $optgroup = "</optgroup>";
 133+ } elseif ( substr( $value, 0, 2) == '**' ) {
 134+ // groupmember
 135+ $selected = "";
 136+ $value = trim( substr( $value, 2 ) );
 137+ if ( $mDeleteReasonList === $value)
 138+ $selected = ' selected="selected"';
 139+ $deleteReasonList .= "<option value=\"$value\"$selected>$value</option>";
 140+ } else {
 141+ // groupless delete reason
 142+ $selected = "";
 143+ if ( $this->DeleteReasonList === $value)
 144+ $selected = ' selected="selected"';
 145+ $deleteReasonList .= "$optgroup<option value=\"$value\"$selected>$value</option>";
 146+ $optgroup = "";
 147+ }
 148+ }
 149+ $deleteReasonList .= $optgroup;
 150+ }
107151
108152 $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
109153 $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) );
110154 $form .= '<fieldset><legend>' . wfMsgHtml( 'filedelete-legend' ) . '</legend>';
 155+ $form .= '<table><tr>';
111156 $form .= $this->prepareMessage( 'filedelete-intro' );
112 -
113 - $form .= '<p>' . Xml::inputLabel( wfMsg( 'filedelete-comment' ), 'wpReason', 'wpReason',
114 - 60, $wgRequest->getText( 'wpReason' ) ) . '</p>';
 157+ $form .= "<td align=\"right\"> $delcom </td><td align=\"left\">";
 158+ $form .= "<select tabindex='2' id='wpDeleteReasonList' name=\"wpDeleteReasonList\">
 159+ $deleteReasonList
 160+</select>";
 161+ $form .= "</tr><tr><td align=\"right\"> $mDeletereasonother </td><td align=\"left\">";
 162+ $form .= "<input type='text' maxlength='255' size='60' name='wpReason' id='wpReason' ";
 163+ $form .= "value=\"". htmlspecialchars( $wgRequest->getText( 'wpReason' ) ) ."\" tabindex=\"1\" />";
 164+ $form .= '</td></tr><tr><td colspan=2>';
115165 $form .= '<p>' . Xml::submitButton( wfMsg( 'filedelete-submit' ), array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit' ) ) . '</p>';
 166+ $form .= '</tr></table>';
116167 $form .= '</fieldset>';
117168 $form .= '</form>';
118169
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1569,18 +1569,24 @@
15701570 'filerevert-badversion' => 'There is no previous local version of this file with the provided timestamp.',
15711571
15721572 # File deletion
1573 -'filedelete' => 'Delete $1',
1574 -'filedelete-backlink' => '← $1', # only translate this message to other languages if you have to change it
1575 -'filedelete-legend' => 'Delete file',
1576 -'filedelete-intro' => "You are deleting '''[[Media:$1|$1]]'''.",
1577 -'filedelete-intro-old' => '<span class="plainlinks">You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].</span>',
1578 -'filedelete-comment' => 'Comment:',
1579 -'filedelete-submit' => 'Delete',
1580 -'filedelete-success' => "'''$1''' has been deleted.",
1581 -'filedelete-success-old' => '<span class="plainlinks">The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.</span>',
1582 -'filedelete-nofile' => "'''$1''' does not exist on {{SITENAME}}.",
1583 -'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
1584 -'filedelete-iscurrent' => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
 1573+'filedelete' => 'Delete $1',
 1574+'filedelete-backlink' => '← $1', # only translate this message to other languages if you have to change it
 1575+'filedelete-legend' => 'Delete file',
 1576+'filedelete-intro' => "You are deleting '''[[Media:$1|$1]]'''.",
 1577+'filedelete-intro-old' => '<span class="plainlinks">You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].</span>',
 1578+'filedelete-comment' => 'Reason for deletion:',
 1579+'filedelete-submit' => 'Delete',
 1580+'filedelete-success' => "'''$1''' has been deleted.",
 1581+'filedelete-success-old' => '<span class="plainlinks">The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.</span>',
 1582+'filedelete-nofile' => "'''$1''' does not exist on {{SITENAME}}.",
 1583+'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
 1584+'filedelete-iscurrent' => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
 1585+'filedelete-otherreason' => 'Other/additional reason:',
 1586+'filedelete-reason-otherlist' => 'Other reason',
 1587+'filedelete-reason-dropdown' => '
 1588+*Common delete reasons
 1589+** Copyright violation
 1590+** Duplicated file',
15851591
15861592 # MIME search
15871593 'mimesearch' => 'MIME search',
Index: trunk/phase3/RELEASE-NOTES
@@ -142,6 +142,7 @@
143143 when using mailers that set the envelope sender to the From header value.
144144 * (bug 11897) Add alias [[Special:CreateAccount]] & [[Special:Userlogin/signup]]
145145 for Special:Userlogin?type=signup
 146+* (bug 12214) Add a predefined list of delete reasons to the file deletion form
146147
147148 === Bug fixes in 1.12 ===
148149

Status & tagging log