Index: branches/REL1_17/phase3/includes/HTMLForm.php |
— | — | @@ -42,6 +42,10 @@ |
43 | 43 | * 'validation-callback' -- a function name to give you the chance |
44 | 44 | * to impose extra validation on the field input. |
45 | 45 | * @see HTMLForm::validate() |
| 46 | + * 'name' -- By default, the 'name' attribute of the input field |
| 47 | + * is "wp{$fieldname}". If you want a different name |
| 48 | + * (eg one without the "wp" prefix), specify it here and |
| 49 | + * it will be used without modification. |
46 | 50 | * |
47 | 51 | * TODO: Document 'section' / 'subsection' stuff |
48 | 52 | */ |
— | — | @@ -116,15 +120,11 @@ |
117 | 121 | ? $info['section'] |
118 | 122 | : ''; |
119 | 123 | |
120 | | - $info['name'] = isset( $info['name'] ) |
121 | | - ? $info['name'] |
122 | | - : $fieldname; |
123 | | - |
124 | 124 | if ( isset( $info['type'] ) && $info['type'] == 'file' ) { |
125 | 125 | $this->mUseMultipart = true; |
126 | 126 | } |
127 | 127 | |
128 | | - $field = self::loadInputFromParameters( $info ); |
| 128 | + $field = self::loadInputFromParameters( $fieldname, $info ); |
129 | 129 | $field->mParent = $this; |
130 | 130 | |
131 | 131 | $setSection =& $loadedDescriptor; |
— | — | @@ -166,7 +166,7 @@ |
167 | 167 | * @param $descriptor input Descriptor, as described above |
168 | 168 | * @return HTMLFormField subclass |
169 | 169 | */ |
170 | | - static function loadInputFromParameters( $descriptor ) { |
| 170 | + static function loadInputFromParameters( $fieldname, $descriptor ) { |
171 | 171 | if ( isset( $descriptor['class'] ) ) { |
172 | 172 | $class = $descriptor['class']; |
173 | 173 | } elseif ( isset( $descriptor['type'] ) ) { |
— | — | @@ -177,6 +177,8 @@ |
178 | 178 | if ( !$class ) { |
179 | 179 | throw new MWException( "Descriptor with no class: " . print_r( $descriptor, true ) ); |
180 | 180 | } |
| 181 | + |
| 182 | + $descriptor['fieldname'] = $fieldname; |
181 | 183 | |
182 | 184 | $obj = new $class( $descriptor ); |
183 | 185 | |
— | — | @@ -205,7 +207,7 @@ |
206 | 208 | $editToken = $wgRequest->getVal( 'wpEditToken' ); |
207 | 209 | |
208 | 210 | $result = false; |
209 | | - if ( $wgUser->matchEditToken( $editToken ) ) { |
| 211 | + if ( $this->getMethod() != 'post' || $wgUser->matchEditToken( $editToken ) ) { |
210 | 212 | $result = $this->trySubmit(); |
211 | 213 | } |
212 | 214 | |
— | — | @@ -304,7 +306,7 @@ |
305 | 307 | |
306 | 308 | /** |
307 | 309 | * Add a hidden field to the output |
308 | | - * @param $name String field name |
| 310 | + * @param $name String field name. This will be used exactly as entered |
309 | 311 | * @param $value String field value |
310 | 312 | * @param $attribs Array |
311 | 313 | */ |
— | — | @@ -380,8 +382,11 @@ |
381 | 383 | global $wgUser; |
382 | 384 | |
383 | 385 | $html = ''; |
384 | | - $html .= Html::hidden( 'wpEditToken', $wgUser->editToken(), array( 'id' => 'wpEditToken' ) ) . "\n"; |
385 | | - $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
| 386 | + |
| 387 | + if( $this->getMethod() == 'post' ){ |
| 388 | + $html .= Html::hidden( 'wpEditToken', $wgUser->editToken(), array( 'id' => 'wpEditToken' ) ) . "\n"; |
| 389 | + $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
| 390 | + } |
386 | 391 | |
387 | 392 | foreach ( $this->mHiddenFields as $data ) { |
388 | 393 | list( $value, $attribs ) = $data; |
— | — | @@ -768,17 +773,17 @@ |
769 | 774 | $this->mLabel = $params['label']; |
770 | 775 | } |
771 | 776 | |
| 777 | + $this->mName = "wp{$params['fieldname']}"; |
772 | 778 | if ( isset( $params['name'] ) ) { |
773 | | - $name = $params['name']; |
774 | | - $validName = Sanitizer::escapeId( $name ); |
775 | | - |
776 | | - if ( $name != $validName ) { |
777 | | - throw new MWException( "Invalid name '$name' passed to " . __METHOD__ ); |
778 | | - } |
779 | | - |
780 | | - $this->mName = 'wp' . $name; |
781 | | - $this->mID = 'mw-input-' . $name; |
| 779 | + $this->mName = $params['name']; |
782 | 780 | } |
| 781 | + |
| 782 | + $validName = Sanitizer::escapeId( $this->mName ); |
| 783 | + if ( $this->mName != $validName && !isset( $params['nodata'] ) ) { |
| 784 | + throw new MWException( "Invalid name '{$this->mName}' passed to " . __METHOD__ ); |
| 785 | + } |
| 786 | + |
| 787 | + $this->mID = "mw-input-{$this->mName}"; |
783 | 788 | |
784 | 789 | if ( isset( $params['default'] ) ) { |
785 | 790 | $this->mDefault = $params['default']; |
— | — | @@ -1191,13 +1196,18 @@ |
1192 | 1197 | # If one of the options' 'name' is int(0), it is automatically selected. |
1193 | 1198 | # because PHP sucks and things int(0) == 'some string'. |
1194 | 1199 | # Working around this by forcing all of them to strings. |
1195 | | - $options = array_map( 'strval', $this->mParams['options'] ); |
| 1200 | + foreach( $this->mParams['options'] as $key => &$opt ){ |
| 1201 | + if( is_int( $opt ) ){ |
| 1202 | + $opt = strval( $opt ); |
| 1203 | + } |
| 1204 | + } |
| 1205 | + unset( $opt ); # PHP keeps $opt around as a reference, which is a bit scary |
1196 | 1206 | |
1197 | 1207 | if ( !empty( $this->mParams['disabled'] ) ) { |
1198 | 1208 | $select->setAttribute( 'disabled', 'disabled' ); |
1199 | 1209 | } |
1200 | 1210 | |
1201 | | - $select->addOptions( $options ); |
| 1211 | + $select->addOptions( $this->mParams['options'] ); |
1202 | 1212 | |
1203 | 1213 | return $select->getHTML(); |
1204 | 1214 | } |
— | — | @@ -1472,9 +1482,6 @@ |
1473 | 1483 | class HTMLHiddenField extends HTMLFormField { |
1474 | 1484 | public function __construct( $params ) { |
1475 | 1485 | parent::__construct( $params ); |
1476 | | - # forcing the 'wp' prefix on hidden field names |
1477 | | - # is undesirable |
1478 | | - $this->mName = substr( $this->mName, 2 ); |
1479 | 1486 | |
1480 | 1487 | # Per HTML5 spec, hidden fields cannot be 'required' |
1481 | 1488 | # http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#hidden-state |
Index: branches/REL1_17/phase3/includes/specials/SpecialUploadStash.php |
— | — | @@ -329,7 +329,13 @@ |
330 | 330 | // create the form, which will also be used to execute a callback to process incoming form data |
331 | 331 | // this design is extremely dubious, but supposedly HTMLForm is our standard now? |
332 | 332 | |
333 | | - $form = new HTMLForm( array( 'clear' => array( 'class' => 'HTMLHiddenField', 'default' => true ) ), 'clearStashedUploads' ); |
| 333 | + $form = new HTMLForm( array( |
| 334 | + 'Clear' => array( |
| 335 | + 'type' => 'hidden', |
| 336 | + 'default' => true, |
| 337 | + 'name' => 'clear', |
| 338 | + ) |
| 339 | + ), 'clearStashedUploads' ); |
334 | 340 | $form->setSubmitCallback( array( __CLASS__, 'tryClearStashedUploads' ) ); |
335 | 341 | $form->setTitle( $this->getTitle() ); |
336 | 342 | $form->addHiddenField( 'clear', true, array( 'type' => 'boolean' ) ); |
Property changes on: branches/REL1_17/phase3/includes/specials/SpecialUploadStash.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
337 | 343 | Merged /trunk/phase3/includes/specials/SpecialUploadStash.php:r78452,78454,78566,78924 |
Index: branches/REL1_17/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -1030,14 +1030,14 @@ |
1031 | 1031 | ); |
1032 | 1032 | } |
1033 | 1033 | |
1034 | | - $descriptor['wpDestFileWarningAck'] = array( |
| 1034 | + $descriptor['DestFileWarningAck'] = array( |
1035 | 1035 | 'type' => 'hidden', |
1036 | 1036 | 'id' => 'wpDestFileWarningAck', |
1037 | 1037 | 'default' => $this->mDestWarningAck ? '1' : '', |
1038 | 1038 | ); |
1039 | 1039 | |
1040 | 1040 | if ( $this->mForReUpload ) { |
1041 | | - $descriptor['wpForReUpload'] = array( |
| 1041 | + $descriptor['ForReUpload'] = array( |
1042 | 1042 | 'type' => 'hidden', |
1043 | 1043 | 'id' => 'wpForReUpload', |
1044 | 1044 | 'default' => '1', |
Index: branches/REL1_17/phase3/includes/specials/SpecialEmailuser.php |
— | — | @@ -57,7 +57,6 @@ |
58 | 58 | 'id' => 'mw-emailuser-recipient', |
59 | 59 | ), |
60 | 60 | 'Target' => array( |
61 | | - 'name' => 'wpTarget', |
62 | 61 | 'type' => 'hidden', |
63 | 62 | 'default' => $this->mTargetObj->getName(), |
64 | 63 | ), |
Index: branches/REL1_17/phase3/includes/Preferences.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | ## Prod in defaults from the user |
69 | 69 | foreach ( $defaultPreferences as $name => &$info ) { |
70 | 70 | $prefFromUser = self::getOptionFromUser( $name, $info, $user ); |
71 | | - $field = HTMLForm::loadInputFromParameters( $info ); // For validation |
| 71 | + $field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation |
72 | 72 | $defaultOptions = User::getDefaultOptions(); |
73 | 73 | $globalDefault = isset( $defaultOptions[$name] ) |
74 | 74 | ? $defaultOptions[$name] |