r106564 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106563‎ | r106564 | r106565 >
Date:15:09, 18 December 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Make some more buttons disabled if the form is disabled, removed unused message from JS vars
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -235,26 +235,35 @@
236236 * Creates the HTML for the inner table for every instance of a
237237 * multiple-instance template in the form.
238238 */
239 - function multipleTemplateInstanceTableHTML( $mainText ) {
 239+ function multipleTemplateInstanceTableHTML( $form_is_disabled, $mainText ) {
240240 global $sfgTabIndex, $sfgScriptPath;
241241
242 - $remove_text = wfMsg( 'sf_formedit_remove' );
 242+ $attributes = array(
 243+ 'type' => 'button',
 244+ 'value' => wfMsg( 'sf_formedit_remove' ),
 245+ 'tabindex' => $sfgTabIndex,
 246+ 'class' => 'remover',
 247+ );
 248+
 249+ $rearranger = 'class="rearrangerImage"';
 250+
 251+ if ( $form_is_disabled ) {
 252+ $attributes['disabled'] = 'disabled';
 253+ $rearranger = '';
 254+ }
 255+
 256+ $removeButton = Xml::element( 'input', $attributes );
 257+
243258 $text =<<<END
244 -
245259 <table>
246260 <tr>
247 - <td>
248 - $mainText
249 - </td>
250 - <td class="removeButton">
251 - <input type="button" value="$remove_text" tabindex="$sfgTabIndex" class="remover" />
252 - </td>
 261+ <td>$mainText</td>
 262+ <td class="removeButton">$removeButton</td>
253263 <td class="instanceRearranger">
254 - <img src="$sfgScriptPath/skins/rearranger.png" class="rearrangerImage" />
 264+ <img src="$sfgScriptPath/skins/rearranger.png" $rearranger />
255265 </td>
256266 </tr>
257267 </table>
258 -
259268 END;
260269
261270 return $text;
@@ -264,7 +273,7 @@
265274 * Creates the HTML for a single instance of a multiple-instance template;
266275 * plus the end tags for the full multiple-instance HTML.
267276 */
268 - function multipleTemplateInstanceHTML( $all_instances_printed, &$section, $instance_num, $add_button_text ) {
 277+ function multipleTemplateInstanceHTML( $form_is_disabled, $all_instances_printed, &$section, $instance_num, $add_button_text ) {
269278 global $sfgTabIndex;
270279
271280 if ( ! $all_instances_printed ) {
@@ -280,7 +289,7 @@
281290 // wikis before SF 2.0.9.
282291 'class' => "multipleTemplateInstance multipleTemplate"
283292 ),
284 - $this->multipleTemplateInstanceTableHTML( $section )
 293+ $this->multipleTemplateInstanceTableHTML( $form_is_disabled, $section )
285294 ) . "\n";
286295
287296 } else { //if ( $all_instances_printed ) {
@@ -293,12 +302,20 @@
294303 'class' => "multipleTemplateStarter",
295304 'style' => "display: none",
296305 ),
297 - $this->multipleTemplateInstanceTableHTML( $section )
 306+ $this->multipleTemplateInstanceTableHTML( $form_is_disabled, $section )
298307 ) . "\n";
 308+
 309+ $attributes = array(
 310+ 'type' => 'button',
 311+ 'value' => Sanitizer::decodeCharReferences( $add_button_text ),
 312+ 'tabindex' => $sfgTabIndex,
 313+ 'class' => 'multipleTemplateAdder',
 314+ );
 315+ if ( $form_is_disabled ) $attributes['disabled'] = 'disabled';
 316+ $button = Xml::element( 'input', $attributes );
299317 $text .= <<<END
300318 </div><!-- multipleTemplateList -->
301 - <p style="margin-left:10px;" />
302 - <p><input type="button" value="$add_button_text" tabindex="$sfgTabIndex" class="multipleTemplateAdder" /></p>
 319+ <p>$button</p>
303320 </div><!-- multipleTemplateWrapper -->
304321 END;
305322 }
@@ -1400,14 +1417,14 @@
14011418 if ( $allow_multiple ) {
14021419 if ( $curPlaceholder == null ) {
14031420 // The normal process.
1404 - $form_text .= $this->multipleTemplateInstanceHTML( $all_instances_printed, $section, $instance_num, $add_button_text );
 1421+ $form_text .= $this->multipleTemplateInstanceHTML( $form_is_disabled, $all_instances_printed, $section, $instance_num, $add_button_text );
14051422 } else { // if ( $curPlaceholder != null ){
14061423 // The template text won't be appended at the end of the template like for usual multiple template forms.
14071424 // The HTML text will then be stored in the $multipleTemplateString variable,
14081425 // and then added in the right @insertHTML_".$placeHolderField."@"; position
14091426 // Optimization: actually, instead of separating the processes, the usual multiple
14101427 // template forms could also be handled this way if a fitting placeholder tag was added.
1411 - $multipleTemplateString .= $this->multipleTemplateInstanceHTML( $all_instances_printed, $section, $instance_num, $add_button_text );
 1428+ $multipleTemplateString .= $this->multipleTemplateInstanceHTML( $form_is_disabled, $all_instances_printed, $section, $instance_num, $add_button_text );
14121429 // We replace the $multipleTemplateString HTML into the
14131430 // current placeholder tag, but also add another
14141431 // placeholder tag, to keep track of it.
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -17,7 +17,6 @@
1818 // global $sfgInitJSFunctions, $sfgValidationJSFunctions;
1919 global $sfgShowOnSelect;
2020
21 - $vars['sfgRemoveText'] = wfMsg( 'sf_formedit_remove' );
2221 $vars['sfgAutocompleteOnAllChars'] = $sfgAutocompleteOnAllChars;
2322 $vars['sfgScriptPath'] = $sfgScriptPath;
2423 // variables that are associative arrays need to be cast as