interface will not appear in Special:AllMessages.
* $wgRegisterInternalExternals can be used to record external links pointing
to same server
-* $wgHtml5 outputs an HTML 5 doctype instead of XHTML 1.0 Transitional.
* $wgSpecialVersionExtended shows the extended version information besides
PHP and database version.
* $wgSecondaryGoNamespaces allows an arry of namespaces to be checked when the
* wgMainPageTitle variable now available to JavaScript code to identify the main
page link, so it doesn't have to be extracted from the link URLs.
* (bug 16836) Display preview of signature in user preferences and describe its use
+* The default output format is now HTML 5 instead of XHTML 1.0 Transitional.
+ This can be disabled by setting $wgHtml5 = false;. Specific features enabled
+ if HTML 5 is used:
+** New HTML 5 input attributes allow JavaScript-free input validation in some
+ cutting-edge browsers. E.g., some inputs will be autofocused, users will
+ not be allowed to submit forms with certain types of invalid values (like
+ numbers outside the permitted ranges), etc.
=== Bug fixes in 1.16 ===
'float' => 'HTMLFloatField',
'info' => 'HTMLInfoField',
'selectorother' => 'HTMLSelectOrOtherField',
+ # HTMLTextField will output the correct type="" attribute automagically.
+ # There are about four zillion other HTML 5 input types, like url, but
+ # we don't use those at the moment, so no point in adding all of them.
+ 'email' => 'HTMLTextField',
);
function __construct( $descriptor, $messagePrefix ) {
}
class HTMLTextField extends HTMLFormField {
-
function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
}
function getInputHTML( $value ) {
+ global $wgHtml5;
$attribs = array( 'id' => $this->mID );
if ( isset( $this->mParams['maxlength'] ) ) {
$attribs['maxlength'] = $this->mParams['maxlength'];
}
- if( !empty( $this->mParams['disabled'] ) ) {
+ if ( !empty( $this->mParams['disabled'] ) ) {
$attribs['disabled'] = 'disabled';
}
+ if ( $wgHtml5 ) {
+ # TODO: Enforce pattern, step, required, readonly on the server
+ # side as well
+ foreach ( array( 'min', 'max', 'pattern', 'title', 'step',
+ 'placeholder' ) as $param ) {
+ if ( isset( $this->mParams[$param] ) ) {
+ $attribs[$param] = $this->mParams[$param];
+ }
+ }
+ foreach ( array( 'required', 'autofocus', 'multiple', 'readonly' )
+ as $param ) {
+ if ( isset( $this->mParams[$param] ) ) {
+ $attribs[$param] = '';
+ }
+ }
+ if ( isset( $this->mParams['type'] ) ) {
+ switch ( $this->mParams['type'] ) {
+ case 'email':
+ $attribs['type'] = 'email';
+ break;
+ case 'int':
+ $attribs['type'] = 'number';
+ break;
+ case 'float':
+ $attribs['type'] = 'number';
+ $attribs['step'] = 'any';
+ break;
+ }
+ }
+ }
+
return Xml::input(
$this->mName,
$this->getSize(),
$attribs
);
}
-
}
class HTMLFloatField extends HTMLTextField {
$defaultPreferences['emailaddress'] =
array(
- 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'text' : 'info',
+ 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'email' : 'info',
'default' => $user->getEmail(),
'section' => 'personal/email',
'label-message' => 'youremail',
}
function pretty( $fields ) {
+ global $wgHtml5;
$out = '';
foreach( $fields as $list ) {
list( $name, $label, $type, $value ) = $list;
if( $type == 'text' ) {
$field = htmlspecialchars( $value );
} else {
+ $attribs = array( 'id' => $name, 'type' => $type );
+ if ( $wgHtml5 ) {
+ # All three fields are required, and we should focus the
+ # first (wpPassword)
+ $attribs['required'] = '';
+ if ( $name == 'wpPassword' ) {
+ $attribs['autofocus'] = '';
+ }
+ }
$field = Xml::input( $name, 20, $value,
- array( 'id' => $name, 'type' => $type ) );
+ $attribs );
}
$out .= '<tr>';
$out .= "<td class='mw-label'>";
*/
class UserloginTemplate extends QuickTemplate {
function execute() {
+ global $wgHtml5;
+
if( $this->data['message'] ) {
?>
<div class="<?php $this->text('messagetype') ?>box">
<td class="mw-input">
<input type='text' class='loginText' name="wpName" id="wpName1"
tabindex="1"
- value="<?php $this->text('name') ?>" size='20' />
+ value="<?php $this->text('name'); ?>" size='20'<?php
+if ( $wgHtml5 ) {
+ echo ' required="" autofocus=""';
+}
+?>" />
</td>
</tr>
<tr>
}
function execute() {
+ global $wgHtml5, $wgMinimalPasswordLength;
+
if( $this->data['message'] ) {
?>
<div class="<?php $this->text('messagetype') ?>box">
<td class="mw-input">
<input type='text' class='loginText' name="wpName" id="wpName2"
tabindex="1"
- value="<?php $this->text('name') ?>" size='20' />
+ value="<?php $this->text('name') ?>" size='20'<?php
+if ( $wgHtml5 ) {
+ echo ' required=""';
+}
+?> />
</td>
</tr>
<tr>
<td class="mw-input">
<input type='password' class='loginPassword' name="wpPassword" id="wpPassword2"
tabindex="2"
- value="" size='20' />
+ value="" size='20'<?php
+if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
+ echo ' required=""';
+}
+?> />
</td>
</tr>
<?php if( $this->data['usedomain'] ) {
<input type='password' class='loginPassword' name="wpRetype" id="wpRetype"
tabindex="4"
value=""
- size='20' />
+ size='20'<?php
+if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
+ echo ' required=""';
+}
+?> />
</td>
</tr>
<tr>
<?php if( $this->data['useemail'] ) { ?>
<td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
<td class="mw-input">
- <input type='text' class='loginText' name="wpEmail" id="wpEmail"
+ <input type='<?php echo $wgHtml5 ? 'email' : 'text' ?>' class='loginText' name="wpEmail" id="wpEmail"
tabindex="5"
value="<?php $this->text('email') ?>" size='20' />
<div class="prefsectiontip">