r85083 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85082‎ | r85083 | r85084 >
Date:20:04, 31 March 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for default of 'minor edit' setting ($wgDefaultUserOptions['minordefault']), removed some now-unnecessary globals (follow-up to r84980)
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -12,7 +12,7 @@
1313 static function setGlobalJSVariables( &$vars ) {
1414 global $sfgAutocompleteValues, $sfgAutocompleteOnAllChars;
1515 global $sfgInitJSFunctions, $sfgValidationJSFunctions;
16 - global $sfgShowOnSelect, $wgParser, $wgUser;
 16+ global $sfgShowOnSelect;
1717
1818 $vars['sfgRemoveText'] = wfMsg( 'sf_formedit_remove' );
1919 $vars['sfgAutocompleteOnAllChars'] = $sfgAutocompleteOnAllChars;
@@ -85,17 +85,15 @@
8686 return $text;
8787 }
8888
89 - static function minorEditInputHTML( $is_disabled, $label = null, $attr = array() ) {
90 - global $sfgTabIndex;
 89+ static function minorEditInputHTML( $is_disabled, $label = null, $attrs = array() ) {
 90+ global $sfgTabIndex, $wgUser;
9191
9292 $sfgTabIndex++;
 93+ $checked = $wgUser->getOption( 'minordefault' );
9394 if ( $label == null )
9495 $label = wfMsgExt( 'minoredit', array( 'parseinline' ) );
9596 $tooltip = wfMsg( 'tooltip-minoredit' );
96 - $attrs = $attr + array(
97 - 'type' => 'checkbox',
98 - 'value' => '',
99 - 'name' => 'wpMinoredit',
 97+ $attrs += array(
10098 'id' => 'wpMinoredit',
10199 'accesskey' => wfMsg( 'accesskey-minoredit' ),
102100 'tabindex' => $sfgTabIndex,
@@ -103,7 +101,7 @@
104102 if ( $is_disabled ) {
105103 $attrs['disabled'] = 'disabled';
106104 }
107 - $text = "\t" . Xml::element( 'input', $attrs ) . "\n";
 105+ $text = "\t" . Xml::check( 'wpMinoredit', $checked, $attrs ) . "\n";
108106 $text .= "\t" . Xml::element( 'label', array(
109107 'for' => 'wpMinoredit',
110108 'title' => $tooltip
@@ -112,34 +110,40 @@
113111 return $text;
114112 }
115113
116 - static function watchInputHTML( $is_disabled, $label = null, $attr = array() ) {
 114+ static function watchInputHTML( $is_disabled, $label = null, $attrs = array() ) {
117115 global $sfgTabIndex, $wgUser, $wgTitle;
118116
119117 $sfgTabIndex++;
120 - $checked_text = "";
121 - $disabled_text = ( $is_disabled ) ? " disabled" : "";
 118+ $checked = "";
122119 // figure out if the checkbox should be checked -
123120 // this code borrowed from /includes/EditPage.php
124121 if ( $wgUser->getOption( 'watchdefault' ) ) {
125122 # Watch all edits
126 - $checked_text = " checked";
 123+ $checked = true;
127124 } elseif ( $wgUser->getOption( 'watchcreations' ) && !$wgTitle->exists() ) {
128125 # Watch creations
129 - $checked_text = " checked";
 126+ $checked = true;
130127 } elseif ( $wgTitle->userIsWatching() ) {
131128 # Already watched
132 - $checked_text = " checked";
 129+ $checked = true;
133130 }
134131 if ( $label == null )
135132 $label = wfMsgExt( 'watchthis', array( 'parseinline' ) );
136 - $accesskey = htmlspecialchars( wfMsg( 'accesskey-watch' ) );
 133+ $attrs += array(
 134+ 'id' => 'wpWatchthis',
 135+ 'accesskey' => wfMsg( 'accesskey-watch' ),
 136+ 'tabindex' => $sfgTabIndex,
 137+ );
 138+ if ( $is_disabled ) {
 139+ $attrs['disabled'] = 'disabled';
 140+ }
 141+ $text = "\t" . Xml::check( 'wpWatchthis', $checked, $attrs ) . "\n";
137142 $tooltip = htmlspecialchars( wfMsg( 'tooltip-watch' ) );
138 - $attr = Xml::expandAttributes( $attr );
139 - $text = <<<END
140 - <input tabindex="$sfgTabIndex" type="checkbox" name="wpWatchthis" accesskey="$accesskey" id='wpWatchthis'$checked_text$disabled_text$attr/>
141 - <label for="wpWatchthis" title="$tooltip">$label</label>
 143+ $text .= "\t" . Xml::element( 'label', array(
 144+ 'for' => 'wpWatchthis',
 145+ 'title' => $tooltip
 146+ ), $label ) . "\n";
142147
143 -END;
144148 return $text;
145149 }
146150
@@ -176,8 +180,9 @@
177181
178182 $sfgTabIndex++;
179183
180 - if ( $label == null )
 184+ if ( $label == null ) {
181185 $label = wfMsg( 'sf_formedit_saveandcontinueediting' );
 186+ }
182187
183188 $temp = $attr + array(
184189 'id' => 'wpSaveAndContinue',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84980removing ridiculously complex message sanitizing and using an extension-local...foxtrott21:11, 29 March 2011