Revision: 43468
Author:   aaron
Date:     2008-11-14 00:00:48 +0000 (Fri, 14 Nov 2008)

Log Message:
-----------
Extract url params from GET requests

Modified Paths:
--------------
    trunk/extensions/CodeReview/CodeRevisionCommitter.php
    trunk/extensions/CodeReview/CodeRevisionView.php

Modified: trunk/extensions/CodeReview/CodeRevisionCommitter.php
===================================================================
--- trunk/extensions/CodeReview/CodeRevisionCommitter.php       2008-11-13 
23:39:14 UTC (rev 43467)
+++ trunk/extensions/CodeReview/CodeRevisionCommitter.php       2008-11-14 
00:00:48 UTC (rev 43468)
@@ -5,13 +5,6 @@
        function __construct( $repoName, $rev ){
                // Parent should set $this->mRepo, $this->mRev, 
$this->mReplyTarget
                parent::__construct( $repoName, $rev );
-               
-               global $wgRequest;
-               $this->mAddTags = $this->splitTags( $wgRequest->getText( 
'wpTag' ) );
-               $this->mRemoveTags = $this->splitTags( $wgRequest->getText( 
'wpRemoveTag' ) );
-               $this->mStatus = $wgRequest->getText( 'wpStatus' );
-               $this->text = $wgRequest->getText( 
"wpReply{$this->mReplyTarget}" );
-               $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext');
        }
 
        function execute() {
@@ -70,18 +63,6 @@
                $wgOut->redirect( $redirTitle->getFullUrl() );
        }
        
-       function splitTags( $input ) {
-               $tags = array_map( 'trim', explode( ",", $input ) );
-               foreach( $tags as $key => $tag ) {
-                       $normal = $this->mRev->normalizeTag( $tag );
-                       if( $normal === false ) {
-                               return null;
-                       }
-                       $tags[$key] = $normal;
-               }
-               return $tags;
-       }
-       
        public function validPost( $permission ) {
                global $wgUser, $wgRequest;
                return parent::validPost($permission) && $wgRequest->wasPosted()

Modified: trunk/extensions/CodeReview/CodeRevisionView.php
===================================================================
--- trunk/extensions/CodeReview/CodeRevisionView.php    2008-11-13 23:39:14 UTC 
(rev 43467)
+++ trunk/extensions/CodeReview/CodeRevisionView.php    2008-11-14 00:00:48 UTC 
(rev 43468)
@@ -9,8 +9,15 @@
                $this->mRepo = CodeRepository::newFromName( $repoName );
                $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( 
$rev ) ) : null;
                $this->mPreviewText = false;
+               # URL params...
+               $this->mAddTags = $this->splitTags( $wgRequest->getText( 
'wpTag' ) );
+               $this->mRemoveTags = $this->splitTags( $wgRequest->getText( 
'wpRemoveTag' ) );
+               $this->mStatus = $wgRequest->getText('wpStatus') ? 
+                       $wgRequest->getText('wpStatus') : 
$this->mRev->getStatus();
+               $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext');
                $this->mReplyTarget = $replyTarget ? 
                        (int)$replyTarget : $wgRequest->getIntOrNull( 
'wpParent' );
+               $this->text = $wgRequest->getText( 
"wpReply{$this->mReplyTarget}" );
                $this->mSkipCache = ($wgRequest->getVal( 'action' ) == 'purge');
        }
 
@@ -201,7 +208,25 @@
                return $list;
        }
        
-       function statusForm() {
+       protected function splitTags( $input ) {
+               $tags = array_map( 'trim', explode( ",", $input ) );
+               foreach( $tags as $key => $tag ) {
+                       $normal = $this->mRev->normalizeTag( $tag );
+                       if( $normal === false ) {
+                               return null;
+                       }
+                       $tags[$key] = $normal;
+               }
+               return $tags;
+       }
+       
+       protected function listTags( $tags ) {
+               if( empty($tags) )
+                       return "";
+               return implode(",",$tags);
+       }
+       
+       protected function statusForm() {
                global $wgUser;
                if( $wgUser->isAllowed( 'codereview-set-status' ) ) {
                        $repo = $this->mRepo->getName();
@@ -217,8 +242,7 @@
                $states = CodeRevision::getPossibleStates();
                $out = '';
                foreach( $states as $state ) {
-                       $out .= Xml::option( $this->statusDesc( $state ), 
$state,
-                               $this->mRev->getStatus() == $state );
+                       $out .= Xml::option( $this->statusDesc( $state ), 
$state, $this->mStatus === $state );
                }
                return $out;
        }
@@ -228,10 +252,10 @@
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
                return '<div><table><tr><td>' .
-                       Xml::inputLabel( wfMsg('code-rev-tag-add'), 'wpTag', 
'wpTag', '' ) .
-                       '</td><td>&nbsp;</td><td>' .
-                       Xml::inputLabel( wfMsg('code-rev-tag-remove'), 
'wpRemoveTag', 'wpRemoveTag', '' ) .
-                       '</td></tr></table></div>';
+                       Xml::inputLabel( wfMsg('code-rev-tag-add'), 'wpTag', 
'wpTag', 20,
+                               $this->listTags($this->mAddTags) ) . 
'</td><td>&nbsp;</td><td>' .
+                       Xml::inputLabel( wfMsg('code-rev-tag-remove'), 
'wpRemoveTag', 'wpRemoveTag', 20,
+                               $this->listTags($this->mRemoveTags) ) . 
'</td></tr></table></div>';
        }
        
        protected function formatTag( $tag ) {
@@ -405,12 +429,12 @@
        
        protected function postCommentForm( $parent=null ) {
                global $wgUser;
-               if( $this->mPreviewText != false && $parent === 
$this->mReplyTarget ) {
+               if( $this->mPreviewText !== false && $parent === 
$this->mReplyTarget ) {
                        $preview = $this->previewComment( $this->mPreviewText );
                        $text = htmlspecialchars( $this->mPreviewText );
                } else {
                        $preview = '';
-                       $text = '';
+                       $text = $this->text;
                }
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to