r56078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56077‎ | r56078 | r56079 >
Date:23:40, 8 September 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added escaping of quotes in hidden fields; replaced wfElement with Xml::element() when possible
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -395,6 +395,7 @@
396396 }
397397
398398 static function hiddenFieldHTML($input_name, $cur_value) {
 399+ $cur_value = str_replace('"', '"', $cur_value);
399400 $text =<<<END
400401 <input type="hidden" name="$input_name" value="$cur_value" />
401402
@@ -497,6 +498,15 @@
498499 return $text;
499500 }
500501
 502+ /**
 503+ * Helper function to display a simple button
 504+ */
 505+ static function buttonHTML($values) {
 506+ // for backwards-compatibility with pre-1.13 MW
 507+ $button_html = function_exists("Xml::element") ? Xml::element('input', $values, '') : wfElement('input', $values, '');
 508+ return " $button_html\n";
 509+ }
 510+
501511 static function saveButtonHTML($is_disabled, $label = null) {
502512 global $sfgTabIndex;
503513
@@ -514,8 +524,7 @@
515525 'title' => wfMsg('tooltip-save'),
516526 $disabled_text => '',
517527 );
518 - $text = " " . wfElement('input', $temp, '') . "\n";
519 - return $text;
 528+ return self::buttonHTML($temp);
520529 }
521530
522531 static function showPreviewButtonHTML($is_disabled, $label = null) {
@@ -535,8 +544,7 @@
536545 'title' => wfMsg('tooltip-preview'),
537546 $disabled_text => '',
538547 );
539 - $text = " " . wfElement('input', $temp, '') . "\n";
540 - return $text;
 548+ return self::buttonHTML($temp);
541549 }
542550
543551 static function showChangesButtonHTML($is_disabled, $label = null) {
@@ -556,8 +564,7 @@
557565 'title' => wfMsg('tooltip-diff'),
558566 $disabled_text => '',
559567 );
560 - $text = " " . wfElement('input', $temp, '') . "\n";
561 - return $text;
 568+ return self::buttonHTML($temp);
562569 }
563570
564571 static function cancelLinkHTML($is_disabled, $label = null) {
@@ -658,8 +665,7 @@
659666 'value' => $label,
660667 'title' => $label,
661668 );
662 - $text = " " . wfElement('input', $temp, '') . "\n";
663 - return $text;
 669+ return self::buttonHTML($temp);
664670 }
665671
666672 static function getMonthNames() {

Status & tagging log