r59368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59367‎ | r59368 | r59369 >
Date:20:33, 23 November 2009
Author:dantman
Status:deferred
Tags:
Comment:
Fix newline inside input which breaks embedding forms. Add support for class/style inside standard input buttons.
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -449,62 +449,65 @@
450450 return $additional_template_text;
451451 }
452452
453 - static function summaryInputHTML($is_disabled, $label = null) {
 453+ static function summaryInputHTML($is_disabled, $label = null, $attr = array()) {
454454 global $sfgTabIndex;
455455
456456 $sfgTabIndex++;
457457 if ($label == null)
458458 $label = wfMsg('summary');
459 - $disabled_text = ($is_disabled) ? "disabled" : "";
 459+ $disabled_text = ($is_disabled) ? " disabled" : "";
 460+ $attr = Xml::expandAttributes($attr);
460461 $text =<<<END
461462 <span id='wpSummaryLabel'><label for='wpSummary'>$label</label></span>
462 - <input tabindex="$sfgTabIndex" type='text' value="" name='wpSummary' id='wpSummary' maxlength='200' size='60' $disabled_text/>
 463+ <input tabindex="$sfgTabIndex" type='text' value="" name='wpSummary' id='wpSummary' maxlength='200' size='60'$disabled_text$attr/>
463464
464465 END;
465466 return $text;
466467 }
467468
468 - static function minorEditInputHTML($is_disabled, $label = null) {
 469+ static function minorEditInputHTML($is_disabled, $label = null, $attr = array()) {
469470 global $sfgTabIndex;
470471
471472 $sfgTabIndex++;
472 - $disabled_text = ($is_disabled) ? "disabled" : "";
 473+ $disabled_text = ($is_disabled) ? " disabled" : "";
473474 if ($label == null)
474475 $label = wfMsgExt('minoredit', array('parseinline'));
475476 $accesskey = wfMsg('accesskey-minoredit');
476477 $tooltip = wfMsg('tooltip-minoredit');
 478+ $attr = Xml::expandAttributes($attr);
477479 $text =<<<END
478 - <input tabindex="$sfgTabIndex" type="checkbox" value="1" name="wpMinoredit" accesskey="$accesskey" id="wpMinoredit" $disabled_text/>
 480+ <input tabindex="$sfgTabIndex" type="checkbox" value="1" name="wpMinoredit" accesskey="$accesskey" id="wpMinoredit"$disabled_text$attr/>
479481 <label for="wpMinoredit" title="$tooltip">$label</label>
480482
481483 END;
482484 return $text;
483485 }
484486
485 - static function watchInputHTML($is_disabled, $label = null) {
 487+ static function watchInputHTML($is_disabled, $label = null, $attr = array()) {
486488 global $sfgTabIndex, $wgUser, $wgTitle;
487489
488490 $sfgTabIndex++;
489491 $checked_text = "";
490 - $disabled_text = ($is_disabled) ? "disabled" : "";
 492+ $disabled_text = ($is_disabled) ? " disabled" : "";
491493 // figure out if the checkbox should be checked -
492494 // this code borrowed from /includes/EditPage.php
493495 if ($wgUser->getOption('watchdefault')) {
494496 # Watch all edits
495 - $checked_text = "checked";
 497+ $checked_text = " checked";
496498 } elseif ($wgUser->getOption('watchcreations') && !$wgTitle->exists() ) {
497499 # Watch creations
498 - $checked_text = "checked";
 500+ $checked_text = " checked";
499501 } elseif ($wgTitle->userIsWatching()) {
500502 # Already watched
501 - $checked_text = "checked";
 503+ $checked_text = " checked";
502504 }
503505 if ($label == null)
504506 $label = wfMsgExt('watchthis', array('parseinline'));
505507 $accesskey = htmlspecialchars(wfMsg('accesskey-watch'));
506508 $tooltip = htmlspecialchars(wfMsg('tooltip-watch'));
 509+ $attr = Xml::expandAttributes($attr);
507510 $text =<<<END
508 - <input tabindex="$sfgTabIndex" type="checkbox" name="wpWatchthis" accesskey="$accesskey" id='wpWatchthis' $checked_text $disabled_text/>
 511+ <input tabindex="$sfgTabIndex" type="checkbox" name="wpWatchthis" accesskey="$accesskey" id='wpWatchthis'$checked_text$disabled_text$attr/>
509512 <label for="wpWatchthis" title="$tooltip">$label</label>
510513
511514 END;
@@ -520,7 +523,7 @@
521524 return " $button_html\n";
522525 }
523526
524 - static function saveButtonHTML($is_disabled, $label = null) {
 527+ static function saveButtonHTML($is_disabled, $label = null, $attr = array()) {
525528 global $sfgTabIndex;
526529
527530 $sfgTabIndex++;
@@ -536,11 +539,11 @@
537540 'accesskey' => wfMsg('accesskey-save'),
538541 'title' => wfMsg('tooltip-save'),
539542 $disabled_text => '',
540 - );
 543+ ) + $attr;
541544 return self::buttonHTML($temp);
542545 }
543546
544 - static function showPreviewButtonHTML($is_disabled, $label = null) {
 547+ static function showPreviewButtonHTML($is_disabled, $label = null, $attr = array()) {
545548 global $sfgTabIndex;
546549
547550 $sfgTabIndex++;
@@ -556,11 +559,11 @@
557560 'accesskey' => wfMsg('accesskey-preview'),
558561 'title' => wfMsg('tooltip-preview'),
559562 $disabled_text => '',
560 - );
 563+ ) + $attr;
561564 return self::buttonHTML($temp);
562565 }
563566
564 - static function showChangesButtonHTML($is_disabled, $label = null) {
 567+ static function showChangesButtonHTML($is_disabled, $label = null, $attr = array()) {
565568 global $sfgTabIndex;
566569
567570 $sfgTabIndex++;
@@ -576,11 +579,11 @@
577580 'accesskey' => wfMsg('accesskey-diff'),
578581 'title' => wfMsg('tooltip-diff'),
579582 $disabled_text => '',
580 - );
 583+ ) + $attr;
581584 return self::buttonHTML($temp);
582585 }
583586
584 - static function cancelLinkHTML($is_disabled, $label = null) {
 587+ static function cancelLinkHTML($is_disabled, $label = null, $attr = array()) {
585588 global $wgUser, $wgTitle;
586589
587590 $sk = $wgUser->getSkin();
@@ -606,7 +609,7 @@
607610 return $text;
608611 }
609612
610 - static function runQueryButtonHTML($is_disabled = false, $label = null) {
 613+ static function runQueryButtonHTML($is_disabled = false, $label = null, $attr = array()) {
611614 // is_disabled is currently ignored
612615 global $sfgTabIndex;
613616
@@ -621,7 +624,7 @@
622625 'tabindex' => $sfgTabIndex,
623626 'value' => $label,
624627 'title' => $label,
625 - ));
 628+ ) + $attr);
