32 parent::__construct( $descriptor,
$context, $messagePrefix );
34 $this->
getOutput()->addModuleStyles(
'mediawiki.htmlform.ooui.styles' );
46 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
47 $field->setShowEmptyLabel(
false );
55 $isBadIE = preg_match(
'/MSIE [1-7]\./i', $this->
getRequest()->getHeader(
'User-Agent' ) );
57 if ( $this->mShowSubmit ) {
60 if ( isset( $this->mSubmitID ) ) {
64 if ( isset( $this->mSubmitName ) ) {
68 if ( isset( $this->mSubmitTooltip ) ) {
75 $attribs[
'classes'] = [
'mw-htmlform-submit' ];
82 $buttons .=
new OOUI\ButtonInputWidget(
$attribs );
85 if ( $this->mShowReset ) {
86 $buttons .=
new OOUI\ButtonInputWidget( [
88 'label' => $this->
msg(
'htmlform-reset' )->
text(),
89 'useInputTag' => $isBadIE,
93 if ( $this->mShowCancel ) {
94 $target = $this->mCancelTarget ?: Title::newMainPage();
95 if ( $target instanceof
Title ) {
96 $target = $target->getLocalURL();
98 $buttons .=
new OOUI\ButtonWidget( [
99 'label' => $this->
msg(
'cancel' )->
text(),
104 foreach ( $this->mButtons as $button ) {
107 if ( $button[
'attribs'] ) {
108 $attrs += $button[
'attribs'];
111 if ( isset( $button[
'id'] ) ) {
112 $attrs[
'id'] = $button[
'id'];
116 $label = $button[
'value'];
117 } elseif ( isset( $button[
'label-message'] ) ) {
118 $label =
new OOUI\HtmlSnippet( $this->
getMessage( $button[
'label-message'] )->parse() );
119 } elseif ( isset( $button[
'label'] ) ) {
120 $label = $button[
'label'];
121 } elseif ( isset( $button[
'label-raw'] ) ) {
122 $label =
new OOUI\HtmlSnippet( $button[
'label-raw'] );
124 $label = $button[
'value'];
127 $attrs[
'classes'] = isset( $attrs[
'class'] ) ? (
array)$attrs[
'class'] : [];
129 $buttons .=
new OOUI\ButtonInputWidget( [
131 'name' => $button[
'name'],
132 'value' => $button[
'value'],
134 'flags' => $button[
'flags'],
135 'framed' => $button[
'framed'],
136 'useInputTag' => $isBadIE,
144 return Html::rawElement(
'div',
145 [
'class' =>
'mw-htmlform-submit-buttons' ],
"\n$buttons" ) .
"\n";
150 $layout =
new OOUI\PanelLayout( [
154 'infusable' =>
false,
157 $layout->appendContent(
158 new OOUI\FieldsetLayout( [
160 'infusable' =>
false,
163 'content' =>
new OOUI\HtmlSnippet(
$section )
178 protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
180 'items' => $fieldsHtml,
182 if ( $sectionName ) {
183 $config[
'id'] = Sanitizer::escapeIdForAttribute( $sectionName );
185 if ( is_string( $this->mWrapperLegend ) ) {
188 return new OOUI\FieldsetLayout( $config );
197 if ( $elements ===
'' ) {
201 if ( !in_array( $elementsType, [
'error',
'warning' ],
true ) ) {
202 throw new DomainException( $elementsType .
' is not a valid type.' );
205 if ( $elements instanceof
Status ) {
206 if ( !$elements->isGood() ) {
207 $errors = $elements->getErrorsByType( $elementsType );
208 foreach ( $errors as &$error ) {
211 $error = array_merge( [ $error[
'message'] ], $error[
'params'] );
214 } elseif ( $elementsType ===
'error' ) {
215 if ( is_array( $elements ) ) {
217 } elseif ( is_string( $elements ) ) {
218 $errors = [ $elements ];
222 foreach ( $errors as &$error ) {
223 $error = $this->
getMessage( $error )->parse();
224 $error =
new OOUI\HtmlSnippet( $error );
228 if ( $elementsType ===
'error' ) {
229 $this->oouiErrors = $errors;
231 $this->oouiWarnings = $errors;
241 return parent::getHeaderText(
$section );
246 $fieldset = parent::getBody();
248 if ( $fieldset instanceof OOUI\FieldsetLayout ) {
249 $classes = [
'mw-htmlform-ooui-header' ];
250 if ( $this->oouiErrors ) {
251 $classes[] =
'mw-htmlform-ooui-header-errors';
253 if ( $this->oouiWarnings ) {
254 $classes[] =
'mw-htmlform-ooui-header-warnings';
256 if ( $this->mHeader || $this->oouiErrors || $this->oouiWarnings ) {
258 if ( $this->mHeader ) {
259 $element =
new OOUI\LabelWidget( [
'label' =>
new OOUI\HtmlSnippet( $this->mHeader ) ] );
261 $element =
new OOUI\Widget( [] );
263 $fieldset->addItems( [
264 new OOUI\FieldLayout(
268 'errors' => $this->oouiErrors,
269 'notices' => $this->oouiWarnings,
270 'classes' => $classes,
281 'classes' => [
'mw-htmlform',
'mw-htmlform-ooui' ],
282 'content' =>
new OOUI\HtmlSnippet(
$html ),
286 $form =
new OOUI\PanelLayout( [
287 'classes' => [
'mw-htmlform-ooui-wrapper' ],
289 'padded' => $this->mWrapperLegend !==
false,
290 'framed' => $this->mWrapperLegend !==
false,
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getRequest()
Get the WebRequest object.
getOutput()
Get the OutputPage object.
static titleAttrib( $name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Represents a title within MediaWiki.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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 true
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
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section