Merge "Let wildcard actions work in list=logevents&leaction="
[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 ) + $this->getTooltipAndAccessKey();
15
16 if ( $this->mClass !== '' ) {
17 $attribs['class'] = $this->mClass;
18 }
19
20 # @todo Enforce pattern, step, required, readonly on the server side as
21 # well
22 $allowedParams = array(
23 'min',
24 'max',
25 'pattern',
26 'title',
27 'step',
28 'placeholder',
29 'list',
30 'maxlength',
31 'tabindex',
32 'disabled',
33 'required',
34 'autofocus',
35 'multiple',
36 'readonly'
37 );
38
39 $attribs += $this->getAttributes( $allowedParams );
40
41 # Implement tiny differences between some field variants
42 # here, rather than creating a new class for each one which
43 # is essentially just a clone of this one.
44 if ( isset( $this->mParams['type'] ) ) {
45 switch ( $this->mParams['type'] ) {
46 case 'email':
47 $attribs['type'] = 'email';
48 break;
49 case 'int':
50 $attribs['type'] = 'number';
51 break;
52 case 'float':
53 $attribs['type'] = 'number';
54 $attribs['step'] = 'any';
55 break;
56 # Pass through
57 case 'password':
58 case 'file':
59 $attribs['type'] = $this->mParams['type'];
60 break;
61 }
62 }
63
64 return Html::element( 'input', $attribs );
65 }
66 }