r64756 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64755‎ | r64756 | r64757 >
Date:20:35, 8 April 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added support for MW 1.12, improved handling of 'disabled' attribute in inputs
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -448,6 +448,21 @@
449449 return $additional_template_text;
450450 }
451451
 452+ /**
 453+ * Helper function, for versions of MediaWiki that don't have
 454+ * Xml::expandAttributes (i.e., before 1.13)
 455+ */
 456+ static function expandAttributes( $attribs ) {
 457+ if ( method_exists( 'Xml', 'expandAttributes' ) ) {
 458+ return Xml::expandAttributes( $attribs );
 459+ } else {
 460+ $out = '';
 461+ foreach( $attribs as $name => $val )
 462+ $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
 463+ return $out;
 464+ }
 465+ }
 466+
452467 static function summaryInputHTML($is_disabled, $label = null, $attr = array()) {
453468 global $sfgTabIndex;
454469
@@ -455,7 +470,7 @@
456471 if ($label == null)
457472 $label = wfMsg('summary');
458473 $disabled_text = ($is_disabled) ? " disabled" : "";
459 - $attr = Xml::expandAttributes($attr);
 474+ $attr = self::expandAttributes($attr);
460475 $text =<<<END
461476 <span id='wpSummaryLabel'><label for='wpSummary'>$label</label></span>
462477 <input tabindex="$sfgTabIndex" type='text' value="" name='wpSummary' id='wpSummary' maxlength='200' size='60'$disabled_text$attr/>
@@ -473,7 +488,7 @@
474489 $label = wfMsgExt('minoredit', array('parseinline'));
475490 $accesskey = wfMsg('accesskey-minoredit');
476491 $tooltip = wfMsg('tooltip-minoredit');
477 - $attr = Xml::expandAttributes($attr);
 492+ $attr = self::expandAttributes($attr);
478493 $text =<<<END
479494 <input tabindex="$sfgTabIndex" type="checkbox" value="1" name="wpMinoredit" accesskey="$accesskey" id="wpMinoredit"$disabled_text$attr/>
480495 <label for="wpMinoredit" title="$tooltip">$label</label>
@@ -504,7 +519,7 @@
505520 $label = wfMsgExt('watchthis', array('parseinline'));
506521 $accesskey = htmlspecialchars(wfMsg('accesskey-watch'));
507522 $tooltip = htmlspecialchars(wfMsg('tooltip-watch'));
508 - $attr = Xml::expandAttributes($attr);
 523+ $attr = self::expandAttributes($attr);
509524 $text =<<<END
510525 <input tabindex="$sfgTabIndex" type="checkbox" name="wpWatchthis" accesskey="$accesskey" id='wpWatchthis'$checked_text$disabled_text$attr/>
511526 <label for="wpWatchthis" title="$tooltip">$label</label>
@@ -525,7 +540,6 @@
526541 global $sfgTabIndex;
527542
528543 $sfgTabIndex++;
529 - $disabled_text = ($is_disabled) ? "disabled" : "";
530544 if ($label == null)
531545 $label = wfMsg('savearticle');
532546 $temp = $attr + array(
@@ -536,8 +550,10 @@
537551 'value' => $label,
538552 'accesskey' => wfMsg('accesskey-save'),
539553 'title' => wfMsg('tooltip-save'),
540 - $disabled_text => '',
541554 );
 555+ if ( $is_disabled ) {
 556+ $temp['disabled'] = '';
 557+ }
542558 return self::buttonHTML($temp);
543559 }
544560
@@ -545,7 +561,6 @@
546562 global $sfgTabIndex;
547563
548564 $sfgTabIndex++;
549 - $disabled_text = ($is_disabled) ? "disabled" : "";
550565 if ($label == null)
551566 $label = wfMsg('showpreview');
552567 $temp = $attr + array(
@@ -556,8 +571,10 @@
557572 'value' => $label,
558573 'accesskey' => wfMsg('accesskey-preview'),
559574 'title' => wfMsg('tooltip-preview'),
560 - $disabled_text => '',
561575 );
 576+ if ( $is_disabled ) {
 577+ $temp['disabled'] = '';
 578+ }
562579 return self::buttonHTML($temp);
563580 }
564581
@@ -565,7 +582,6 @@
566583 global $sfgTabIndex;
567584
568585 $sfgTabIndex++;
569 - $disabled_text = ($is_disabled) ? "disabled" : "";
570586 if ($label == null)
571587 $label = wfMsg('showdiff');
572588 $temp = $attr + array(
@@ -576,8 +592,10 @@
577593 'value' => $label,
578594 'accesskey' => wfMsg('accesskey-diff'),
579595 'title' => wfMsg('tooltip-diff'),
580 - $disabled_text => '',
581596 );
 597+ if ( $is_disabled ) {
 598+ $temp['disabled'] = '';
 599+ }
582600 return self::buttonHTML($temp);
583601 }
584602
@@ -605,7 +623,6 @@
606624 global $sfgTabIndex;
607625
608626 $sfgTabIndex++;
609 - $disabled_text = ($is_disabled) ? "disabled" : "";
610627 if ($label == null)
611628 $label = wfMsg('runquery');
612629 return self::buttonHTML($attr + array(

Status & tagging log