Index: branches/wmf/1.17wmf1/includes/HTMLForm.php |
— | — | @@ -187,23 +187,26 @@ |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
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 |
195 | 192 | */ |
196 | | - function show() { |
| 193 | + function prepareForm() { |
197 | 194 | # Check if we have the info we need |
198 | 195 | if ( ! $this->mTitle ) { |
199 | 196 | throw new MWException( "You must call setTitle() on an HTMLForm" ); |
200 | 197 | } |
201 | 198 | |
| 199 | + // FIXME shouldn't this be closer to displayForm() ? |
202 | 200 | self::addJS(); |
203 | 201 | |
204 | 202 | # Load data from the request. |
205 | 203 | $this->loadData(); |
| 204 | + } |
206 | 205 | |
207 | | - # Try a submission |
| 206 | + /** |
| 207 | + * Try submitting, with edit token check first |
| 208 | + * @return Status|boolean |
| 209 | + */ |
| 210 | + function tryAuthorizedSubmit() { |
208 | 211 | global $wgUser, $wgRequest; |
209 | 212 | $editToken = $wgRequest->getVal( 'wpEditToken' ); |
210 | 213 | |
— | — | @@ -211,12 +214,23 @@ |
212 | 215 | if ( $this->getMethod() != 'post' || $wgUser->matchEditToken( $editToken ) ) { |
213 | 216 | $result = $this->trySubmit(); |
214 | 217 | } |
| 218 | + return $result; |
| 219 | + } |
215 | 220 | |
| 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(); |
216 | 231 | if ( $result === true || ( $result instanceof Status && $result->isGood() ) ){ |
217 | 232 | return $result; |
218 | 233 | } |
219 | 234 | |
220 | | - # Display form. |
221 | 235 | $this->displayForm( $result ); |
222 | 236 | return false; |
223 | 237 | } |
— | — | @@ -541,7 +555,6 @@ |
542 | 556 | $this->mSubmitTooltip = $name; |
543 | 557 | } |
544 | 558 | |
545 | | - |
546 | 559 | /** |
547 | 560 | * Set the id for the submit button. |
548 | 561 | * @param $t String. FIXME: Integrity is *not* validated |
Property changes on: branches/wmf/1.17wmf1/includes/HTMLForm.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
549 | 562 | Merged /trunk/phase3/includes/HTMLForm.php:r78425 |