MediaWiki REL1_33
PreferencesFormOOUI.php
Go to the documentation of this file.
1<?php
27 // Override default value from HTMLForm
28 protected $mSubSectionBeforeFields = false;
29
31
35 public function setModifiedUser( $user ) {
36 $this->modifiedUser = $user;
37 }
38
42 public function getModifiedUser() {
43 if ( $this->modifiedUser === null ) {
44 return $this->getUser();
45 } else {
47 }
48 }
49
57 return [];
58 }
59
64 function wrapForm( $html ) {
65 $html = Xml::tags( 'div', [ 'id' => 'preferences' ], $html );
66
67 return parent::wrapForm( $html );
68 }
69
73 function getButtons() {
74 if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
75 return '';
76 }
77
78 $html = parent::getButtons();
79
80 if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) {
81 $t = $this->getTitle()->getSubpage( 'reset' );
82
83 $html .= new OOUI\ButtonWidget( [
84 'infusable' => true,
85 'id' => 'mw-prefs-restoreprefs',
86 'label' => $this->msg( 'restoreprefs' )->text(),
87 'href' => $t->getLinkURL(),
88 'flags' => [ 'destructive' ],
89 'framed' => false,
90 ] );
91
92 $html = Xml::tags( 'div', [ 'class' => 'mw-prefs-buttons' ], $html );
93 }
94
95 return $html;
96 }
97
105 foreach ( $this->mFlatFields as $fieldname => $field ) {
106 if ( $field instanceof HTMLNestedFilterable ) {
107 $info = $field->mParams;
108 $prefix = $info['prefix'] ?? $fieldname;
109 foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
110 $data["$prefix$key"] = $value;
111 }
112 unset( $data[$fieldname] );
113 }
114 }
115
116 return $data;
117 }
118
119 protected function wrapFieldSetSection( $legend, $section, $attributes, $isRoot ) {
120 $layout = parent::wrapFieldSetSection( $legend, $section, $attributes, $isRoot );
121
122 $layout->addClasses( [ 'mw-prefs-fieldset-wrapper' ] );
123 $layout->removeClasses( [ 'oo-ui-panelLayout-framed' ] );
124
125 return $layout;
126 }
127
132 function getBody() {
133 $tabPanels = [];
134 foreach ( $this->mFieldTree as $key => $val ) {
135 if ( !is_array( $val ) ) {
136 wfDebug( __METHOD__ . " encountered a field not attached to a section: '$key'" );
137 continue;
138 }
139 $label = $this->getLegend( $key );
140 $content =
141 $this->getHeaderText( $key ) .
142 $this->displaySection(
143 $this->mFieldTree[$key],
144 "",
145 "mw-prefsection-$key-"
146 ) .
147 $this->getFooterText( $key );
148
149 $tabPanels[] = new OOUI\TabPanelLayout( [
150 'classes' => [ 'mw-htmlform-autoinfuse-lazy' ],
151 'name' => 'mw-prefsection-' . $key,
152 'label' => $label,
153 'content' => new OOUI\FieldsetLayout( [
154 'classes' => [ 'mw-prefs-section-fieldset' ],
155 'id' => "mw-prefsection-$key",
156 'label' => $label,
157 'items' => [
158 new OOUI\Widget( [
159 'content' => new OOUI\HtmlSnippet( $content )
160 ] ),
161 ],
162 ] ),
163 'expanded' => false,
164 'framed' => true,
165 ] );
166 }
167
168 $indexLayout = new OOUI\IndexLayout( [
169 'infusable' => true,
170 'expanded' => false,
171 'autoFocus' => false,
172 'classes' => [ 'mw-prefs-tabs' ],
173 ] );
174 $indexLayout->addTabPanels( $tabPanels );
175
176 return new OOUI\PanelLayout( [
177 'framed' => true,
178 'expanded' => false,
179 'classes' => [ 'mw-prefs-tabs-wrapper' ],
180 'content' => $indexLayout
181 ] );
182 }
183
190 function getLegend( $key ) {
191 $legend = parent::getLegend( $key );
192 Hooks::run( 'PreferencesGetLegend', [ $this, $key, &$legend ] );
193 return $legend;
194 }
195
201 return array_keys( array_filter( $this->mFieldTree, 'is_array' ) );
202 }
203}
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getFooterText( $section=null)
Get footer text.
Definition HTMLForm.php:866
getTitle()
Get the title.
displaySection( $fields, $sectionName='', $fieldsetIDPrefix='', &$hasUserVisibleFields=false)
Compact stacked vertical format for forms, implemented using OOUI widgets.
getHeaderText( $section=null)
Get header text.
Form to edit user preferences.
filterDataForSubmit( $data)
Separate multi-option preferences into multiple preferences, since we have to store them separately.
getPreferenceSections()
Get the keys of each top level preference section.
getBody()
Get the whole body of the form.
getLegend( $key)
Get the "<legend>" for a given section key.
wrapFieldSetSection( $legend, $section, $attributes, $isRoot)
@inheritDoc
getExtraSuccessRedirectParameters()
Get extra parameters for the query string when redirecting after successful save.
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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
Definition hooks.txt:2011
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:3070
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
$content