r84748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84747‎ | r84748 | r84749 >
Date:15:09, 25 March 2011
Author:demon
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.17wmf1/includes/HTMLForm.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/HTMLForm.php
@@ -187,23 +187,26 @@
188188 }
189189
190190 /**
191 - * The here's-one-I-made-earlier option: do the submission if
192 - * posted, or display the form with or without funky valiation
193 - * errors
194 - * @return Bool or Status whether submission was successful.
 191+ * Prepare form for submission
195192 */
196 - function show() {
 193+ function prepareForm() {
197194 # Check if we have the info we need
198195 if ( ! $this->mTitle ) {
199196 throw new MWException( "You must call setTitle() on an HTMLForm" );
200197 }
201198
 199+ // FIXME shouldn't this be closer to displayForm() ?
202200 self::addJS();
203201
204202 # Load data from the request.
205203 $this->loadData();
 204+ }
206205
207 - # Try a submission
 206+ /**
 207+ * Try submitting, with edit token check first
 208+ * @return Status|boolean
 209+ */
 210+ function tryAuthorizedSubmit() {
208211 global $wgUser, $wgRequest;
209212 $editToken = $wgRequest->getVal( 'wpEditToken' );
210213
@@ -211,12 +214,23 @@
212215 if ( $this->getMethod() != 'post' || $wgUser->matchEditToken( $editToken ) ) {
213216 $result = $this->trySubmit();
214217 }
 218+ return $result;
 219+ }
215220
 221+ /**
 222+ * The here's-one-I-made-earlier option: do the submission if
 223+ * posted, or display the form with or without funky valiation
 224+ * errors
 225+ * @return Bool or Status whether submission was successful.
 226+ */
 227+ function show() {
 228+ $this->prepareForm();
 229+
 230+ $result = $this->tryAuthorizedSubmit();
216231 if ( $result === true || ( $result instanceof Status && $result->isGood() ) ){
217232 return $result;
218233 }
219234
220 - # Display form.
221235 $this->displayForm( $result );
222236 return false;
223237 }
@@ -541,7 +555,6 @@
542556 $this->mSubmitTooltip = $name;
543557 }
544558
545 -
546559 /**
547560 * Set the id for the submit button.
548561 * @param $t String. FIXME: Integrity is *not* validated
Property changes on: branches/wmf/1.17wmf1/includes/HTMLForm.php
___________________________________________________________________
Modified: svn:mergeinfo
549562 Merged /trunk/phase3/includes/HTMLForm.php:r78425

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78425refactored HTMLForm show() into three methods, in case you want to process a ...neilk01:17, 15 December 2010

Status & tagging log