626629 }
627630
628631 // Much of this function is based on MediaWiki's EditPage::showEditForm()
Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -331,8 +331,7 @@
332332 $size = "35";
333333
334334 $text =<<<END
335 - <input tabindex="$sfgTabIndex" id="$input_id" name="$input_name" type="text"
336 - value="" size="$size" class="$className"
 335+ <input tabindex="$sfgTabIndex" id="$input_id" name="$input_name" type="text" value="" size="$size" class="$className"
337336 END;
338337 if ($is_disabled)
339338 $text .= " disabled";
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -935,6 +935,7 @@
936936 // handle all the possible values
937937 $input_name = $tag_components[1];
938938 $input_label = null;
 939+ $attr = array();
939940
940941 // if it's a query, ignore all standard inputs except run query
941942 if (($is_query && $input_name != 'run query') || (!$is_query && $input_name == 'run query')) {
@@ -953,8 +954,14 @@
954955 $free_text_components[] = 'edittools';
955956 }
956957 } elseif (count($sub_components) == 2) {
957 - if ($sub_components[0] == 'label') {
 958+ switch($sub_components[0]) {
 959+ case 'label':
958960 $input_label = $sub_components[1];
 961+ break;
 962+ case 'class':
 963+ case 'style':
 964+ $attr[$sub_components[0]] = $sub_components[1];
 965+ break;
959966 }
960967 // free text input needs more handling than the rest
961968 if ($input_name == 'free text' || $input_name == '<freetext>') {
@@ -965,21 +972,21 @@
966973 }
967974 }
968975 if ($input_name == 'summary') {
969 - $new_text = SFFormUtils::summaryInputHTML($form_is_disabled, $input_label);
 976+ $new_text = SFFormUtils::summaryInputHTML($form_is_disabled, $input_label, $attr);
970977 } elseif ($input_name == 'minor edit') {
971 - $new_text = SFFormUtils::minorEditInputHTML($form_is_disabled, $input_label);
 978+ $new_text = SFFormUtils::minorEditInputHTML($form_is_disabled, $input_label, $attr);
972979 } elseif ($input_name == 'watch') {
973 - $new_text = SFFormUtils::watchInputHTML($form_is_disabled, $input_label);
 980+ $new_text = SFFormUtils::watchInputHTML($form_is_disabled, $input_label, $attr);
974981 } elseif ($input_name == 'save') {
975 - $new_text = SFFormUtils::saveButtonHTML($form_is_disabled, $input_label);
 982+ $new_text = SFFormUtils::saveButtonHTML($form_is_disabled, $input_label, $attr);
976983 } elseif ($input_name == 'preview') {
977 - $new_text = SFFormUtils::showPreviewButtonHTML($form_is_disabled, $input_label);
 984+ $new_text = SFFormUtils::showPreviewButtonHTML($form_is_disabled, $input_label, $attr);
978985 } elseif ($input_name == 'changes') {
979 - $new_text = SFFormUtils::showChangesButtonHTML($form_is_disabled, $input_label);
 986+ $new_text = SFFormUtils::showChangesButtonHTML($form_is_disabled, $input_label, $attr);
980987 } elseif ($input_name == 'cancel') {
981 - $new_text = SFFormUtils::cancelLinkHTML($form_is_disabled, $input_label);
 988+ $new_text = SFFormUtils::cancelLinkHTML($form_is_disabled, $input_label, $attr);
982989 } elseif ($input_name == 'run query') {
983 - $new_text = SFFormUtils::runQueryButtonHTML($form_is_disabled, $input_label);
 990+ $new_text = SFFormUtils::runQueryButtonHTML($form_is_disabled, $input_label, $attr);
984991 }
985992 $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
986993 // =====================================================

Status & tagging log