MediaWiki  1.23.15
HTMLSelectOrOtherField.php
Go to the documentation of this file.
1 <?php
2 
7  function __construct( $params ) {
8  parent::__construct( $params );
9  $this->getOptions();
10  if ( !in_array( 'other', $this->mOptions, true ) ) {
11  $msg =
12  isset( $params['other'] )
13  ? $params['other']
14  : wfMessage( 'htmlform-selectorother-other' )->text();
15  $this->mOptions[$msg] = 'other';
16  }
17 
18  }
19 
20  function getInputHTML( $value ) {
21  $valInSelect = false;
22 
23  if ( $value !== false ) {
24  $value = strval( $value );
25  $valInSelect = in_array(
27  );
28  }
29 
30  $selected = $valInSelect ? $value : 'other';
31 
32  $select = new XmlSelect( $this->mName, $this->mID, $selected );
33  $select->addOptions( $this->getOptions() );
34 
35  $select->setAttribute( 'class', 'mw-htmlform-select-or-other' );
36 
37  $tbAttribs = array( 'id' => $this->mID . '-other', 'size' => $this->getSize() );
38 
39  if ( !empty( $this->mParams['disabled'] ) ) {
40  $select->setAttribute( 'disabled', 'disabled' );
41  $tbAttribs['disabled'] = 'disabled';
42  }
43 
44  if ( isset( $this->mParams['tabindex'] ) ) {
45  $select->setAttribute( 'tabindex', $this->mParams['tabindex'] );
46  $tbAttribs['tabindex'] = $this->mParams['tabindex'];
47  }
48 
49  $select = $select->getHTML();
50 
51  if ( isset( $this->mParams['maxlength'] ) ) {
52  $tbAttribs['maxlength'] = $this->mParams['maxlength'];
53  }
54 
55  if ( $this->mClass !== '' ) {
56  $tbAttribs['class'] = $this->mClass;
57  }
58 
59  $textbox = Html::input( $this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs );
60 
61  return "$select<br />\n$textbox";
62  }
63 
70  if ( $request->getCheck( $this->mName ) ) {
71  $val = $request->getText( $this->mName );
72 
73  if ( $val === 'other' ) {
74  $val = $request->getText( $this->mName . '-other' );
75  }
76 
77  return $val;
78  } else {
79  return $this->getDefault();
80  }
81  }
82 }
HTMLFormField\getOptions
getOptions()
Fetch the array of options from the field's parameters.
Definition: HTMLFormField.php:550
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
Definition: hooks.txt:1961
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$params
$params
Definition: styleTest.css.php:40
HTMLSelectOrOtherField
Select dropdown field, with an additional "other" textbox.
Definition: HTMLSelectOrOtherField.php:6
HTMLFormField\$mClass
$mClass
Definition: HTMLFormField.php:15
HTMLTextField
Definition: HTMLTextField.php:3
XmlSelect
Definition: Xml.php:844
wfMessage
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 after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
HTMLSelectOrOtherField\loadDataFromRequest
loadDataFromRequest( $request)
Definition: HTMLSelectOrOtherField.php:69
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Html\input
static input( $name, $value='', $type='text', $attribs=array())
Convenience function to produce an "<input>" element.
Definition: Html.php:590
HTMLSelectOrOtherField\__construct
__construct( $params)
Initialise the object.
Definition: HTMLSelectOrOtherField.php:7
$value
$value
Definition: styleTest.css.php:45
HTMLFormField\getDefault
getDefault()
Definition: HTMLFormField.php:466
HTMLSelectOrOtherField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLSelectOrOtherField.php:20
HTMLFormField\flattenOptions
static flattenOptions( $options)
flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>...
Definition: HTMLFormField.php:601
HTMLTextField\getSize
getSize()
Definition: HTMLTextField.php:4