r43468 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43467‎ | r43468 | r43469 >
Date:00:00, 14 November 2008
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Extract url params from GET requests
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevisionCommitter.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -9,8 +9,15 @@
1010 $this->mRepo = CodeRepository::newFromName( $repoName );
1111 $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( $rev ) ) : null;
1212 $this->mPreviewText = false;
 13+ # URL params...
 14+ $this->mAddTags = $this->splitTags( $wgRequest->getText( 'wpTag' ) );
 15+ $this->mRemoveTags = $this->splitTags( $wgRequest->getText( 'wpRemoveTag' ) );
 16+ $this->mStatus = $wgRequest->getText('wpStatus') ?
 17+ $wgRequest->getText('wpStatus') : $this->mRev->getStatus();
 18+ $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext');
1319 $this->mReplyTarget = $replyTarget ?
1420 (int)$replyTarget : $wgRequest->getIntOrNull( 'wpParent' );
 21+ $this->text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" );
1522 $this->mSkipCache = ($wgRequest->getVal( 'action' ) == 'purge');
1623 }
1724
@@ -201,7 +208,25 @@
202209 return $list;
203210 }
204211
205 - function statusForm() {
 212+ protected function splitTags( $input ) {
 213+ $tags = array_map( 'trim', explode( ",", $input ) );
 214+ foreach( $tags as $key => $tag ) {
 215+ $normal = $this->mRev->normalizeTag( $tag );
 216+ if( $normal === false ) {
 217+ return null;
 218+ }
 219+ $tags[$key] = $normal;
 220+ }
 221+ return $tags;
 222+ }
 223+
 224+ protected function listTags( $tags ) {
 225+ if( empty($tags) )
 226+ return "";
 227+ return implode(",",$tags);
 228+ }
 229+
 230+ protected function statusForm() {
206231 global $wgUser;
207232 if( $wgUser->isAllowed( 'codereview-set-status' ) ) {
208233 $repo = $this->mRepo->getName();
@@ -217,8 +242,7 @@
218243 $states = CodeRevision::getPossibleStates();
219244 $out = '';
220245 foreach( $states as $state ) {
221 - $out .= Xml::option( $this->statusDesc( $state ), $state,
222 - $this->mRev->getStatus() == $state );
 246+ $out .= Xml::option( $this->statusDesc( $state ), $state, $this->mStatus === $state );
223247 }
224248 return $out;
225249 }
@@ -228,10 +252,10 @@
229253 $repo = $this->mRepo->getName();
230254 $rev = $this->mRev->getId();
231255 return '<div><table><tr><td>' .
232 - Xml::inputLabel( wfMsg('code-rev-tag-add'), 'wpTag', 'wpTag', '' ) .
233 - '</td><td>&nbsp;</td><td>' .
234 - Xml::inputLabel( wfMsg('code-rev-tag-remove'), 'wpRemoveTag', 'wpRemoveTag', '' ) .
235 - '</td></tr></table></div>';
 256+ Xml::inputLabel( wfMsg('code-rev-tag-add'), 'wpTag', 'wpTag', 20,
 257+ $this->listTags($this->mAddTags) ) . '</td><td>&nbsp;</td><td>' .
 258+ Xml::inputLabel( wfMsg('code-rev-tag-remove'), 'wpRemoveTag', 'wpRemoveTag', 20,
 259+ $this->listTags($this->mRemoveTags) ) . '</td></tr></table></div>';
236260 }
237261
238262 protected function formatTag( $tag ) {
@@ -405,12 +429,12 @@
406430
407431 protected function postCommentForm( $parent=null ) {
408432 global $wgUser;
409 - if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) {
 433+ if( $this->mPreviewText !== false && $parent === $this->mReplyTarget ) {
410434 $preview = $this->previewComment( $this->mPreviewText );
411435 $text = htmlspecialchars( $this->mPreviewText );
412436 } else {
413437 $preview = '';
414 - $text = '';
 438+ $text = $this->text;
415439 }
416440 $repo = $this->mRepo->getName();
417441 $rev = $this->mRev->getId();
Index: trunk/extensions/CodeReview/CodeRevisionCommitter.php
@@ -5,13 +5,6 @@
66 function __construct( $repoName, $rev ){
77 // Parent should set $this->mRepo, $this->mRev, $this->mReplyTarget
88 parent::__construct( $repoName, $rev );
9 -
10 - global $wgRequest;
11 - $this->mAddTags = $this->splitTags( $wgRequest->getText( 'wpTag' ) );
12 - $this->mRemoveTags = $this->splitTags( $wgRequest->getText( 'wpRemoveTag' ) );
13 - $this->mStatus = $wgRequest->getText( 'wpStatus' );
14 - $this->text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" );
15 - $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext');
169 }
1710
1811 function execute() {
@@ -70,18 +63,6 @@
7164 $wgOut->redirect( $redirTitle->getFullUrl() );
7265 }
7366
74 - function splitTags( $input ) {
75 - $tags = array_map( 'trim', explode( ",", $input ) );
76 - foreach( $tags as $key => $tag ) {
77 - $normal = $this->mRev->normalizeTag( $tag );
78 - if( $normal === false ) {
79 - return null;
80 - }
81 - $tags[$key] = $normal;
82 - }
83 - return $tags;
84 - }
85 -
8667 public function validPost( $permission ) {
8768 global $wgUser, $wgRequest;
8869 return parent::validPost($permission) && $wgRequest->wasPosted()

Comments

#Comment by Brion VIBBER (talk | contribs)   00:35, 14 November 2008

yay! this resolves fixme from r43463

Status & tagging log