From: Huji Date: Thu, 24 Jan 2008 15:35:44 +0000 (+0000) Subject: (bug 12214) Add a predefined list of delete reasons to the file deletion form X-Git-Tag: 1.31.0-rc.0~49797 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=9fe827167203c4165a2d1d35d15888a9b4360514;p=lhc%2Fweb%2Fwiklou.git (bug 12214) Add a predefined list of delete reasons to the file deletion form --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8ea891ce27..ee08a6624a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 24586d4e89..c979d1ae06 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -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 = ""; + $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 = ""; + } elseif ( substr( $value, 0, 2) == '**' ) { + // groupmember + $selected = ""; + $value = trim( substr( $value, 2 ) ); + if ( $mDeleteReasonList === $value) + $selected = ' selected="selected"'; + $deleteReasonList .= ""; + } else { + // groupless delete reason + $selected = ""; + if ( $this->DeleteReasonList === $value) + $selected = ' selected="selected"'; + $deleteReasonList .= "$optgroup"; + $optgroup = ""; + } + } + $deleteReasonList .= $optgroup; + } $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) ); $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ); $form .= '
' . wfMsgHtml( 'filedelete-legend' ) . ''; + $form .= ''; $form .= $this->prepareMessage( 'filedelete-intro' ); - - $form .= '

' . Xml::inputLabel( wfMsg( 'filedelete-comment' ), 'wpReason', 'wpReason', - 60, $wgRequest->getText( 'wpReason' ) ) . '

'; + $form .= "
$delcom "; + $form .= ""; + $form .= "
$mDeletereasonother "; + $form .= "getText( 'wpReason' ) ) ."\" tabindex=\"1\" />"; + $form .= '
'; $form .= '

' . Xml::submitButton( wfMsg( 'filedelete-submit' ), array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit' ) ) . '

'; + $form .= '
'; $form .= '
'; $form .= ''; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 235107d5e9..3db1488c57 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' => 'You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].', -'filedelete-comment' => 'Comment:', -'filedelete-submit' => 'Delete', -'filedelete-success' => "'''$1''' has been deleted.", -'filedelete-success-old' => 'The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.', -'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' => 'You are deleting the version of \'\'\'[[Media:$1|$1]]\'\'\' as of [$4 $3, $2].', +'filedelete-comment' => 'Reason for deletion:', +'filedelete-submit' => 'Delete', +'filedelete-success' => "'''$1''' has been deleted.", +'filedelete-success-old' => 'The version of \'\'\'[[Media:$1|$1]]\'\'\' as of $3, $2 has been deleted.', +'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', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 82005a753f..87326f8da0 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -962,6 +962,9 @@ $wgMessageStructure = array( 'filedelete-nofile', 'filedelete-nofile-old', 'filedelete-iscurrent', + 'filedelete-otherreason', + 'filedelete-reason-otherlist', + 'filedelete-reason-dropdown', ), 'mimesearch' => array( 'mimesearch',