MediaWiki REL1_31
PreferencesForm.php
Go to the documentation of this file.
1<?php
22
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 {
46 return $this->modifiedUser;
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 $attrs = [ 'id' => 'mw-prefs-restoreprefs' ];
75
76 if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
77 return '';
78 }
79
80 $html = parent::getButtons();
81
82 if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) {
83 $t = $this->getTitle()->getSubpage( 'reset' );
84
85 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
86 $html .= "\n" . $linkRenderer->makeLink( $t, $this->msg( 'restoreprefs' )->text(),
87 Html::buttonAttributes( $attrs, [ 'mw-ui-quiet' ] ) );
88
89 $html = Xml::tags( 'div', [ 'class' => 'mw-prefs-buttons' ], $html );
90 }
91
92 return $html;
93 }
94
101 function filterDataForSubmit( $data ) {
102 foreach ( $this->mFlatFields as $fieldname => $field ) {
103 if ( $field instanceof HTMLNestedFilterable ) {
104 $info = $field->mParams;
105 $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $fieldname;
106 foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
107 $data["$prefix$key"] = $value;
108 }
109 unset( $data[$fieldname] );
110 }
111 }
112
113 return $data;
114 }
115
120 function getBody() {
121 return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' );
122 }
123
130 function getLegend( $key ) {
131 $legend = parent::getLegend( $key );
132 Hooks::run( 'PreferencesGetLegend', [ $this, $key, &$legend ] );
133 return $legend;
134 }
135
141 return array_keys( array_filter( $this->mFieldTree, 'is_array' ) );
142 }
143}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition HTMLForm.php:130
getTitle()
Get the title.
displaySection( $fields, $sectionName='', $fieldsetIDPrefix='', &$hasUserVisibleFields=false)
MediaWikiServices is the service locator for the application scope of MediaWiki.
Form to edit user preferences.
getBody()
Get the whole body of the form.
filterDataForSubmit( $data)
Separate multi-option preferences into multiple preferences, since we have to store them separately.
getExtraSuccessRedirectParameters()
Get extra parameters for the query string when redirecting after successful save.
getPreferenceSections()
Get the keys of each top level preference section.
getLegend( $key)
Get the "<legend>" for a given section key.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
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
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:2013
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 before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition hooks.txt:2056
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:247
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