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
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
$content