Move up devunt's name to Developers
[lhc/web/wiklou.git] / includes / htmlform / HTMLTextField.php
1 <?php
2
3 class HTMLTextField extends HTMLFormField {
4 function getSize() {
5 return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
6 }
7
8 function getInputHTML( $value ) {
9 $attribs = array(
10 'id' => $this->mID,
11 'name' => $this->mName,
12 'size' => $this->getSize(),
13 'value' => $value,
14 'dir' => $this->mDir,
15 ) + $this->getTooltipAndAccessKey();
16
17 if ( $this->mClass !== '' ) {
18 $attribs['class'] = $this->mClass;
19 }
20
21 # @todo Enforce pattern, step, required, readonly on the server side as
22 # well
23 $allowedParams = array(
24 'type',
25 'min',
26 'max',
27 'pattern',
28 'title',
29 'step',
30 'placeholder',
31 'list',
32 'maxlength',
33 'tabindex',
34 'disabled',
35 'required',
36 'autofocus',
37 'multiple',
38 'readonly'
39 );
40
41 $attribs += $this->getAttributes( $allowedParams );
42
43 # Extract 'type'
44 $type = isset( $attribs['type'] ) ? $attribs['type'] : 'text';
45 unset( $attribs['type'] );
46
47 # Implement tiny differences between some field variants
48 # here, rather than creating a new class for each one which
49 # is essentially just a clone of this one.
50 if ( isset( $this->mParams['type'] ) ) {
51 switch ( $this->mParams['type'] ) {
52 case 'int':
53 $type = 'number';
54 break;
55 case 'float':
56 $type = 'number';
57 $attribs['step'] = 'any';
58 break;
59 # Pass through
60 case 'email':
61 case 'password':
62 case 'file':
63 case 'url':
64 $type = $this->mParams['type'];
65 break;
66 }
67 }
68
69 return Html::input( $this->mName, $value, $type, $attribs );
70 }
71 }