Go to the documentation of this file.
21 if ( isset( $this->mParams[
'disabled-options'] ) ===
false ) {
22 $this->mParams[
'disabled-options'] = [];
25 if ( isset(
$params[
'dropdown'] ) ) {
26 $this->mClass .=
' mw-htmlform-dropdown';
29 if ( isset(
$params[
'flatlist'] ) ) {
30 $this->mClass .=
' mw-htmlform-flatlist';
35 $p = parent::validate(
$value, $alldata );
41 if ( !is_array(
$value ) ) {
45 # If all options are valid, array_intersect of the valid options
46 # and the provided options will return the provided options.
49 $validValues = array_intersect(
$value, $validOptions );
53 return $this->
msg(
'htmlform-select-badoption' );
58 if ( isset( $this->mParams[
'dropdown'] ) ) {
59 $this->mParent->getOutput()->addModules(
'jquery.chosen' );
74 if ( is_array( $info ) ) {
79 'id' =>
"{$this->mID}-$info",
82 if ( in_array( $info, $this->mParams[
'disabled-options'],
true ) ) {
83 $thisAttribs[
'disabled'] =
'disabled';
85 $checked = in_array( $info,
$value,
true );
91 [
'class' =>
'mw-htmlform-flatlist-item' ],
102 throw new MWException(
'HTMLMultiSelectField#getOneCheckbox() is not supported' );
104 $elementFunc = [
Html::class, $this->mOptionsLabelsNotFromMessage ?
'rawElement' :
'element' ];
108 call_user_func( $elementFunc,
113 if ( $this->mParent->getConfig()->get(
'UseMediaWikiUIEverywhere' ) ) {
128 throw new MWException(
'HTMLMultiSelectField#getOptionsOOUI() is not supported' );
142 $this->mParent->getOutput()->addModules(
'oojs-ui-widgets' );
144 $hasSections =
false;
145 $optionsOouiSections = [];
159 $optionsOouiSections = array_merge(
166 foreach ( $optionsOouiSections
as $sectionLabel => $optionsOoui ) {
168 $attr[
'name'] =
"{$this->mName}[]";
171 $attr[
'options'] = $optionsOoui;
173 foreach ( $attr[
'options']
as &$option ) {
174 $option[
'disabled'] = in_array( $option[
'data'], $this->mParams[
'disabled-options'],
true );
176 if ( $this->mOptionsLabelsNotFromMessage ) {
177 foreach ( $attr[
'options']
as &$option ) {
178 $option[
'label'] =
new OOUI\HtmlSnippet( $option[
'label'] );
182 $attr += OOUI\Element::configFromHtmlAttributes(
186 if ( $this->mClass !==
'' ) {
190 $widget =
new OOUI\CheckboxMultiselectInputWidget( $attr );
191 if ( $sectionLabel ) {
192 $out[] =
new OOUI\FieldsetLayout( [
193 'items' => [ $widget ],
194 'label' =>
new OOUI\HtmlSnippet( $sectionLabel ),
201 if ( !$hasSections ) {
207 return implode(
'',
$out );
216 $fromRequest =
$request->getArray( $this->mName, [] );
231 if ( isset( $this->mDefault ) ) {
244 $res[
"$opt"] = in_array(
$opt, $data,
true );
loadDataFromRequest( $request)
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
getInputOOUI( $value)
Get the OOUI version of this field.
static listDropDownOptionsOoui( $options)
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc.
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
filterDataForSubmit( $data)
Support for separating multi-option preferences into multiple preferences Due to lack of array suppor...
static closeElement( $element)
Returns "</$element>".
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
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 & $html
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
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 & $options
getOneCheckbox( $checked, $attribs, $label)
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
formatOptions( $options, $value)
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out