MediaWiki REL1_28
HTMLTextAreaField.php
Go to the documentation of this file.
1<?php
2
4 const DEFAULT_COLS = 80;
5 const DEFAULT_ROWS = 25;
6
7 protected $mPlaceholder = '';
8
15 public function __construct( $params ) {
16 parent::__construct( $params );
17
18 if ( isset( $params['placeholder-message'] ) ) {
19 $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->parse();
20 } elseif ( isset( $params['placeholder'] ) ) {
21 $this->mPlaceholder = $params['placeholder'];
22 }
23 }
24
25 function getCols() {
26 return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
27 }
28
29 function getRows() {
30 return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
31 }
32
33 function getSpellCheck() {
34 $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
35 if ( is_bool( $val ) ) {
36 // "spellcheck" attribute literally requires "true" or "false" to work.
37 return $val === true ? 'true' : 'false';
38 }
39 return null;
40 }
41
42 function getInputHTML( $value ) {
43 $attribs = [
44 'id' => $this->mID,
45 'cols' => $this->getCols(),
46 'rows' => $this->getRows(),
47 'spellcheck' => $this->getSpellCheck(),
48 ] + $this->getTooltipAndAccessKey();
49
50 if ( $this->mClass !== '' ) {
51 $attribs['class'] = $this->mClass;
52 }
53 if ( $this->mPlaceholder !== '' ) {
54 $attribs['placeholder'] = $this->mPlaceholder;
55 }
56
57 $allowedParams = [
58 'tabindex',
59 'disabled',
60 'readonly',
61 'required',
62 'autofocus'
63 ];
64
65 $attribs += $this->getAttributes( $allowedParams );
66 return Html::textarea( $this->mName, $value, $attribs );
67 }
68
69 function getInputOOUI( $value ) {
70 if ( isset( $this->mParams['cols'] ) ) {
71 throw new Exception( "OOUIHTMLForm does not support the 'cols' parameter for textareas" );
72 }
73
75
76 if ( $this->mClass !== '' ) {
77 $attribs['classes'] = [ $this->mClass ];
78 }
79 if ( $this->mPlaceholder !== '' ) {
80 $attribs['placeholder'] = $this->mPlaceholder;
81 }
82
83 $allowedParams = [
84 'tabindex',
85 'disabled',
86 'readonly',
87 'required',
88 'autofocus',
89 ];
90
91 $attribs += OOUI\Element::configFromHtmlAttributes(
92 $this->getAttributes( $allowedParams )
93 );
94
95 return new OOUI\TextInputWidget( [
96 'id' => $this->mID,
97 'name' => $this->mName,
98 'multiline' => true,
99 'value' => $value,
100 'rows' => $this->getRows(),
101 ] + $attribs );
102 }
103}
The parent class to generate form fields.
getMessage( $value)
Turns a *-message parameter (which could be a MessageSpecifier, or a message name,...
getAttributes(array $list)
Returns the given attributes from the parameters.
getTooltipAndAccessKey()
Returns the attributes required for the tooltip and accesskey.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:1958
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
$params