http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98060

Revision: 98060
Author:   yaron
Date:     2011-09-25 07:52:21 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
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
    
trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
    trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php
    
trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php

Modified: 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
===================================================================
--- trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php     
2011-09-25 07:46:12 UTC (rev 98059)
+++ trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php     
2011-09-25 07:52:21 UTC (rev 98060)
@@ -6,10 +6,6 @@
  * @ingroup SF
  */
 
-if ( !defined( 'SF_VERSION' ) ) {
-       die( 'This file is part of the SemanticForms extension, it is not a 
valid entry point.' );
-}
-
 /**
  * The SFTextAreaInput class.
  *
@@ -82,6 +78,10 @@
                        $textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
                        $textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
                }
+               if ( array_key_exists( 'placeholder', $other_args ) ) {
+                       $textarea_attrs['placeholder'] = 
$other_args['placeholder'];
+               }
+
                // Bug in Xml::element()? It doesn't close the textarea tag
                // properly if the text inside is null - set it to '' instead.
                if ( is_null( $cur_value ) ) {
@@ -119,6 +119,11 @@
                        'description' => wfMsg( 'sf_forminputs_maxlength' )
                );
                $params[] = array(
+                       'name' => 'placeholder',
+                       'type' => 'string',
+                       'description' => wfMsg( 'sf_forminputs_placeholder' )
+               );
+               $params[] = array(
                        'name' => 'autogrow',
                        'type' => 'boolean',
                        'description' => wfMsg( 'sf_forminputs_autogrow' )

Modified: 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
===================================================================
--- 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
     2011-09-25 07:46:12 UTC (rev 98059)
+++ 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
     2011-09-25 07:52:21 UTC (rev 98060)
@@ -6,10 +6,6 @@
  * @ingroup SF
  */
 
-if ( !defined( 'SF_VERSION' ) ) {
-       die( 'This file is part of the SemanticForms extension, it is not a 
valid entry point.' );
-}
-
 /**
  * The SFTextAreaWithAutocompleteInput class.
  *
@@ -94,6 +90,10 @@
                        $textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
                        $textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
                }
+               if ( array_key_exists( 'placeholder', $other_args ) ) {
+                       $textarea_attrs = $other_args['placeholder'];
+               }
+
                // Bug in Xml::element()? It doesn't close the textarea tag
                // properly if the text inside is null - set it to '' instead.
                if ( is_null( $cur_value ) ) {

Modified: trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php
===================================================================
--- trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php 
2011-09-25 07:46:12 UTC (rev 98059)
+++ trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php 
2011-09-25 07:52:21 UTC (rev 98060)
@@ -6,10 +6,6 @@
  * @ingroup SF
  */
 
-if ( !defined( 'SF_VERSION' ) ) {
-       die( 'This file is part of the SemanticForms extension, it is not a 
valid entry point.' );
-}
-
 /**
  * The SFTextInput class.
  *
@@ -126,6 +122,9 @@
                if ( array_key_exists( 'maxlength', $other_args ) ) {
                        $inputAttrs['maxlength'] = $other_args['maxlength'];
                }
+               if ( array_key_exists( 'placeholder', $other_args ) ) {
+                       $inputAttrs['placeholder'] = $other_args['placeholder'];
+               }
                $text = Xml::element( 'input', $inputAttrs );
 
                if ( array_key_exists( 'is_uploadable', $other_args ) && 
$other_args['is_uploadable'] == true ) {
@@ -169,6 +168,11 @@
                        'description' => wfMsg( 'sf_forminputs_maxlength' )
                );
                $params[] = array(
+                       'name' => 'placeholder',
+                       'type' => 'string',
+                       'description' => wfMsg( 'sf_forminputs_placeholder' )
+               );
+               $params[] = array(
                        'name' => 'uploadable',
                        'type' => 'boolean',
                        'description' => wfMsg( 'sf_forminputs_uploadable' )

Modified: 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php
===================================================================
--- 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php
 2011-09-25 07:46:12 UTC (rev 98059)
+++ 
trunk/extensions/SemanticForms/includes/forminputs/SF_TextWithAutocompleteInput.php
 2011-09-25 07:52:21 UTC (rev 98060)
@@ -6,10 +6,6 @@
  * @ingroup SF
  */
 
-if ( !defined( 'SF_VERSION' ) ) {
-       die( 'This file is part of the SemanticForms extension, it is not a 
valid entry point.' );
-}
-
 /**
  * The SFTextWithAutocompleteInput class.
  *
@@ -177,6 +173,9 @@
                if ( array_key_exists( 'maxlength', $other_args ) ) {
                        $inputAttrs['maxlength'] = $other_args['maxlength'];
                }
+               if ( array_key_exists( 'placeholder', $other_args ) ) {
+                       $inputAttrs['placeholder'] = $other_args['placeholder'];
+               }
                $text = "\n\t" . Xml::element( 'input', $inputAttrs ) . "\n";
 
                if ( array_key_exists( 'is_uploadable', $other_args ) && 
$other_args['is_uploadable'] == true ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to