MediaWiki REL1_39
HTMLForm.php
Go to the documentation of this file.
1<?php
2
24use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
28
150class HTMLForm extends ContextSource {
151 use ProtectedHookAccessorTrait;
152
154 public static $typeMappings = [
155 'api' => HTMLApiField::class,
156 'text' => HTMLTextField::class,
157 'textwithbutton' => HTMLTextFieldWithButton::class,
158 'textarea' => HTMLTextAreaField::class,
159 'select' => HTMLSelectField::class,
160 'combobox' => HTMLComboboxField::class,
161 'radio' => HTMLRadioField::class,
162 'multiselect' => HTMLMultiSelectField::class,
163 'limitselect' => HTMLSelectLimitField::class,
164 'check' => HTMLCheckField::class,
165 'toggle' => HTMLCheckField::class,
166 'int' => HTMLIntField::class,
167 'file' => HTMLFileField::class,
168 'float' => HTMLFloatField::class,
169 'info' => HTMLInfoField::class,
170 'selectorother' => HTMLSelectOrOtherField::class,
171 'selectandother' => HTMLSelectAndOtherField::class,
172 'namespaceselect' => HTMLSelectNamespace::class,
173 'namespaceselectwithbutton' => HTMLSelectNamespaceWithButton::class,
174 'tagfilter' => HTMLTagFilter::class,
175 'sizefilter' => HTMLSizeFilterField::class,
176 'submit' => HTMLSubmitField::class,
177 'hidden' => HTMLHiddenField::class,
178 'edittools' => HTMLEditTools::class,
179 'checkmatrix' => HTMLCheckMatrix::class,
180 'cloner' => HTMLFormFieldCloner::class,
181 'autocompleteselect' => HTMLAutoCompleteSelectField::class,
182 'language' => HTMLSelectLanguageField::class,
183 'date' => HTMLDateTimeField::class,
184 'time' => HTMLDateTimeField::class,
185 'datetime' => HTMLDateTimeField::class,
186 'expiry' => HTMLExpiryField::class,
187 // HTMLTextField will output the correct type="" attribute automagically.
188 // There are about four zillion other HTML5 input types, like range, but
189 // we don't use those at the moment, so no point in adding all of them.
190 'email' => HTMLTextField::class,
191 'password' => HTMLTextField::class,
192 'url' => HTMLTextField::class,
193 'title' => HTMLTitleTextField::class,
194 'user' => HTMLUserTextField::class,
195 'tagmultiselect' => HTMLTagMultiselectField::class,
196 'usersmultiselect' => HTMLUsersMultiselectField::class,
197 'titlesmultiselect' => HTMLTitlesMultiselectField::class,
198 'namespacesmultiselect' => HTMLNamespacesMultiselectField::class,
199 ];
200
202
204
206 protected $mFlatFields = [];
207 protected $mFieldTree = [];
208 protected $mShowReset = false;
209 protected $mShowSubmit = true;
211 protected $mSubmitFlags = [ 'primary', 'progressive' ];
212 protected $mShowCancel = false;
213 protected $mCancelTarget;
214
221
222 protected $mPre = '';
223 protected $mHeader = '';
224 protected $mFooter = '';
225 protected $mSectionHeaders = [];
226 protected $mSectionFooters = [];
227 protected $mPost = '';
228 protected $mId;
229 protected $mName;
230 protected $mTableId = '';
231
232 protected $mSubmitID;
233 protected $mSubmitName;
234 protected $mSubmitText;
236
239 protected $mTitle;
240 protected $mMethod = 'post';
241 protected $mWasSubmitted = false;
242
248 protected $mAction = false;
249
255 protected $mCollapsible = false;
256
262 protected $mCollapsed = false;
263
269 protected $mAutocomplete = null;
270
271 protected $mUseMultipart = false;
276 protected $mHiddenFields = [];
281 protected $mButtons = [];
282
283 protected $mWrapperLegend = false;
284 protected $mWrapperAttributes = [];
285
290 protected $mTokenSalt = '';
291
300 protected $mSubSectionBeforeFields = true;
301
307 protected $displayFormat = 'table';
308
313 protected $availableDisplayFormats = [
314 'table',
315 'div',
316 'raw',
317 'inline',
318 ];
319
324 protected $availableSubclassDisplayFormats = [
325 'vform',
326 'ooui',
327 ];
328
333 private $hiddenTitleAddedToForm = false;
334
348 public static function factory(
349 $displayFormat, $descriptor, IContextSource $context, $messagePrefix = ''
350 ) {
351 switch ( $displayFormat ) {
352 case 'vform':
353 return new VFormHTMLForm( $descriptor, $context, $messagePrefix );
354 case 'ooui':
355 return new OOUIHTMLForm( $descriptor, $context, $messagePrefix );
356 default:
357 $form = new self( $descriptor, $context, $messagePrefix );
358 $form->setDisplayFormat( $displayFormat );
359 return $form;
360 }
361 }
362
374 public function __construct(
375 $descriptor, IContextSource $context, $messagePrefix = ''
376 ) {
377 $this->setContext( $context );
378 $this->mMessagePrefix = $messagePrefix;
379
380 // Evil hack for mobile :(
381 if (
382 !$this->getConfig()->get( MainConfigNames::HTMLFormAllowTableFormat )
383 && $this->displayFormat === 'table'
384 ) {
385 $this->displayFormat = 'div';
386 }
387
388 $this->addFields( $descriptor );
389 }
390
400 public function addFields( $descriptor ) {
401 $loadedDescriptor = [];
402
403 foreach ( $descriptor as $fieldname => $info ) {
404
405 $section = $info['section'] ?? '';
406
407 if ( isset( $info['type'] ) && $info['type'] === 'file' ) {
408 $this->mUseMultipart = true;
409 }
410
411 $field = static::loadInputFromParameters( $fieldname, $info, $this );
412
413 $setSection =& $loadedDescriptor;
414 if ( $section ) {
415 foreach ( explode( '/', $section ) as $newName ) {
416 if ( !isset( $setSection[$newName] ) ) {
417 $setSection[$newName] = [];
418 }
419
420 $setSection =& $setSection[$newName];
421 }
422 }
423
424 $setSection[$fieldname] = $field;
425 $this->mFlatFields[$fieldname] = $field;
426 }
427
428 $this->mFieldTree = array_merge( $this->mFieldTree, $loadedDescriptor );
429
430 return $this;
431 }
432
437 public function hasField( $fieldname ) {
438 return isset( $this->mFlatFields[$fieldname] );
439 }
440
446 public function getField( $fieldname ) {
447 if ( !$this->hasField( $fieldname ) ) {
448 throw new DomainException( __METHOD__ . ': no field named ' . $fieldname );
449 }
450 return $this->mFlatFields[$fieldname];
451 }
452
463 public function setDisplayFormat( $format ) {
464 if (
465 in_array( $format, $this->availableSubclassDisplayFormats, true ) ||
466 in_array( $this->displayFormat, $this->availableSubclassDisplayFormats, true )
467 ) {
468 throw new MWException( 'Cannot change display format after creation, ' .
469 'use HTMLForm::factory() instead' );
470 }
471
472 if ( !in_array( $format, $this->availableDisplayFormats, true ) ) {
473 throw new MWException( 'Display format must be one of ' .
474 print_r(
475 array_merge(
476 $this->availableDisplayFormats,
477 $this->availableSubclassDisplayFormats
478 ),
479 true
480 ) );
481 }
482
483 // Evil hack for mobile :(
484 if ( !$this->getConfig()->get( MainConfigNames::HTMLFormAllowTableFormat ) &&
485 $format === 'table' ) {
486 $format = 'div';
487 }
488
489 $this->displayFormat = $format;
490
491 return $this;
492 }
493
499 public function getDisplayFormat() {
500 return $this->displayFormat;
501 }
502
520 public static function getClassFromDescriptor( $fieldname, &$descriptor ) {
521 if ( isset( $descriptor['class'] ) ) {
522 $class = $descriptor['class'];
523 } elseif ( isset( $descriptor['type'] ) ) {
524 $class = static::$typeMappings[$descriptor['type']];
525 $descriptor['class'] = $class;
526 } else {
527 $class = null;
528 }
529
530 if ( !$class ) {
531 throw new MWException( "Descriptor with no class for $fieldname: "
532 . print_r( $descriptor, true ) );
533 }
534
535 return $class;
536 }
537
550 public static function loadInputFromParameters( $fieldname, $descriptor,
551 HTMLForm $parent = null
552 ) {
553 $class = static::getClassFromDescriptor( $fieldname, $descriptor );
554
555 $descriptor['fieldname'] = $fieldname;
556 if ( $parent ) {
557 $descriptor['parent'] = $parent;
558 }
559
560 # @todo This will throw a fatal error whenever someone try to use
561 # 'class' to feed a CSS class instead of 'cssclass'. Would be
562 # great to avoid the fatal error and show a nice error.
563 return new $class( $descriptor );
564 }
565
575 public function prepareForm() {
576 # Load data from the request.
577 if (
578 $this->mFormIdentifier === null ||
579 $this->getRequest()->getVal( 'wpFormIdentifier' ) === $this->mFormIdentifier
580 ) {
581 $this->loadFieldData();
582 } else {
583 $this->mFieldData = [];
584 }
585
586 return $this;
587 }
588
593 public function tryAuthorizedSubmit() {
594 $result = false;
595
596 if ( $this->mFormIdentifier === null ) {
597 $identOkay = true;
598 } else {
599 $identOkay = $this->getRequest()->getVal( 'wpFormIdentifier' ) === $this->mFormIdentifier;
600 }
601
602 $tokenOkay = false;
603 if ( $this->getMethod() !== 'post' ) {
604 $tokenOkay = true; // no session check needed
605 } elseif ( $this->getRequest()->wasPosted() ) {
606 $editToken = $this->getRequest()->getVal( 'wpEditToken' );
607 if ( $this->getUser()->isRegistered() || $editToken !== null ) {
608 // Session tokens for logged-out users have no security value.
609 // However, if the user gave one, check it in order to give a nice
610 // "session expired" error instead of "permission denied" or such.
611 $tokenOkay = $this->getUser()->matchEditToken( $editToken, $this->mTokenSalt );
612 } else {
613 $tokenOkay = true;
614 }
615 }
616
617 if ( $tokenOkay && $identOkay ) {
618 $this->mWasSubmitted = true;
619 $result = $this->trySubmit();
620 }
621
622 return $result;
623 }
624
632 public function show() {
633 $this->prepareForm();
634
635 $result = $this->tryAuthorizedSubmit();
636 if ( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
637 return $result;
638 }
639
640 $this->displayForm( $result );
641
642 return false;
643 }
644
650 public function showAlways() {
651 $this->prepareForm();
652
653 $result = $this->tryAuthorizedSubmit();
654
655 $this->displayForm( $result );
656
657 return $result;
658 }
659
672 public function trySubmit() {
673 $valid = true;
674 $hoistedErrors = Status::newGood();
675 if ( $this->mValidationErrorMessage ) {
676 foreach ( $this->mValidationErrorMessage as $error ) {
677 $hoistedErrors->fatal( ...$error );
678 }
679 } else {
680 $hoistedErrors->fatal( 'htmlform-invalid-input' );
681 }
682
683 $this->mWasSubmitted = true;
684
685 # Check for cancelled submission
686 foreach ( $this->mFlatFields as $fieldname => $field ) {
687 if ( !array_key_exists( $fieldname, $this->mFieldData ) ) {
688 continue;
689 }
690 if ( $field->cancelSubmit( $this->mFieldData[$fieldname], $this->mFieldData ) ) {
691 $this->mWasSubmitted = false;
692 return false;
693 }
694 }
695
696 # Check for validation
697 foreach ( $this->mFlatFields as $fieldname => $field ) {
698 if ( !array_key_exists( $fieldname, $this->mFieldData ) ) {
699 continue;
700 }
701 if ( $field->isDisabled( $this->mFieldData ) ) {
702 continue;
703 }
704 $res = $field->validate( $this->mFieldData[$fieldname], $this->mFieldData );
705 if ( $res !== true ) {
706 $valid = false;
707 if ( $res !== false && !$field->canDisplayErrors() ) {
708 if ( is_string( $res ) ) {
709 $hoistedErrors->fatal( 'rawmessage', $res );
710 } else {
711 $hoistedErrors->fatal( $res );
712 }
713 }
714 }
715 }
716
717 if ( !$valid ) {
718 return $hoistedErrors;
719 }
720
721 $callback = $this->mSubmitCallback;
722 if ( !is_callable( $callback ) ) {
723 throw new MWException( 'HTMLForm: no submit callback provided. Use ' .
724 'setSubmitCallback() to set one.' );
725 }
726
727 $data = $this->filterDataForSubmit( $this->mFieldData );
728
729 $res = call_user_func( $callback, $data, $this );
730 if ( $res === false ) {
731 $this->mWasSubmitted = false;
732 } elseif ( $res instanceof StatusValue ) {
733 // DWIM - callbacks are not supposed to return a StatusValue but it's easy to mix up.
734 $res = Status::wrap( $res );
735 }
736
737 return $res;
738 }
739
751 public function wasSubmitted() {
752 return $this->mWasSubmitted;
753 }
754
765 public function setSubmitCallback( $cb ) {
766 $this->mSubmitCallback = $cb;
767
768 return $this;
769 }
770
780 public function setValidationErrorMessage( $msg ) {
781 $this->mValidationErrorMessage = $msg;
782
783 return $this;
784 }
785
794 public function setIntro( $msg ) {
795 return $this->setPreHtml( $msg );
796 }
797
806 public function setPreHtml( $html ) {
807 $this->mPre = $html;
808
809 return $this;
810 }
811
820 public function addPreHtml( $html ) {
821 $this->mPre .= $html;
822
823 return $this;
824 }
825
832 public function getPreHtml() {
833 return $this->mPre;
834 }
835
844 public function setPreText( $msg ) {
845 return $this->setPreHtml( $msg );
846 }
847
856 public function addPreText( $msg ) {
857 return $this->addPreHtml( $msg );
858 }
859
867 public function getPreText() {
868 return $this->getPreHtml();
869 }
870
880 public function addHeaderHtml( $html, $section = null ) {
881 if ( $section === null ) {
882 $this->mHeader .= $html;
883 } else {
884 if ( !isset( $this->mSectionHeaders[$section] ) ) {
885 $this->mSectionHeaders[$section] = '';
886 }
887 $this->mSectionHeaders[$section] .= $html;
888 }
889
890 return $this;
891 }
892
902 public function setHeaderHtml( $html, $section = null ) {
903 if ( $section === null ) {
904 $this->mHeader = $html;
905 } else {
906 $this->mSectionHeaders[$section] = $html;
907 }
908
909 return $this;
910 }
911
920 public function getHeaderHtml( $section = null ) {
921 if ( $section === null ) {
922 return $this->mHeader;
923 } else {
924 return $this->mSectionHeaders[$section] ?? '';
925 }
926 }
927
937 public function addHeaderText( $msg, $section = null ) {
938 return $this->addHeaderHtml( $msg, $section );
939 }
940
951 public function setHeaderText( $msg, $section = null ) {
952 return $this->setHeaderHtml( $msg, $section );
953 }
954
964 public function getHeaderText( $section = null ) {
965 return $this->getHeaderHtml( $section );
966 }
967
977 public function addFooterHtml( $html, $section = null ) {
978 if ( $section === null ) {
979 $this->mFooter .= $html;
980 } else {
981 if ( !isset( $this->mSectionFooters[$section] ) ) {
982 $this->mSectionFooters[$section] = '';
983 }
984 $this->mSectionFooters[$section] .= $html;
985 }
986
987 return $this;
988 }
989
999 public function setFooterHtml( $html, $section = null ) {
1000 if ( $section === null ) {
1001 $this->mFooter = $html;
1002 } else {
1003 $this->mSectionFooters[$section] = $html;
1004 }
1005
1006 return $this;
1007 }
1008
1016 public function getFooterHtml( $section = null ) {
1017 if ( $section === null ) {
1018 return $this->mFooter;
1019 } else {
1020 return $this->mSectionFooters[$section] ?? '';
1021 }
1022 }
1023
1033 public function addFooterText( $msg, $section = null ) {
1034 return $this->addFooterHtml( $msg, $section );
1035 }
1036
1047 public function setFooterText( $msg, $section = null ) {
1048 return $this->setFooterHtml( $msg, $section );
1049 }
1050
1059 public function getFooterText( $section = null ) {
1060 return $this->getFooterHtml( $section );
1061 }
1062
1071 public function addPostHtml( $html ) {
1072 $this->mPost .= $html;
1073
1074 return $this;
1075 }
1076
1085 public function setPostHtml( $html ) {
1086 $this->mPost = $html;
1087
1088 return $this;
1089 }
1090
1097 public function getPostHtml() {
1098 return $this->mPost;
1099 }
1100
1109 public function addPostText( $msg ) {
1110 return $this->addPostHtml( $msg );
1111 }
1112
1121 public function setPostText( $msg ) {
1122 return $this->setPostHtml( $msg );
1123 }
1124
1134 public function addHiddenField( $name, $value, array $attribs = [] ) {
1135 $attribs += [ 'name' => $name ];
1136 $this->mHiddenFields[] = [ $value, $attribs ];
1137
1138 return $this;
1139 }
1140
1151 public function addHiddenFields( array $fields ) {
1152 foreach ( $fields as $name => $value ) {
1153 $this->mHiddenFields[] = [ $value, [ 'name' => $name ] ];
1154 }
1155
1156 return $this;
1157 }
1158
1182 public function addButton( $data ) {
1183 if ( !is_array( $data ) ) {
1184 $args = func_get_args();
1185 if ( count( $args ) < 2 || count( $args ) > 4 ) {
1186 throw new InvalidArgumentException(
1187 'Incorrect number of arguments for deprecated calling style'
1188 );
1189 }
1190 $data = [
1191 'name' => $args[0],
1192 'value' => $args[1],
1193 'id' => $args[2] ?? null,
1194 'attribs' => $args[3] ?? null,
1195 ];
1196 } else {
1197 if ( !isset( $data['name'] ) ) {
1198 throw new InvalidArgumentException( 'A name is required' );
1199 }
1200 if ( !isset( $data['value'] ) ) {
1201 throw new InvalidArgumentException( 'A value is required' );
1202 }
1203 }
1204 $this->mButtons[] = $data + [
1205 'id' => null,
1206 'attribs' => null,
1207 'flags' => null,
1208 'framed' => true,
1209 ];
1210
1211 return $this;
1212 }
1213
1223 public function setTokenSalt( $salt ) {
1224 $this->mTokenSalt = $salt;
1225
1226 return $this;
1227 }
1228
1243 public function displayForm( $submitResult ) {
1244 $this->getOutput()->addHTML( $this->getHTML( $submitResult ) );
1245 }
1246
1251 private function getHiddenTitle(): string {
1252 if ( $this->hiddenTitleAddedToForm ) {
1253 return '';
1254 }
1255
1256 $html = '';
1257 if ( $this->getMethod() === 'post' ||
1258 $this->getAction() === $this->getConfig()->get( MainConfigNames::Script )
1259 ) {
1260 $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
1261 }
1262 $this->hiddenTitleAddedToForm = true;
1263 return $html;
1264 }
1265
1276 public function getHTML( $submitResult ) {
1277 # For good measure (it is the default)
1278 $this->getOutput()->setPreventClickjacking( true );
1279 $this->getOutput()->addModules( 'mediawiki.htmlform' );
1280 $this->getOutput()->addModuleStyles( 'mediawiki.htmlform.styles' );
1281
1282 if ( $this->mCollapsible ) {
1283 // Preload jquery.makeCollapsible for mediawiki.htmlform
1284 $this->getOutput()->addModules( 'jquery.makeCollapsible' );
1285 }
1286
1287 $html = ''
1288 . $this->getErrorsOrWarnings( $submitResult, 'error' )
1289 . $this->getErrorsOrWarnings( $submitResult, 'warning' )
1290 . $this->getHeaderText()
1291 . $this->getHiddenTitle()
1292 . $this->getBody()
1293 . $this->getHiddenFields()
1294 . $this->getButtons()
1295 . $this->getFooterText();
1296
1297 $html = $this->wrapForm( $html );
1298
1299 return '' . $this->mPre . $html . $this->mPost;
1300 }
1301
1309 public function setCollapsibleOptions( $collapsedByDefault = false ) {
1310 $this->mCollapsible = true;
1311 $this->mCollapsed = $collapsedByDefault;
1312 return $this;
1313 }
1314
1320 protected function getFormAttributes() {
1321 # Use multipart/form-data
1322 $encType = $this->mUseMultipart
1323 ? 'multipart/form-data'
1324 : 'application/x-www-form-urlencoded';
1325 # Attributes
1326 $attribs = [
1327 'class' => 'mw-htmlform',
1328 'action' => $this->getAction(),
1329 'method' => $this->getMethod(),
1330 'enctype' => $encType,
1331 ];
1332 if ( $this->mId ) {
1333 $attribs['id'] = $this->mId;
1334 }
1335 if ( is_string( $this->mAutocomplete ) ) {
1336 $attribs['autocomplete'] = $this->mAutocomplete;
1337 }
1338 if ( $this->mName ) {
1339 $attribs['name'] = $this->mName;
1340 }
1341 if ( $this->needsJSForHtml5FormValidation() ) {
1342 $attribs['novalidate'] = true;
1343 }
1344 return $attribs;
1345 }
1346
1355 public function wrapForm( $html ) {
1356 # Include a <fieldset> wrapper for style, if requested.
1357 if ( $this->mWrapperLegend !== false ) {
1358 $legend = is_string( $this->mWrapperLegend ) ? $this->mWrapperLegend : false;
1359 $html = Xml::fieldset( $legend, $html, $this->mWrapperAttributes );
1360 }
1361
1362 return Html::rawElement(
1363 'form',
1364 $this->getFormAttributes(),
1365 $html
1366 );
1367 }
1368
1373 public function getHiddenFields() {
1374 $html = '';
1375
1376 // add the title as a hidden file if it hasn't been added yet and if it is necessary
1377 // added for backward compatibility with the previous version of this public method
1378 $html .= $this->getHiddenTitle();
1379
1380 if ( $this->mFormIdentifier !== null ) {
1381 $html .= Html::hidden(
1382 'wpFormIdentifier',
1383 $this->mFormIdentifier
1384 ) . "\n";
1385 }
1386 if ( $this->getMethod() === 'post' ) {
1387 $html .= Html::hidden(
1388 'wpEditToken',
1389 $this->getUser()->getEditToken( $this->mTokenSalt ),
1390 [ 'id' => 'wpEditToken' ]
1391 ) . "\n";
1392 }
1393
1394 foreach ( $this->mHiddenFields as [ $value, $attribs ] ) {
1395 $html .= Html::hidden( $attribs['name'], $value, $attribs ) . "\n";
1396 }
1397
1398 return $html;
1399 }
1400
1406 public function getButtons() {
1407 $buttons = '';
1408 $useMediaWikiUIEverywhere =
1409 $this->getConfig()->get( MainConfigNames::UseMediaWikiUIEverywhere );
1410
1411 if ( $this->mShowSubmit ) {
1412 $attribs = [];
1413
1414 if ( isset( $this->mSubmitID ) ) {
1415 $attribs['id'] = $this->mSubmitID;
1416 }
1417
1418 if ( isset( $this->mSubmitName ) ) {
1419 $attribs['name'] = $this->mSubmitName;
1420 }
1421
1422 if ( isset( $this->mSubmitTooltip ) ) {
1423 $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
1424 }
1425
1426 $attribs['class'] = [ 'mw-htmlform-submit' ];
1427
1428 if ( $useMediaWikiUIEverywhere ) {
1429 foreach ( $this->mSubmitFlags as $flag ) {
1430 $attribs['class'][] = 'mw-ui-' . $flag;
1431 }
1432 $attribs['class'][] = 'mw-ui-button';
1433 }
1434
1435 $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
1436 }
1437
1438 if ( $this->mShowReset ) {
1439 $buttons .= Html::element(
1440 'input',
1441 [
1442 'type' => 'reset',
1443 'value' => $this->msg( 'htmlform-reset' )->text(),
1444 'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button' : null,
1445 ]
1446 ) . "\n";
1447 }
1448
1449 if ( $this->mShowCancel ) {
1450 $target = $this->getCancelTargetURL();
1451 $buttons .= Html::element(
1452 'a',
1453 [
1454 'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button' : null,
1455 'href' => $target,
1456 ],
1457 $this->msg( 'cancel' )->text()
1458 ) . "\n";
1459 }
1460
1461 foreach ( $this->mButtons as $button ) {
1462 $attrs = [
1463 'type' => 'submit',
1464 'name' => $button['name'],
1465 'value' => $button['value']
1466 ];
1467
1468 if ( isset( $button['label-message'] ) ) {
1469 $label = $this->getMessage( $button['label-message'] )->parse();
1470 } elseif ( isset( $button['label'] ) ) {
1471 $label = htmlspecialchars( $button['label'] );
1472 } elseif ( isset( $button['label-raw'] ) ) {
1473 $label = $button['label-raw'];
1474 } else {
1475 $label = htmlspecialchars( $button['value'] );
1476 }
1477
1478 // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset Always set in self::addButton
1479 if ( $button['attribs'] ) {
1480 // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset Always set in self::addButton
1481 $attrs += $button['attribs'];
1482 }
1483
1484 if ( isset( $button['id'] ) ) {
1485 $attrs['id'] = $button['id'];
1486 }
1487
1488 if ( $useMediaWikiUIEverywhere ) {
1489 $attrs['class'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : [];
1490 $attrs['class'][] = 'mw-ui-button';
1491 }
1492
1493 $buttons .= Html::rawElement( 'button', $attrs, $label ) . "\n";
1494 }
1495
1496 if ( !$buttons ) {
1497 return '';
1498 }
1499
1500 return Html::rawElement( 'span',
1501 [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";
1502 }
1503
1509 public function getBody() {
1510 return $this->displaySection( $this->mFieldTree, $this->mTableId );
1511 }
1512
1522 public function getErrorsOrWarnings( $elements, $elementsType ) {
1523 if ( !in_array( $elementsType, [ 'error', 'warning' ], true ) ) {
1524 throw new DomainException( $elementsType . ' is not a valid type.' );
1525 }
1526 $elementstr = false;
1527 if ( $elements instanceof Status ) {
1528 list( $errorStatus, $warningStatus ) = $elements->splitByErrorType();
1529 $status = $elementsType === 'error' ? $errorStatus : $warningStatus;
1530 if ( $status->isGood() ) {
1531 $elementstr = '';
1532 } else {
1533 $elementstr = $status
1534 ->getMessage()
1535 ->setContext( $this )
1536 ->setInterfaceMessageFlag( true )
1537 ->parse();
1538 }
1539 } elseif ( $elementsType === 'error' ) {
1540 if ( is_array( $elements ) ) {
1541 $elementstr = $this->formatErrors( $elements );
1542 } elseif ( $elements && $elements !== true ) {
1543 $elementstr = (string)$elements;
1544 }
1545 }
1546
1547 if ( !$elementstr ) {
1548 return '';
1549 } elseif ( $elementsType === 'error' ) {
1550 return Html::errorBox( $elementstr );
1551 } else { // $elementsType can only be 'warning'
1552 return Html::warningBox( $elementstr );
1553 }
1554 }
1555
1563 public function formatErrors( $errors ) {
1564 $errorstr = '';
1565
1566 foreach ( $errors as $error ) {
1567 $errorstr .= Html::rawElement(
1568 'li',
1569 [],
1570 $this->getMessage( $error )->parse()
1571 );
1572 }
1573
1574 $errorstr = Html::rawElement( 'ul', [], $errorstr );
1575
1576 return $errorstr;
1577 }
1578
1586 public function setSubmitText( $t ) {
1587 $this->mSubmitText = $t;
1588
1589 return $this;
1590 }
1591
1598 public function setSubmitDestructive() {
1599 $this->mSubmitFlags = [ 'destructive', 'primary' ];
1600
1601 return $this;
1602 }
1603
1612 public function setSubmitTextMsg( $msg ) {
1613 if ( !$msg instanceof Message ) {
1614 $msg = $this->msg( $msg );
1615 }
1616 $this->setSubmitText( $msg->text() );
1617
1618 return $this;
1619 }
1620
1625 public function getSubmitText() {
1626 return $this->mSubmitText ?: $this->msg( 'htmlform-submit' )->text();
1627 }
1628
1634 public function setSubmitName( $name ) {
1635 $this->mSubmitName = $name;
1636
1637 return $this;
1638 }
1639
1645 public function setSubmitTooltip( $name ) {
1646 $this->mSubmitTooltip = $name;
1647
1648 return $this;
1649 }
1650
1659 public function setSubmitID( $t ) {
1660 $this->mSubmitID = $t;
1661
1662 return $this;
1663 }
1664
1680 public function setFormIdentifier( $ident ) {
1681 $this->mFormIdentifier = $ident;
1682
1683 return $this;
1684 }
1685
1696 public function suppressDefaultSubmit( $suppressSubmit = true ) {
1697 $this->mShowSubmit = !$suppressSubmit;
1698
1699 return $this;
1700 }
1701
1708 public function showCancel( $show = true ) {
1709 $this->mShowCancel = $show;
1710 return $this;
1711 }
1712
1719 public function setCancelTarget( $target ) {
1720 if ( $target instanceof PageReference ) {
1721 $target = TitleValue::castPageToLinkTarget( $target );
1722 }
1723
1724 $this->mCancelTarget = $target;
1725 return $this;
1726 }
1727
1732 protected function getCancelTargetURL() {
1733 if ( is_string( $this->mCancelTarget ) ) {
1734 return $this->mCancelTarget;
1735 } else {
1736 // TODO: use a service to get the local URL for a LinkTarget, see T282283
1737 $target = Title::castFromLinkTarget( $this->mCancelTarget ) ?: Title::newMainPage();
1738 return $target->getLocalURL();
1739 }
1740 }
1741
1751 public function setTableId( $id ) {
1752 $this->mTableId = $id;
1753
1754 return $this;
1755 }
1756
1762 public function setId( $id ) {
1763 $this->mId = $id;
1764
1765 return $this;
1766 }
1767
1772 public function setName( $name ) {
1773 $this->mName = $name;
1774
1775 return $this;
1776 }
1777
1789 public function setWrapperLegend( $legend ) {
1790 $this->mWrapperLegend = $legend;
1791
1792 return $this;
1793 }
1794
1802 public function setWrapperAttributes( $attributes ) {
1803 $this->mWrapperAttributes = $attributes;
1804
1805 return $this;
1806 }
1807
1817 public function setWrapperLegendMsg( $msg ) {
1818 if ( !$msg instanceof Message ) {
1819 $msg = $this->msg( $msg );
1820 }
1821 $this->setWrapperLegend( $msg->text() );
1822
1823 return $this;
1824 }
1825
1835 public function setMessagePrefix( $p ) {
1836 $this->mMessagePrefix = $p;
1837
1838 return $this;
1839 }
1840
1848 public function setTitle( $t ) {
1849 // TODO: make mTitle a PageReference when we have a better way to get URLs, see T282283.
1850 $this->mTitle = Title::castFromPageReference( $t );
1851
1852 return $this;
1853 }
1854
1858 public function getTitle() {
1859 return $this->mTitle ?: $this->getContext()->getTitle();
1860 }
1861
1869 public function setMethod( $method = 'post' ) {
1870 $this->mMethod = strtolower( $method );
1871
1872 return $this;
1873 }
1874
1878 public function getMethod() {
1879 return $this->mMethod;
1880 }
1881
1892 protected function wrapFieldSetSection( $legend, $section, $attributes, $isRoot ) {
1893 return Xml::fieldset( $legend, $section, $attributes ) . "\n";
1894 }
1895
1913 public function displaySection( $fields,
1914 $sectionName = '',
1915 $fieldsetIDPrefix = '',
1916 &$hasUserVisibleFields = false
1917 ) {
1918 if ( $this->mFieldData === null ) {
1919 throw new LogicException( 'HTMLForm::displaySection() called on uninitialized field data. '
1920 . 'You probably called displayForm() without calling prepareForm() first.' );
1921 }
1922
1923 $displayFormat = $this->getDisplayFormat();
1924
1925 $html = [];
1926 $subsectionHtml = '';
1927 $hasLabel = false;
1928
1929 // Conveniently, PHP method names are case-insensitive.
1930 // For grep: this can call getDiv, getRaw, getInline, getVForm, getOOUI
1931 $getFieldHtmlMethod = $displayFormat === 'table' ? 'getTableRow' : ( 'get' . $displayFormat );
1932
1933 foreach ( $fields as $key => $value ) {
1934 if ( $value instanceof HTMLFormField ) {
1935 $v = array_key_exists( $key, $this->mFieldData )
1936 ? $this->mFieldData[$key]
1937 : $value->getDefault();
1938
1939 $retval = $value->$getFieldHtmlMethod( $v );
1940
1941 // check, if the form field should be added to
1942 // the output.
1943 if ( $value->hasVisibleOutput() ) {
1944 $html[] = $retval;
1945
1946 $labelValue = trim( $value->getLabel() );
1947 if ( $labelValue !== "\u{00A0}" && $labelValue !== '&#160;' && $labelValue !== '' ) {
1948 $hasLabel = true;
1949 }
1950
1951 $hasUserVisibleFields = true;
1952 }
1953 } elseif ( is_array( $value ) ) {
1954 $subsectionHasVisibleFields = false;
1955 $section =
1956 $this->displaySection( $value,
1957 "mw-htmlform-$key",
1958 "$fieldsetIDPrefix$key-",
1959 $subsectionHasVisibleFields );
1960 $legend = null;
1961
1962 if ( $subsectionHasVisibleFields === true ) {
1963 // Display the section with various niceties.
1964 $hasUserVisibleFields = true;
1965
1966 $legend = $this->getLegend( $key );
1967
1968 $section = $this->getHeaderText( $key ) .
1969 $section .
1970 $this->getFooterText( $key );
1971
1972 $attributes = [];
1973 if ( $fieldsetIDPrefix ) {
1974 $attributes['id'] = Sanitizer::escapeIdForAttribute( "$fieldsetIDPrefix$key" );
1975 }
1976 $subsectionHtml .= $this->wrapFieldSetSection(
1977 $legend, $section, $attributes, $fields === $this->mFieldTree
1978 );
1979 } else {
1980 // Just return the inputs, nothing fancy.
1981 $subsectionHtml .= $section;
1982 }
1983 }
1984 }
1985
1986 $html = $this->formatSection( $html, $sectionName, $hasLabel );
1987
1988 if ( $subsectionHtml ) {
1989 if ( $this->mSubSectionBeforeFields ) {
1990 return $subsectionHtml . "\n" . $html;
1991 } else {
1992 return $html . "\n" . $subsectionHtml;
1993 }
1994 } else {
1995 return $html;
1996 }
1997 }
1998
2007 protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
2008 if ( !$fieldsHtml ) {
2009 // Do not generate any wrappers for empty sections. Sections may be empty if they only have
2010 // subsections, but no fields. A legend will still be added in wrapFieldSetSection().
2011 return '';
2012 }
2013
2014 $displayFormat = $this->getDisplayFormat();
2015 $html = implode( '', $fieldsHtml );
2016
2017 if ( $displayFormat === 'raw' ) {
2018 return $html;
2019 }
2020
2021 $classes = [];
2022
2023 if ( !$anyFieldHasLabel ) { // Avoid strange spacing when no labels exist
2024 $classes[] = 'mw-htmlform-nolabel';
2025 }
2026
2027 $attribs = [ 'class' => $classes ];
2028
2029 if ( $sectionName ) {
2030 $attribs['id'] = Sanitizer::escapeIdForAttribute( $sectionName );
2031 }
2032
2033 if ( $displayFormat === 'table' ) {
2034 return Html::rawElement( 'table',
2035 $attribs,
2036 Html::rawElement( 'tbody', [], "\n$html\n" ) ) . "\n";
2037 } elseif ( $displayFormat === 'inline' ) {
2038 return Html::rawElement( 'span', $attribs, "\n$html\n" );
2039 } else {
2040 return Html::rawElement( 'div', $attribs, "\n$html\n" );
2041 }
2042 }
2043
2047 public function loadData() {
2048 $this->prepareForm();
2049 }
2050
2054 protected function loadFieldData() {
2055 $fieldData = [];
2056 $request = $this->getRequest();
2057
2058 foreach ( $this->mFlatFields as $fieldname => $field ) {
2059 if ( $field->skipLoadData( $request ) ) {
2060 continue;
2061 }
2062 if ( $field->mParams['disabled'] ?? false ) {
2063 $fieldData[$fieldname] = $field->getDefault();
2064 } else {
2065 $fieldData[$fieldname] = $field->loadDataFromRequest( $request );
2066 }
2067 }
2068
2069 // Reset to default for fields that are supposed to be disabled.
2070 // FIXME: Handle dependency chains, fields that a field checks on may need a reset too.
2071 foreach ( $fieldData as $name => &$value ) {
2072 $field = $this->mFlatFields[$name];
2073 if ( $field->isDisabled( $fieldData ) ) {
2074 $value = $field->getDefault();
2075 }
2076 }
2077
2078 # Filter data.
2079 foreach ( $fieldData as $name => &$value ) {
2080 $field = $this->mFlatFields[$name];
2081 $value = $field->filter( $value, $fieldData );
2082 }
2083
2084 $this->mFieldData = $fieldData;
2085 }
2086
2094 public function suppressReset( $suppressReset = true ) {
2095 $this->mShowReset = !$suppressReset;
2096
2097 return $this;
2098 }
2099
2110 public function filterDataForSubmit( $data ) {
2111 return $data;
2112 }
2113
2123 public function getLegend( $key ) {
2124 return $this->msg( $this->mMessagePrefix ? "{$this->mMessagePrefix}-$key" : $key )->text();
2125 }
2126
2137 public function setAction( $action ) {
2138 $this->mAction = $action;
2139
2140 return $this;
2141 }
2142
2150 public function getAction() {
2151 // If an action is already provided, return it
2152 if ( $this->mAction !== false ) {
2153 return $this->mAction;
2154 }
2155
2156 $articlePath = $this->getConfig()->get( MainConfigNames::ArticlePath );
2157 // Check whether we are in GET mode and the ArticlePath contains a "?"
2158 // meaning that getLocalURL() would return something like "index.php?title=...".
2159 // As browser remove the query string before submitting GET forms,
2160 // it means that the title would be lost. In such case use script path instead
2161 // and put title in an hidden field (see getHiddenFields()).
2162 if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() === 'get' ) {
2163 return $this->getConfig()->get( MainConfigNames::Script );
2164 }
2165
2166 return $this->getTitle()->getLocalURL();
2167 }
2168
2179 public function setAutocomplete( $autocomplete ) {
2180 $this->mAutocomplete = $autocomplete;
2181
2182 return $this;
2183 }
2184
2191 protected function getMessage( $value ) {
2192 return Message::newFromSpecifier( $value )->setContext( $this );
2193 }
2194
2205 foreach ( $this->mFlatFields as $fieldname => $field ) {
2206 if ( $field->needsJSForHtml5FormValidation() ) {
2207 return true;
2208 }
2209 }
2210 return false;
2211 }
2212}
getUser()
addFields( $fields)
getContext()
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
setContext(IContextSource $context)
The parent class to generate form fields.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:150
needsJSForHtml5FormValidation()
Whether this form, with its current fields, requires the user agent to have JavaScript enabled for th...
setSubmitCallback( $cb)
Set a callback to a function to do something with the form once it's been successfully validated.
Definition HTMLForm.php:765
setHeaderText( $msg, $section=null)
Set header text, inside the form.
Definition HTMLForm.php:951
displayForm( $submitResult)
Display the form (sending to the context's OutputPage object), with an appropriate error message or s...
string null $mAutocomplete
Form attribute autocomplete.
Definition HTMLForm.php:269
bool string $mAction
Form action URL.
Definition HTMLForm.php:248
setAction( $action)
Set the value for the action attribute of the form.
string array $mTokenSalt
Salt for the edit token.
Definition HTMLForm.php:290
setFooterHtml( $html, $section=null)
Set footer HTML, inside the form.
Definition HTMLForm.php:999
string[] $mSubmitFlags
Definition HTMLForm.php:211
addPreHtml( $html)
Add HTML to introductory message.
Definition HTMLForm.php:820
getSubmitText()
Get the text for the submit button, either customised or a default.
setMethod( $method='post')
Set the method used to submit the form.
setValidationErrorMessage( $msg)
Set a message to display on a validation error.
Definition HTMLForm.php:780
getCancelTargetURL()
getMessage( $value)
Turns a *-message parameter (which could be a MessageSpecifier, or a message name,...
getHeaderHtml( $section=null)
Get header HTML.
Definition HTMLForm.php:920
addHeaderHtml( $html, $section=null)
Add HTML to the header, inside the form.
Definition HTMLForm.php:880
setAutocomplete( $autocomplete)
Set the value for the autocomplete attribute of the form.
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
Initialise a new Object for the field.
Definition HTMLForm.php:550
setSubmitName( $name)
setTitle( $t)
Set the title for form submission.
static getClassFromDescriptor( $fieldname, &$descriptor)
Get the HTMLFormField subclass for this descriptor.
Definition HTMLForm.php:520
array $availableSubclassDisplayFormats
Available formats in which to display the form.
Definition HTMLForm.php:324
string $displayFormat
Format in which to display form.
Definition HTMLForm.php:307
addPostHtml( $html)
Add HTML to the end of the display.
bool $mSubSectionBeforeFields
If true, sections that contain both fields and subsections will render their subsections before their...
Definition HTMLForm.php:300
setTableId( $id)
Set the id of the <table> or outermost <div> element.
getHTML( $submitResult)
Returns the raw HTML generated by the form.
getLegend( $key)
Get a string to go in the "<legend>" of a section fieldset.
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
wrapFieldSetSection( $legend, $section, $attributes, $isRoot)
Wraps the given $section into an user-visible fieldset.
filterDataForSubmit( $data)
Overload this if you want to apply special filtration routines to the form as a whole,...
setWrapperLegendMsg( $msg)
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
setId( $id)
setWrapperLegend( $legend)
Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element.
formatErrors( $errors)
Format a stack of error messages into a single HTML string.
setDisplayFormat( $format)
Set format in which to display the form.
Definition HTMLForm.php:463
addButton( $data)
Add a button to the form.
addFooterHtml( $html, $section=null)
Add footer HTML, inside the form.
Definition HTMLForm.php:977
setPreHtml( $html)
Set the introductory message HTML, overwriting any existing message.
Definition HTMLForm.php:806
getPreHtml()
Get the introductory message HTML.
Definition HTMLForm.php:832
setPostHtml( $html)
Set HTML at the end of the display.
getPreText()
Get the introductory message HTML.
Definition HTMLForm.php:867
static string[] $typeMappings
A mapping of 'type' inputs onto standard HTMLFormField subclasses.
Definition HTMLForm.php:154
getHiddenFields()
Get the hidden fields that should go inside the form.
setSubmitDestructive()
Identify that the submit button in the form has a destructive action.
suppressDefaultSubmit( $suppressSubmit=true)
Stop a default submit button being shown for this form.
setSubmitID( $t)
Set the id for the submit button.
getDisplayFormat()
Getter for displayFormat.
Definition HTMLForm.php:499
getAction()
Get the value for the action attribute of the form.
show()
The here's-one-I-made-earlier option: do the submission if posted, or display the form with or withou...
Definition HTMLForm.php:632
hasField( $fieldname)
Definition HTMLForm.php:437
$mWrapperAttributes
Definition HTMLForm.php:284
addFooterText( $msg, $section=null)
Add footer text, inside the form.
addPostText( $msg)
Add text to the end of the display.
getFooterText( $section=null)
Get footer text.
addHeaderText( $msg, $section=null)
Add HTML to the header, inside the form.
Definition HTMLForm.php:937
setWrapperAttributes( $attributes)
For internal use only.
prepareForm()
Prepare form for submission.
Definition HTMLForm.php:575
array[] $mValidationErrorMessage
Definition HTMLForm.php:220
setCollapsibleOptions( $collapsedByDefault=false)
Enable collapsible mode, and set whether the form is collapsed by default.
wasSubmitted()
Test whether the form was considered to have been submitted or not, i.e.
Definition HTMLForm.php:751
getHeaderText( $section=null)
Get header text.
Definition HTMLForm.php:964
array[] $mButtons
Definition HTMLForm.php:281
tryAuthorizedSubmit()
Try submitting, with edit token check first.
Definition HTMLForm.php:593
setSubmitTooltip( $name)
displaySection( $fields, $sectionName='', $fieldsetIDPrefix='', &$hasUserVisibleFields=false)
array[] $mHiddenFields
Definition HTMLForm.php:276
setPreText( $msg)
Set the introductory message HTML, overwriting any existing message.
Definition HTMLForm.php:844
bool $mCollapsible
Whether the form can be collapsed.
Definition HTMLForm.php:255
addHiddenField( $name, $value, array $attribs=[])
Add a hidden field to the output.
setFooterText( $msg, $section=null)
Set footer text, inside the form.
setMessagePrefix( $p)
Set the prefix for various default messages.
getField( $fieldname)
Definition HTMLForm.php:446
bool $mCollapsed
Whether the form is collapsed by default.
Definition HTMLForm.php:262
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.
getFormAttributes()
Get HTML attributes for the <form> tag.
getBody()
Get the whole body of the form.
showAlways()
Same as self::show with the difference, that the form will be added to the output,...
Definition HTMLForm.php:650
getFooterHtml( $section=null)
Get footer HTML.
loadFieldData()
Load data of form fields from the request.
setHeaderHtml( $html, $section=null)
Set header HTML, inside the form.
Definition HTMLForm.php:902
setTokenSalt( $salt)
Set the salt for the edit token.
__construct( $descriptor, IContextSource $context, $messagePrefix='')
Build a new HTMLForm from an array of field attributes.
Definition HTMLForm.php:374
addPreText( $msg)
Add HTML to introductory message.
Definition HTMLForm.php:856
setFormIdentifier( $ident)
Set an internal identifier for this form.
setName( $name)
suppressReset( $suppressReset=true)
Stop a reset button being shown for this form.
setPostText( $msg)
Set text at the end of the display.
formatSection(array $fieldsHtml, $sectionName, $anyFieldHasLabel)
Put a form section together from the individual fields' HTML, merging it and wrapping.
setCancelTarget( $target)
Sets the target where the user is redirected to after clicking cancel.
array $availableDisplayFormats
Available formats in which to display the form.
Definition HTMLForm.php:313
showCancel( $show=true)
Show a cancel button (or prevent it).
Title null $mTitle
Definition HTMLForm.php:239
setSubmitText( $t)
Set the text for the submit button.
setIntro( $msg)
Set the introductory message, overwriting any existing message.
Definition HTMLForm.php:794
getButtons()
Get the submit and (potentially) reset buttons.
static factory( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='')
Construct a HTMLForm object for given display type.
Definition HTMLForm.php:348
trySubmit()
Validate all the fields, and call the submission callback function if everything is kosher.
Definition HTMLForm.php:672
HTMLFormField[] $mFlatFields
Definition HTMLForm.php:206
getErrorsOrWarnings( $elements, $elementsType)
Returns a formatted list of errors or warnings from the given elements.
addHiddenFields(array $fields)
Add an array of hidden fields to the output.
getPostHtml()
Get HTML at the end of the display.
addFields( $descriptor)
Add fields to the form.
Definition HTMLForm.php:400
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition Html.php:851
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null, $localizer=null, $user=null, $config=null, $relevantTitle=null)
Returns the attributes for the tooltip and access key.
Definition Linker.php:2299
MediaWiki exception.
A class containing constants representing the names of configuration variables.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:140
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
Definition Message.php:422
Compact stacked vertical format for forms, implemented using OOUI widgets.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
Represents a title within MediaWiki.
Definition Title.php:49
Compact stacked vertical format for forms.
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
if( $line===false) $args
Definition mcc.php:124