r98060 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98059‎ | r98060 | r98061 >
Date:07:52, 25 September 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for "placeholder=" HTML5 attribute using the new "placeholder" parameter, based in part on patch from LY Meng. Also removed unnecessary "valid entry point" check.
Modified paths:
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php
@@ -6,10 +6,6 @@
77 * @ingroup SF
88 */
99
10 -if ( !defined( 'SF_VERSION' ) ) {
11 - die( 'This file is part of the SemanticForms extension, it is not a valid entry point.' );
12 -}
13 -
1410 /**
1511 * The SFTextInput class.
1612 *
@@ -126,6 +122,9 @@
127123 if ( array_key_exists( 'maxlength', $other_args ) ) {
128124 $inputAttrs['maxlength'] = $other_args['maxlength'];
129125 }
 126+ if ( array_key_exists( 'placeholder', $other_args ) ) {
 127+ $inputAttrs['placeholder'] = $other_args['placeholder'];
 128+ }
130129 $text = Xml::element( 'input', $inputAttrs );
131130
132131 if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) {
@@ -169,6 +168,11 @@
170169 'description' => wfMsg( 'sf_forminputs_maxlength' )
171170 );
172171 $params[] = array(
 172+ 'name' => 'placeholder',
 173+ 'type' => 'string',
 174+ 'description' => wfMsg( 'sf_forminputs_placeholder' )
 175+ );
 176+ $params[] = array(
173177 'name' => 'uploadable',
174178 'type' => 'boolean',
175179 'description' => wfMsg( 'sf_forminputs_uploadable' )
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
@@ -6,10 +6,6 @@
77 * @ingroup SF
88 */
99
10 -if ( !defined( 'SF_VERSION' ) ) {
11 - die( 'This file is part of the SemanticForms extension, it is not a valid entry point.' );
12 -}
13 -
1410 /**
1511 * The SFTextAreaWithAutocompleteInput class.
1612 *
@@ -94,6 +90,10 @@
9591 $textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
9692 $textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
9793 }
 94+ if ( array_key_exists( 'placeholder', $other_args ) ) {
 95+ $textarea_attrs = $other_args['placeholder'];
 96+ }
 97+
9898 // Bug in Xml::element()? It doesn't close the textarea tag
9999 // properly if the text inside is null - set it to '' instead.
100100 if ( is_null( $cur_value ) ) {
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php
@@ -6,10 +6,6 @@
77 * @ingroup SF
88 */
99
10 -if ( !defined( 'SF_VERSION' ) ) {
11 - die( 'This file is part of the SemanticForms extension, it is not a valid entry point.' );
12 -}
13 -
1410 /**
1511 * The SFTextWithAutocompleteInput class.
1612 *
@@ -177,6 +173,9 @@
178174 if ( array_key_exists( 'maxlength', $other_args ) ) {
179175 $inputAttrs['maxlength'] = $other_args['maxlength'];
180176 }
 177+ if ( array_key_exists( 'placeholder', $other_args ) ) {
 178+ $inputAttrs['placeholder'] = $other_args['placeholder'];
 179+ }
181180 $text = "\n\t" . Xml::element( 'input', $inputAttrs ) . "\n";
182181
183182 if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) {
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
@@ -6,10 +6,6 @@
77 * @ingroup SF
88 */
99
10 -if ( !defined( 'SF_VERSION' ) ) {
11 - die( 'This file is part of the SemanticForms extension, it is not a valid entry point.' );
12 -}
13 -
1410 /**
1511 * The SFTextAreaInput class.
1612 *
@@ -82,6 +78,10 @@
8379 $textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
8480 $textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
8581 }
 82+ if ( array_key_exists( 'placeholder', $other_args ) ) {
 83+ $textarea_attrs['placeholder'] = $other_args['placeholder'];
 84+ }
 85+
8686 // Bug in Xml::element()? It doesn't close the textarea tag
8787 // properly if the text inside is null - set it to '' instead.
8888 if ( is_null( $cur_value ) ) {
@@ -119,6 +119,11 @@
120120 'description' => wfMsg( 'sf_forminputs_maxlength' )
121121 );
122122 $params[] = array(
 123+ 'name' => 'placeholder',
 124+ 'type' => 'string',
 125+ 'description' => wfMsg( 'sf_forminputs_placeholder' )
 126+ );
 127+ $params[] = array(
123128 'name' => 'autogrow',
124129 'type' => 'boolean',
125130 'description' => wfMsg( 'sf_forminputs_autogrow' )