r45680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45679‎ | r45680 | r45681 >
Date:18:23, 12 January 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* Code cleanup
Modified paths:
  • /trunk/extensions/Nuke/SpecialNuke_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Nuke/SpecialNuke_body.php
@@ -21,6 +21,13 @@
2222 $this->outputHeader();
2323
2424 $target = $wgRequest->getText( 'target', $par );
 25+
 26+ // Normalise name
 27+ if ( $target !== '' ) {
 28+ $user = User::newFromName( $target );
 29+ if ( $user ) $target = $user->getName();
 30+ }
 31+
2532 $reason = $wgRequest->getText( 'wpReason',
2633 wfMsgForContent( 'nuke-defaultreason', $target ) );
2734 $posted = $wgRequest->wasPosted() &&
@@ -39,22 +46,18 @@
4047 }
4148
4249 function promptForm() {
43 - global $wgUser, $wgOut;
44 - $sk =& $wgUser->getSkin();
 50+ global $wgOut;
4551
46 - $nuke = Title::makeTitle( NS_SPECIAL, 'Nuke' );
47 - $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-user' ) ) );
 52+ $input = Xml::input( 'target', 40 );
 53+ $submit = Xml::submitButton( wfMsg( 'nuke-submit-user' ) );
4854
49 - $wgOut->addWikiText( wfMsg( 'nuke-tools' ) );
50 - $wgOut->addHTML( Xml::element( 'form', array(
51 - 'action' => $nuke->getLocalURL( 'action=submit' ),
52 - 'method' => 'post' ),
53 - null ) .
54 - Xml::element( 'input', array(
55 - 'type' => 'text',
56 - 'size' => 40,
57 - 'name' => 'target' ) ) .
58 - "\n$submit\n" );
 55+ $wgOut->addWikiMsg( 'nuke-tools' );
 56+ $wgOut->addHTML(
 57+ Xml::openElement( 'form', array(
 58+ 'action' => $this->getTitle()->getLocalURL( 'action=submit' ),
 59+ 'method' => 'post' )
 60+ ) . "$input\n$submit\n"
 61+ );
5962
6063 $wgOut->addHTML( "</form>" );
6164 }
@@ -63,54 +66,54 @@
6467 global $wgUser, $wgOut, $wgLang;
6568
6669 $pages = $this->getNewPages( $username );
67 - $escapedName = wfEscapeWikiText( $username );
 70+
6871 if( count( $pages ) == 0 ) {
69 - $wgOut->addWikiText( wfMsg( 'nuke-nopages', $escapedName ) );
 72+ $wgOut->addWikiMsg( 'nuke-nopages', $username );
7073 return $this->promptForm();
7174 }
72 - $wgOut->addWikiText( wfMsg( 'nuke-list', $escapedName ) );
 75+ $wgOut->addWikiMsg( 'nuke-list', $username );
7376
7477 $nuke = $this->getTitle();
75 - $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-delete' ) ) );
 78+ $submit = Xml::submitButton( wfMsg( 'nuke-submit-delete' ) );
7679
77 - $wgOut->addHTML( Xml::element( 'form', array(
78 - 'action' => $nuke->getLocalURL( 'action=delete' ),
79 - 'method' => 'post' ),
80 - null ) .
81 - "\n<div>" .
82 - wfMsgHtml( 'deletecomment' ) . ' ' .
83 - Xml::element( 'input', array(
84 - 'name' => 'wpReason',
85 - 'value' => $reason,
86 - 'size' => 60 ) ) .
87 - "</div><br />" .
88 - $submit .
89 - Xml::element( 'input', array(
90 - 'type' => 'hidden',
91 - 'name' => 'wpEditToken',
92 - 'value' => $wgUser->editToken() ) ) .
93 - "\n<ul>\n" );
 80+ $wgOut->addHTML(
 81+ Xml::openElement( 'form', array(
 82+ 'action' => $nuke->getLocalURL( 'action=delete' ),
 83+ 'method' => 'post' )
 84+ ) .
 85+ Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
 86+ Xml::inputLabel(
 87+ wfMsg( 'deletecomment' ), 'wpReason', 'wpReason', 60, $reason
 88+ ) . '<br /><br />' .
 89+ Xml::submitButton( wfMsg( 'nuke-submit-delete' ) )
 90+ );
9491
95 - $sk =& $wgUser->getSkin();
 92+ $wgOut->addHTML( '<ul>' );
 93+
 94+ $sk = $wgUser->getSkin();
9695 foreach( $pages as $info ) {
9796 list( $title, $edits ) = $info;
9897 $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
9998 $thumb = $image && $image->exists() ? $image->getThumbnail( 120, 120 ) : false;
 99+
 100+ $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) );
100101
101102 $wgOut->addHTML( '<li>' .
102 - Xml::element( 'input', array(
103 - 'type' => 'checkbox',
104 - 'name' => "pages[]",
105 - 'value' => $title->getPrefixedDbKey(),
106 - 'checked' => 'checked' ) ) .
 103+ Xml::check( 'pages[]', true,
 104+ array( 'value' => $title->getPrefixedDbKey() )
 105+ ) .
107106 '&nbsp;' .
108107 ( $thumb ? $thumb->toHtml( array( 'desc-link' => true ) ) : '' ) .
109108 $sk->makeKnownLinkObj( $title ) .
110109 '&nbsp;(' .
111 - $sk->makeKnownLinkObj( $title, wfMsgExt( 'nchanges', array( 'parsemag' ), $wgLang->formatNum( $edits ) ), 'action=history' ) .
 110+ $sk->makeKnownLinkObj( $title, $changes, 'action=history' ) .
112111 ")</li>\n" );
113112 }
114 - $wgOut->addHTML( "</ul>\n$submit</form>" );
 113+ $wgOut->addHTML(
 114+ "</ul>\n" .
 115+ Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) .
 116+ "</form>"
 117+ );
115118 }
116119
117120 function getNewPages( $username ) {

Status & tagging log