31 private $modifiedUser;
34 private $privateInfoEditable =
true;
37 private $optionsEditable =
true;
43 $this->modifiedUser = $user;
50 if ( $this->modifiedUser ===
null ) {
53 return $this->modifiedUser;
61 return $this->privateInfoEditable;
69 $this->privateInfoEditable = $editable;
77 return $this->optionsEditable;
84 $this->optionsEditable = $optionsEditable;
99 $html =
Xml::tags(
'div', [
'id' =>
'preferences' ], $html );
101 return parent::wrapForm( $html );
111 foreach ( $this->mFlatFields as $fieldname => $field ) {
113 $info = $field->mParams;
114 $prefix = $info[
'prefix'] ?? $fieldname;
115 foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
116 $data[
"$prefix$key"] = $value;
118 unset( $data[$fieldname] );
126 $layout = parent::wrapFieldSetSection( $legend, $section, $attributes, $isRoot );
128 $layout->addClasses( [
'mw-prefs-fieldset-wrapper' ] );
129 $layout->removeClasses( [
'oo-ui-panelLayout-framed' ] );
140 $skin = $out->getSkin();
141 $this->getHookRunner()->onPreferencesGetLayout( $useMobileLayout,
142 $skin->getSkinName(), [
'isResponsive' => $skin->isResponsive() ] );
144 if ( $useMobileLayout ) {
146 $out->addModuleStyles(
148 'oojs-ui.styles.icons-user',
149 'oojs-ui.styles.icons-editing-core',
150 'oojs-ui.styles.icons-editing-advanced',
151 'oojs-ui.styles.icons-wikimediaui',
152 'oojs-ui.styles.icons-content',
153 'oojs-ui.styles.icons-moderation',
154 'oojs-ui.styles.icons-interactions',
155 'oojs-ui.styles.icons-movement',
156 'oojs-ui.styles.icons-wikimedia',
157 'oojs-ui.styles.icons-media',
158 'oojs-ui.styles.icons-accessibility',
159 'oojs-ui.styles.icons-layout',
162 $form = $this->createMobilePreferencesForm();
164 $form = $this->createDesktopPreferencesForm();
179 $legend = parent::getLegend( $key );
180 $this->getHookRunner()->onPreferencesGetLegend( $this, $key, $legend );
189 return array_keys( array_filter( $this->mFieldTree,
'is_array' ) );
196 private function createMobilePreferencesForm() {
199 'personal' =>
'userAvatar',
200 'rendering' =>
'palette',
202 'rc' =>
'recentChanges',
203 'watchlist' =>
'watchlist',
204 'searchoptions' =>
'search',
209 $this->getHookRunner()->onPreferencesGetIcon( $hookIcons );
210 $iconNames += $hookIcons;
212 foreach ( $this->mFieldTree as $key => $val ) {
213 if ( !is_array( $val ) ) {
214 wfDebug( __METHOD__ .
" encountered a field not attached to a section: '$key'" );
223 "mw-prefsection-$key-"
227 $prefPanel =
new OOUI\PanelLayout( [
232 'mw-mobile-prefsection',
233 'mw-prefs-section-fieldset',
235 'tagName' =>
'fieldset',
238 $iconHeaderDiv = (
new OOUI\Tag(
'div' ) )
239 ->addClasses( [
'mw-prefs-header-container' ] );
240 $iconExists = array_key_exists( $key, $iconNames );
242 $iconName = $iconNames[ $key ];
244 $iconName =
"settings";
246 $spanIcon =
new OOUI\IconWidget( [
250 'classes' => [
'mw-prefs-icon' ],
252 $prefTitle = (
new OOUI\Tag(
'h5' ) )->appendContent( $label )->addClasses( [
'prefs-title' ] );
253 $iconHeaderDiv->appendContent( $spanIcon );
254 $iconHeaderDiv->appendContent( $prefTitle );
255 $prefPanel->appendContent( $iconHeaderDiv );
256 $prefDescriptionMsg = $this->
msg(
"prefs-description-" . $key );
257 $prefDescription = $prefDescriptionMsg->exists() ? $prefDescriptionMsg->text() :
"";
258 $prefPanel->appendContent( (
new OOUI\Tag(
'p' ) )
259 ->appendContent( $prefDescription )
260 ->addClasses( [
'mw-prefs-description' ] )
262 $contentDiv = (
new OOUI\Tag(
'div' ) );
263 $contentDiv->addClasses( [
'mw-prefs-content-page' ] );
264 $contentDiv->setAttributes( [
265 'id' =>
'mw-mobile-prefs-' . $key .
'-content'
267 $contentHeader = (
new OOUI\Tag(
'div' ) )->setAttributes( [
268 'id' =>
'mw-mobile-prefs-' . $key .
'-head'
270 $contentHeader->addClasses( [
'mw-prefs-content-head' ] );
271 $contentHeaderTitle = (
new OOUI\Tag(
'h5' ) )->setAttributes( [
272 'id' =>
'mw-mobile-prefs-' . $key .
'-title',
274 $contentHeaderTitle->appendContent( $label )->addClasses( [
'mw-prefs-header-title' ] );
275 $formContent =
new OOUI\Widget( [
276 'content' =>
new OOUI\HtmlSnippet(
$content )
278 $hiddenForm = (
new OOUI\Tag(
'div' ) )->appendContent( $formContent );
279 $contentHeader->appendContent( $contentHeaderTitle );
280 $contentDiv->appendContent( $contentHeader );
281 $contentDiv->appendContent( $hiddenForm );
282 $prefPanel->appendContent( $contentDiv );
283 $prefPanel->setAttributes( [
284 'id' =>
'mw-mobile-prefs-' . $key,
286 $prefPanel->setInfusable(
true );
287 $prefPanels[] = $prefPanel;
290 $form =
new OOUI\StackLayout( [
291 'items' => $prefPanels,
292 'continuous' =>
true,
294 'classes' => [
'mw-mobile-preferences-container' ]
296 $form->setAttributes( [
297 'id' =>
'mw-prefs-container',
299 $form->setInfusable(
true );
308 private function createDesktopPreferencesForm() {
310 foreach ( $this->mFieldTree as $key => $val ) {
311 if ( !is_array( $val ) ) {
312 wfDebug( __METHOD__ .
" encountered a field not attached to a section: '$key'" );
321 "mw-prefsection-$key-"
325 $tabPanels[] =
new OOUI\TabPanelLayout(
'mw-prefsection-' . $key, [
326 'classes' => [
'mw-htmlform-autoinfuse-lazy' ],
328 'content' =>
new OOUI\FieldsetLayout( [
329 'classes' => [
'mw-prefs-section-fieldset' ],
330 'id' =>
"mw-prefsection-$key",
334 'content' =>
new OOUI\HtmlSnippet(
$content )
343 $indexLayout =
new OOUI\IndexLayout( [
346 'autoFocus' =>
false,
347 'classes' => [
'mw-prefs-tabs' ],
349 $indexLayout->addTabPanels( $tabPanels );
351 $form =
new OOUI\PanelLayout( [
354 'classes' => [
'mw-prefs-tabs-wrapper' ],
355 'content' => $indexLayout
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.