Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
HTMLFormField.php
Go to the documentation of this file.
1<?php
2
3namespaceMediaWiki\HTMLForm;
4
5use InvalidArgumentException;
6useMediaWiki\Context\RequestContext;
7useMediaWiki\Html\Html;
8useMediaWiki\HTMLForm\Field\HTMLCheckField;
9useMediaWiki\HTMLForm\Field\HTMLFormFieldCloner;
10useMediaWiki\Json\FormatJson;
11useMediaWiki\Linker\Linker;
12useMediaWiki\Logger\LoggerFactory;
13useMediaWiki\Message\Message;
14useMediaWiki\Request\WebRequest;
15useMediaWiki\Status\Status;
16useStatusValue;
17useWikimedia\HtmlArmor\HtmlArmor;
18useWikimedia\Message\MessageParam;
19useWikimedia\Message\MessageSpecifier;
20
27abstractclassHTMLFormField {
29public$mParams;
30
32protected $mValidationCallback;
34protected $mFilterCallback;
36protected$mName;
38protected$mDir;
40protected$mLabel;
42protected$mID;
44protected$mClass ='';
46protected$mVFormClass ='';
48protected$mHelpClass =false;
50protected$mDefault;
52private $mNotices;
53
57protected$mOptions =false;
59protected$mOptionsLabelsNotFromMessage =false;
63protected$mCondState = [];
65protected$mCondStateClass = [];
66
71protected$mShowEmptyLabels =true;
72
76public$mParent;
77
88abstractpublicfunctiongetInputHTML( $value );
89
98publicfunctiongetInputOOUI( $value ) {
99returnfalse;
100 }
101
113publicfunctiongetInputCodex( $value, $hasErrors ) {
114// If not overridden, fall back to getInputHTML()
115return $this->getInputHTML( $value );
116 }
117
124publicfunctioncanDisplayErrors() {
125return $this->hasVisibleOutput();
126 }
127
142publicfunctionmsg( $key, ...$params ) {
143if ( $this->mParent ) {
144return $this->mParent->msg( $key, ...$params );
145 }
146returnwfMessage( $key, ...$params );
147 }
148
156publicfunctionhasVisibleOutput() {
157returntrue;
158 }
159
166publicfunctiongetName() {
167return$this->mName;
168 }
169
181protectedfunctiongetNearestField( $name, $backCompat =false ) {
182// When the field is belong to a HTMLFormFieldCloner
183 $cloner = $this->mParams['cloner'] ??null;
184if ( $cloner instanceofHTMLFormFieldCloner ) {
185 $field = $cloner->findNearestField( $this, $name );
186if ( $field ) {
187return $field;
188 }
189 }
190
191if ( $backCompat && str_starts_with( $name,'wp' ) &&
192 !$this->mParent->hasField( $name )
193 ) {
194// Don't break the existed use cases.
195return $this->mParent->getField( substr( $name, 2 ) );
196 }
197return $this->mParent->getField( $name );
198 }
199
211protectedfunctiongetNearestFieldValue( $alldata, $name, $asDisplay =false, $backCompat =false ) {
212 $field = $this->getNearestField( $name, $backCompat );
213// When the field belongs to a HTMLFormFieldCloner
214 $cloner = $field->mParams['cloner'] ??null;
215if ( $cloner instanceofHTMLFormFieldCloner ) {
216 $value = $cloner->extractFieldData( $field, $alldata );
217 }else {
218// Note $alldata is an empty array when first rendering a form with a formIdentifier.
219// In that case, $alldata[$field->mParams['fieldname']] is unset and we use the
220// field's default value
221 $value = $alldata[$field->mParams['fieldname']] ?? $field->getDefault();
222 }
223
224// Check invert state for HTMLCheckField
225if ( $asDisplay && $field instanceofHTMLCheckField && ( $field->mParams['invert'] ??false ) ) {
226 $value = !$value;
227 }
228
229return $value;
230 }
231
242protectedfunctiongetNearestFieldByName( $alldata, $name, $asDisplay =false ) {
243return (string)$this->getNearestFieldValue( $alldata, $name, $asDisplay );
244 }
245
252protectedfunctionvalidateCondState( $params ) {
253 $origParams = $params;
254 $op = array_shift( $params );
255
256 $makeException =function (string $details ) use ( $origParams ): InvalidArgumentException {
257returnnew InvalidArgumentException(
258"Invalid hide-if or disable-if specification for $this->mName: " .
259 $details ." in " . var_export( $origParams,true )
260 );
261 };
262
263switch ( $op ) {
264case'NOT':
265if ( count( $params ) !== 1 ) {
266throw $makeException("NOT takes exactly one parameter" );
267 }
268// Fall-through intentionally
269
270case'AND':
271case'OR':
272case'NAND':
273case'NOR':
274foreach ( $params as $i => $p ) {
275if ( !is_array( $p ) ) {
276 $type = get_debug_type( $p );
277throw $makeException("Expected array, found $type at index $i" );
278 }
279 $this->validateCondState( $p );
280 }
281break;
282
283case'===':
284case'!==':
285case'CONTAINS':
286if ( count( $params ) !== 2 ) {
287throw $makeException("$op takes exactly two parameters" );
288 }
289 [ $name, $value ] = $params;
290if ( !is_string( $name ) || !is_string( $value ) ) {
291throw $makeException("Parameters for $op must be strings" );
292 }
293break;
294
295default:
296throw $makeException("Unknown operation" );
297 }
298 }
299
307protectedfunctioncheckStateRecurse( array $alldata, array $params ) {
308 $op = array_shift( $params );
309 $valueChk = ['AND' =>false,'OR' =>true,'NAND' =>false,'NOR' => true ];
310 $valueRet = ['AND' =>true,'OR' =>false,'NAND' =>false,'NOR' => true ];
311
312switch ( $op ) {
313case'AND':
314case'OR':
315case'NAND':
316case'NOR':
317foreach ( $params as $p ) {
318if ( $valueChk[$op] === $this->checkStateRecurse( $alldata, $p ) ) {
319return !$valueRet[$op];
320 }
321 }
322return $valueRet[$op];
323
324case'NOT':
325return !$this->checkStateRecurse( $alldata, $params[0] );
326
327case'===':
328case'!==':
329case'CONTAINS':
330 [ $field, $value ] = $params;
331 $testValue = $this->getNearestFieldValue( $alldata, $field,true,true );
332switch ( $op ) {
333case'===':
334return ( $value === (string)$testValue );
335case'!==':
336return ( $value !== (string)$testValue );
337case'CONTAINS':
338return in_array( $value, $testValue,true );
339 }
340 }
341 }
342
351protectedfunctionparseCondState( $params ) {
352 $op = array_shift( $params );
353
354switch ( $op ) {
355case'AND':
356case'OR':
357case'NAND':
358case'NOR':
359 $ret = [ $op ];
360foreach ( $params as $p ) {
361 $ret[] = $this->parseCondState( $p );
362 }
363return $ret;
364
365case'NOT':
366return ['NOT', $this->parseCondState( $params[0] ) ];
367
368case'===':
369case'!==':
370case'CONTAINS':
371 [ $name, $value ] = $params;
372 $field = $this->getNearestField( $name,true );
373return [ $op, $field->getName(), $value ];
374 }
375 }
376
382protectedfunctionparseCondStateForClient() {
383 $parsed = [];
384foreach ( $this->mCondState as $type => $params ) {
385 $parsed[$type] = $this->parseCondState( $params );
386 }
387return $parsed;
388 }
389
398publicfunctionisHidden( $alldata ) {
399return isset( $this->mCondState['hide'] ) &&
400 $this->checkStateRecurse( $alldata, $this->mCondState['hide'] );
401 }
402
411publicfunctionisDisabled( $alldata ) {
412return ( $this->mParams['disabled'] ??false ) ||
413 $this->isHidden( $alldata ) ||
414 ( isset( $this->mCondState['disable'] )
415 && $this->checkStateRecurse( $alldata, $this->mCondState['disable'] ) );
416 }
417
429publicfunctioncancelSubmit( $value, $alldata ) {
430returnfalse;
431 }
432
445publicfunctionvalidate( $value, $alldata ) {
446if ( $this->isHidden( $alldata ) ) {
447returntrue;
448 }
449
450if ( isset( $this->mParams['required'] )
451 && $this->mParams['required'] !==false
452 && ( $value ==='' || $value ===false || $value ===null )
453 ) {
454return $this->msg('htmlform-required' );
455 }
456
457if ( $this->mValidationCallback ===null ) {
458returntrue;
459 }
460
461 $p = ( $this->mValidationCallback )( $value, $alldata, $this->mParent );
462
463if ( $p instanceofStatusValue ) {
464 $language = $this->mParent ? $this->mParent->getLanguage() : RequestContext::getMain()->getLanguage();
465
466return $p->isGood() ? true : Status::wrap( $p )->getHTML(false,false, $language );
467 }
468
469return $p;
470 }
471
480publicfunctionfilter( $value, $alldata ) {
481if ( $this->mFilterCallback !==null ) {
482 $value = ( $this->mFilterCallback )( $value, $alldata, $this->mParent );
483 }
484
485return $value;
486 }
487
495protectedfunctionneedsLabel() {
496returntrue;
497 }
498
508publicfunctionsetShowEmptyLabel( $show ) {
509 $this->mShowEmptyLabels = $show;
510 }
511
523protectedfunctionisSubmitAttempt(WebRequest $request ) {
524// HTMLForm would add a hidden field of edit token for forms that require to be posted.
525return ( $request->wasPosted() && $request->getCheck('wpEditToken' ) )
526// The identifier matching or not has been checked in HTMLForm::prepareForm()
527 || $request->getCheck('wpFormIdentifier' );
528 }
529
538publicfunctionloadDataFromRequest( $request ) {
539if ( $request->getCheck( $this->mName ) ) {
540return $request->getText( $this->mName );
541 }else {
542return $this->getDefault();
543 }
544 }
545
554publicfunction__construct( $params ) {
555 $this->mParams = $params;
556
557if ( isset( $params['parent'] ) && $params['parent'] instanceofHTMLForm ) {
558 $this->mParent = $params['parent'];
559 }else {
560// Normally parent is added automatically by HTMLForm::factory.
561// Several field types already assume unconditionally this is always set,
562// so deprecate manually creating an HTMLFormField without a parent form set.
564 __METHOD__ .": Constructing an HTMLFormField without a 'parent' parameter",
565"1.40"
566 );
567 }
568
569 # Generate the label from a message, if possible
570if ( isset( $params['label-message'] ) ) {
571 $this->mLabel = $this->getMessage( $params['label-message'] )->parse();
572 } elseif ( isset( $params['label'] ) ) {
573if ( $params['label'] ==='&#160;' || $params['label'] ==="\u{00A0}" ) {
574// Apparently some things set &nbsp directly and in an odd format
575 $this->mLabel ="\u{00A0}";
576 }else {
577 $this->mLabel = htmlspecialchars( $params['label'] );
578 }
579 } elseif ( isset( $params['label-raw'] ) ) {
580 $this->mLabel = $params['label-raw'];
581 }
582
583 $this->mName = $params['name'] ??'wp' . $params['fieldname'];
584
585if ( isset( $params['dir'] ) ) {
586 $this->mDir = $params['dir'];
587 }
588
589 $this->mID ="mw-input-{$this->mName}";
590
591if ( isset( $params['default'] ) ) {
592 $this->mDefault = $params['default'];
593 }
594
595if ( isset( $params['id'] ) ) {
596 $this->mID = $params['id'];
597 }
598
599if ( isset( $params['cssclass'] ) ) {
600 $this->mClass = $params['cssclass'];
601 }
602
603if ( isset( $params['csshelpclass'] ) ) {
604 $this->mHelpClass = $params['csshelpclass'];
605 }
606
607if ( isset( $params['validation-callback'] ) ) {
608 $this->mValidationCallback = $params['validation-callback'];
609 }
610
611if ( isset( $params['filter-callback'] ) ) {
612 $this->mFilterCallback = $params['filter-callback'];
613 }
614
615if ( isset( $params['hidelabel'] ) ) {
616 $this->mShowEmptyLabels =false;
617 }
618if ( isset( $params['notices'] ) ) {
619 $this->mNotices = $params['notices'];
620 }
621
622if ( isset( $params['hide-if'] ) && $params['hide-if'] ) {
623 $this->validateCondState( $params['hide-if'] );
624 $this->mCondState['hide'] = $params['hide-if'];
625 $this->mCondStateClass[] ='mw-htmlform-hide-if';
626 }
627if ( !( isset( $params['disabled'] ) && $params['disabled'] ) &&
628 isset( $params['disable-if'] ) && $params['disable-if']
629 ) {
630 $this->validateCondState( $params['disable-if'] );
631 $this->mCondState['disable'] = $params['disable-if'];
632 $this->mCondStateClass[] ='mw-htmlform-disable-if';
633 }
634 }
635
645publicfunctiongetTableRow( $value ) {
646 [ $errors, $errorClass ] = $this->getErrorsAndErrorClass( $value );
647 $inputHtml = $this->getInputHTML( $value );
648 $fieldType = $this->getClassName();
649 $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() );
650 $cellAttributes = [];
651 $rowAttributes = [];
652 $rowClasses ='';
653
654if ( !empty( $this->mParams['vertical-label'] ) ) {
655 $cellAttributes['colspan'] = 2;
656 $verticalLabel =true;
657 }else {
658 $verticalLabel =false;
659 }
660
661 $label = $this->getLabelHtml( $cellAttributes );
662
663 $field = Html::rawElement(
664'td',
665 ['class' =>'mw-input' ] + $cellAttributes,
666 $inputHtml ."\n$errors"
667 );
668
669if ( $this->mCondState ) {
670 $rowAttributes['data-cond-state'] = FormatJson::encode( $this->parseCondStateForClient() );
671 $rowClasses .= implode(' ', $this->mCondStateClass );
672if ( $this->isHidden( $this->mParent->mFieldData ) ) {
673 $rowClasses .=' mw-htmlform-hide-if-hidden';
674 }
675 }
676
677if ( $verticalLabel ) {
678 $html = Html::rawElement('tr',
679 $rowAttributes + ['class' =>"mw-htmlform-vertical-label $rowClasses" ], $label );
680 $html .= Html::rawElement('tr',
681 $rowAttributes + [
682'class' =>"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses"
683 ],
684 $field );
685 }else {
686 $html = Html::rawElement('tr',
687 $rowAttributes + [
688'class' =>"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses"
689 ],
690 $label . $field );
691 }
692
693return $html . $helptext;
694 }
695
706publicfunctiongetDiv( $value ) {
707 [ $errors, $errorClass ] = $this->getErrorsAndErrorClass( $value );
708 $inputHtml = $this->getInputHTML( $value );
709 $fieldType = $this->getClassName();
710 $helptext = $this->getHelpTextHtmlDiv( $this->getHelpText() );
711 $cellAttributes = [];
712 $label = $this->getLabelHtml( $cellAttributes );
713
714 $outerDivClass = [
715'mw-input',
716'mw-htmlform-nolabel' => ( $label ==='' )
717 ];
718
719 $horizontalLabel = $this->mParams['horizontal-label'] ??false;
720
721if ( $horizontalLabel ) {
722 $field ="\u{00A0}" . $inputHtml ."\n$errors";
723 }else {
724 $field = Html::rawElement(
725'div',
726// @phan-suppress-next-line PhanUselessBinaryAddRight
727 ['class' => $outerDivClass ] + $cellAttributes,
728 $inputHtml ."\n$errors"
729 );
730 }
731
732 $wrapperAttributes = ['class' => [
733"mw-htmlform-field-$fieldType",
736 $errorClass,
737 ] ];
738if ( $this->mCondState ) {
739 $wrapperAttributes['data-cond-state'] = FormatJson::encode( $this->parseCondStateForClient() );
740 $wrapperAttributes['class'] = array_merge( $wrapperAttributes['class'], $this->mCondStateClass );
741if ( $this->isHidden( $this->mParent->mFieldData ) ) {
742 $wrapperAttributes['class'][] ='mw-htmlform-hide-if-hidden';
743 }
744 }
745return Html::rawElement('div', $wrapperAttributes, $label . $field ) .
746 $helptext;
747 }
748
758publicfunctiongetOOUI( $value ) {
759 $inputField = $this->getInputOOUI( $value );
760
761if ( !$inputField ) {
762// This field doesn't have an OOUI implementation yet at all. Fall back to getDiv() to
763// generate the whole field, label and errors and all, then wrap it in a Widget.
764// It might look weird, but it'll work OK.
765return $this->getFieldLayoutOOUI(
766new \OOUI\Widget( ['content' =>new \OOUI\HtmlSnippet( $this->getDiv( $value ) ) ] ),
767 ['align' =>'top' ]
768 );
769 }
770
771 $infusable =true;
772if ( is_string( $inputField ) ) {
773// We have an OOUI implementation, but it's not proper, and we got a load of HTML.
774// Cheat a little and wrap it in a widget. It won't be infusable, though, since client-side
775// JavaScript doesn't know how to rebuilt the contents.
776 $inputField = new \OOUI\Widget( ['content' =>new \OOUI\HtmlSnippet( $inputField ) ] );
777 $infusable =false;
778 }
779
780 $fieldType = $this->getClassName();
781 $help = $this->getHelpText();
782 $errors = $this->getErrorsRaw( $value );
783foreach ( $errors as &$error ) {
784 $error = new \OOUI\HtmlSnippet( $error );
785 }
786
787 $config = [
788'classes' => ["mw-htmlform-field-$fieldType" ],
789'align' => $this->getLabelAlignOOUI(),
790'help' => ( $help !==null && $help !=='' ) ?new \OOUI\HtmlSnippet( $help ) :null,
791'errors' => $errors,
792'infusable' => $infusable,
793'helpInline' => $this->isHelpInline(),
794'notices' => $this->mNotices ?: [],
795 ];
796if ( $this->mClass !=='' ) {
797 $config['classes'][] =$this->mClass;
798 }
799
800 $preloadModules =false;
801
802if ( $infusable && $this->shouldInfuseOOUI() ) {
803 $preloadModules =true;
804 $config['classes'][] ='mw-htmlform-autoinfuse';
805 }
806if ( $this->mCondState ) {
807 $config['classes'] = array_merge( $config['classes'], $this->mCondStateClass );
808if ( $this->isHidden( $this->mParent->mFieldData ) ) {
809 $config['classes'][] ='mw-htmlform-hide-if-hidden';
810 }
811 }
812
813// the element could specify, that the label doesn't need to be added
814 $label = $this->getLabel();
815if ( $label && $label !=="\u{00A0}" && $label !=='&#160;' ) {
816 $config['label'] = new \OOUI\HtmlSnippet( $label );
817 }
818
819if ( $this->mCondState ) {
820 $preloadModules =true;
821 $config['condState'] = $this->parseCondStateForClient();
822 }
823
824 $config['modules'] = $this->getOOUIModules();
825
826if ( $preloadModules ) {
827 $this->mParent->getOutput()->addModules('mediawiki.htmlform.ooui' );
828 $this->mParent->getOutput()->addModules( $this->getOOUIModules() );
829 }
830
831return $this->getFieldLayoutOOUI( $inputField, $config );
832 }
833
841publicfunctiongetCodex( $value ) {
842 $isDisabled = ( $this->mParams['disabled'] ?? false );
843
844// Label
845 $labelDiv ='';
846 $labelValue = trim( $this->getLabel() );
847// For weird historical reasons, a non-breaking space is treated as an empty label
848// Check for both a literal nbsp ("\u{00A0}") and the HTML-encoded version
849if ( $labelValue !=='' && $labelValue !=="\u{00A0}" && $labelValue !=='&#160;' ) {
850 $labelFor = $this->needsLabel() ? ['for' =>$this->mID ] : [];
851 $labelClasses = ['cdx-label' ];
852if ( $isDisabled ) {
853 $labelClasses[] ='cdx-label--disabled';
854 }
855// <div class="cdx-label">
856 $labelDiv = Html::rawElement('div', ['class' => $labelClasses ],
857// <label class="cdx-label__label" for="ID">
858 Html::rawElement('label', ['class' =>'cdx-label__label' ] + $labelFor,
859// <span class="cdx-label__label__text">
860 Html::rawElement('span', ['class' =>'cdx-label__label__text' ],
861 $labelValue
862 )
863 )
864 );
865 }
866
867// Help text
868// <div class="cdx-field__help-text">
869 $helptext = $this->getHelpTextHtmlDiv( $this->getHelpText(), ['cdx-field__help-text' ] );
870
871// Validation message
872// <div class="cdx-field__validation-message">
873// $errors is a <div class="cdx-message">
874// FIXME right now this generates a block message (cdx-message--block), we want an inline message instead
875 $validationMessage ='';
876 [ $errors, $errorClass ] = $this->getErrorsAndErrorClass( $value );
877if ( $errors !=='' ) {
878 $validationMessage = Html::rawElement('div', ['class' =>'cdx-field__validation-message' ],
879 $errors
880 );
881 }
882
883// Control
884 $inputHtml = $this->getInputCodex( $value, $errors !=='' );
885// <div class="cdx-field__control cdx-field__control--has-help-text">
886 $controlClasses = ['cdx-field__control' ];
887if ( $helptext ) {
888 $controlClasses[] ='cdx-field__control--has-help-text';
889 }
890 $control = Html::rawElement('div', ['class' => $controlClasses ], $inputHtml );
891
892// <div class="cdx-field">
893 $fieldClasses = [
894"mw-htmlform-field-{$this->getClassName()}",
896 $errorClass,
897'cdx-field'
898 ];
899if ( $isDisabled ) {
900 $fieldClasses[] ='cdx-field--disabled';
901 }
902 $fieldAttributes = [];
903// Set data attribute and CSS class for client side handling of hide-if / disable-if
904if ( $this->mCondState ) {
905 $fieldAttributes['data-cond-state'] = FormatJson::encode( $this->parseCondStateForClient() );
906 $fieldClasses = array_merge( $fieldClasses, $this->mCondStateClass );
907if ( $this->isHidden( $this->mParent->mFieldData ) ) {
908 $fieldClasses[] ='mw-htmlform-hide-if-hidden';
909 }
910 }
911
912return Html::rawElement('div', ['class' => $fieldClasses ] + $fieldAttributes,
913 $labelDiv . $control . $helptext . $validationMessage
914 );
915 }
916
924protectedfunctiongetClassName() {
925 $name = explode('\\', static::class );
926return end( $name );
927 }
928
934protectedfunctiongetLabelAlignOOUI() {
935return'top';
936 }
937
944protectedfunctiongetFieldLayoutOOUI( $inputField, $config ) {
945returnnewHTMLFormFieldLayout( $inputField, $config );
946 }
947
956protectedfunctionshouldInfuseOOUI() {
957// Always infuse fields with popup help text, since the interface for it is nicer with JS
958return !$this->isHelpInline() && $this->getHelpMessages();
959 }
960
968protectedfunctiongetOOUIModules() {
969return [];
970 }
971
982publicfunctiongetRaw( $value ) {
983 [ $errors, ] = $this->getErrorsAndErrorClass( $value );
984return"\n" . $errors .
985 $this->getLabelHtml() .
986 $this->getInputHTML( $value ) .
987 $this->getHelpTextHtmlRaw( $this->getHelpText() );
988 }
989
1000publicfunctiongetVForm( $value ) {
1001wfDeprecated( __METHOD__,'1.45' );
1002// Ewwww
1003 $this->mVFormClass =' mw-ui-vform-field';
1004return $this->getDiv( $value );
1005 }
1006
1014publicfunctiongetInline( $value ) {
1015 [ $errors, ] = $this->getErrorsAndErrorClass( $value );
1016return"\n" . $errors .
1017 $this->getLabelHtml() .
1018"\u{00A0}" .
1019 $this->getInputHTML( $value ) .
1020 $this->getHelpTextHtmlDiv( $this->getHelpText() );
1021 }
1022
1030publicfunctiongetHelpTextHtmlTable( $helptext ) {
1031if ( $helptext ===null ) {
1032return'';
1033 }
1034
1035 $rowAttributes = [];
1036if ( $this->mCondState ) {
1037 $rowAttributes['data-cond-state'] = FormatJson::encode( $this->parseCondStateForClient() );
1038 $rowAttributes['class'] =$this->mCondStateClass;
1039 }
1040
1041 $tdClasses = ['htmlform-tip' ];
1042if ( $this->mHelpClass !==false ) {
1043 $tdClasses[] =$this->mHelpClass;
1044 }
1045return Html::rawElement('tr', $rowAttributes,
1046 Html::rawElement('td', ['colspan' => 2,'class' => $tdClasses ], $helptext )
1047 );
1048 }
1049
1059publicfunctiongetHelpTextHtmlDiv( $helptext, $cssClasses = [] ) {
1060if ( $helptext ===null ) {
1061return'';
1062 }
1063
1064 $wrapperAttributes = [
1065'class' => array_merge( $cssClasses, ['htmlform-tip' ] ),
1066 ];
1067if ( $this->mHelpClass !==false ) {
1068 $wrapperAttributes['class'][] =$this->mHelpClass;
1069 }
1070if ( $this->mCondState ) {
1071 $wrapperAttributes['data-cond-state'] = FormatJson::encode( $this->parseCondStateForClient() );
1072 $wrapperAttributes['class'] = array_merge( $wrapperAttributes['class'], $this->mCondStateClass );
1073 }
1074return Html::rawElement('div', $wrapperAttributes, $helptext );
1075 }
1076
1084publicfunctiongetHelpTextHtmlRaw( $helptext ) {
1085return $this->getHelpTextHtmlDiv( $helptext );
1086 }
1087
1088privatefunction getHelpMessages(): array {
1089if ( isset( $this->mParams['help-message'] ) ) {
1090return [ $this->mParams['help-message'] ];
1091 } elseif ( isset( $this->mParams['help-messages'] ) ) {
1092return $this->mParams['help-messages'];
1093 } elseif ( isset( $this->mParams['help-raw'] ) ) {
1094return [new HtmlArmor( $this->mParams['help-raw'] ) ];
1095 } elseif ( isset( $this->mParams['help'] ) ) {
1096// @deprecated since 1.43, use 'help-raw' key instead
1097return [new HtmlArmor( $this->mParams['help'] ) ];
1098 }
1099
1100return [];
1101 }
1102
1109publicfunctiongetHelpText() {
1110 $html = [];
1111
1112foreach ( $this->getHelpMessages() as $msg ) {
1113if ( $msg instanceofHtmlArmor ) {
1114 $html[] = HtmlArmor::getHtml( $msg );
1115 }else {
1116 $msg = $this->getMessage( $msg );
1117if ( $msg->exists() ) {
1118 $html[] = $msg->parse();
1119 }
1120 }
1121 }
1122
1123return $html ? implode( $this->msg('word-separator' )->escaped(), $html ) :null;
1124 }
1125
1134publicfunctionisHelpInline() {
1135return $this->mParams['help-inline'] ??true;
1136 }
1137
1150publicfunctiongetErrorsAndErrorClass( $value ) {
1151 $errors = $this->validate( $value, $this->mParent->mFieldData );
1152
1153if ( is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
1154return ['','' ];
1155 }
1156
1157return [ self::formatErrors( $errors ),'mw-htmlform-invalid-input' ];
1158 }
1159
1167publicfunctiongetErrorsRaw( $value ) {
1168 $errors = $this->validate( $value, $this->mParent->mFieldData );
1169
1170if ( is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
1171return [];
1172 }
1173
1174if ( !is_array( $errors ) ) {
1175 $errors = [ $errors ];
1176 }
1177foreach ( $errors as &$error ) {
1178if ( $error instanceofMessage ) {
1179 $error = $error->parse();
1180 }
1181 }
1182
1183return $errors;
1184 }
1185
1190publicfunctiongetLabel() {
1191return $this->mLabel ??'';
1192 }
1193
1200publicfunctiongetLabelHtml( $cellAttributes = [] ) {
1201 # Don't output a for= attribute for labels with no associated input.
1202 # Kind of hacky here, possibly we don't want these to be <label>s at all.
1203 $for = $this->needsLabel() ? ['for' => $this->mID ] : [];
1204
1205 $labelValue = trim( $this->getLabel() );
1206 $hasLabel = $labelValue !=='' && $labelValue !=="\u{00A0}" && $labelValue !=='&#160;';
1207
1208 $displayFormat = $this->mParent->getDisplayFormat();
1209 $horizontalLabel = $this->mParams['horizontal-label'] ??false;
1210
1211if ( $displayFormat ==='table' ) {
1212return Html::rawElement('td',
1213 ['class' =>'mw-label' ] + $cellAttributes,
1214 Html::rawElement('label', $for, $labelValue ) );
1215 } elseif ( $hasLabel || $this->mShowEmptyLabels ) {
1216if ( $displayFormat ==='div' && !$horizontalLabel ) {
1217return Html::rawElement('div',
1218 ['class' =>'mw-label' ] + $cellAttributes,
1219 Html::rawElement('label', $for, $labelValue ) );
1220 }else {
1221return Html::rawElement('label', $for, $labelValue );
1222 }
1223 }
1224
1225return'';
1226 }
1227
1232publicfunctiongetDefault() {
1233return $this->mDefault ??null;
1234 }
1235
1241publicfunctiongetTooltipAndAccessKey() {
1242if ( empty( $this->mParams['tooltip'] ) ) {
1243return [];
1244 }
1245
1246return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] );
1247 }
1248
1255if ( empty( $this->mParams['tooltip'] ) ) {
1256return [];
1257 }
1258
1259return [
1260'title' => Linker::titleAttrib( $this->mParams['tooltip'] ),
1261'accessKey' => Linker::accesskey( $this->mParams['tooltip'] ),
1262 ];
1263 }
1264
1272publicfunctiongetAttributes( array $list ) {
1273static $boolAttribs = ['disabled','required','autofocus','multiple','readonly' ];
1274
1275 $ret = [];
1276foreach ( $list as $key ) {
1277if ( in_array( $key, $boolAttribs ) ) {
1278if ( !empty( $this->mParams[$key] ) ) {
1279 $ret[$key] ='';
1280 }
1281 } elseif ( isset( $this->mParams[$key] ) ) {
1282 $ret[$key] = $this->mParams[$key];
1283 }
1284 }
1285
1286return $ret;
1287 }
1288
1298privatefunction lookupOptionsKeys( $options, $needsParse ) {
1299 $ret = [];
1300foreach ( $options as $key => $value ) {
1301 $msg = $this->msg( $key );
1302 $msgAsText = $needsParse ? $msg->parse() : $msg->plain();
1303if ( array_key_exists( $msgAsText, $ret ) ) {
1304 LoggerFactory::getInstance('translation-problem' )->error(
1305'The option that uses the message key {msg_key_one} has the same translation as ' .
1306'another option in {lang}. This means that {msg_key_one} will not be used as an option.',
1307 [
1308'msg_key_one' => $key,
1309'lang' => $this->mParent ?
1310 $this->mParent->getLanguageCode()->toBcp47Code() :
1311RequestContext::getMain()->getLanguageCode()->toBcp47Code(),
1312 ]
1313 );
1314continue;
1315 }
1316 $ret[$msgAsText] = is_array( $value )
1317 ? $this->lookupOptionsKeys( $value, $needsParse )
1318 : strval( $value );
1319 }
1320return $ret;
1321 }
1322
1330publicstaticfunctionforceToStringRecursive( $array ) {
1331if ( is_array( $array ) ) {
1332return array_map( self::forceToStringRecursive( ... ), $array );
1333 }else {
1334return strval( $array );
1335 }
1336 }
1337
1344publicfunctiongetOptions() {
1345if ( $this->mOptions ===false ) {
1346if ( array_key_exists('options-messages', $this->mParams ) ) {
1347 $needsParse = $this->mParams['options-messages-parse'] ??false;
1348if ( $needsParse ) {
1349 $this->mOptionsLabelsNotFromMessage =true;
1350 }
1351 $this->mOptions = $this->lookupOptionsKeys( $this->mParams['options-messages'], $needsParse );
1352 } elseif ( array_key_exists('options', $this->mParams ) ) {
1353 $this->mOptionsLabelsNotFromMessage =true;
1354 $this->mOptions = self::forceToStringRecursive( $this->mParams['options'] );
1355 } elseif ( array_key_exists('options-message', $this->mParams ) ) {
1356 $message = $this->getMessage( $this->mParams['options-message'] )->inContentLanguage()->plain();
1357 $this->mOptions = Html::listDropdownOptions( $message );
1358 }else {
1359 $this->mOptions =null;
1360 }
1361 }
1362
1363return $this->mOptions;
1364 }
1365
1371publicfunctiongetOptionsOOUI() {
1372 $oldoptions = $this->getOptions();
1373
1374if ( $oldoptions ===null ) {
1375returnnull;
1376 }
1377
1378return Html::listDropdownOptionsOoui( $oldoptions );
1379 }
1380
1388publicstaticfunctionflattenOptions( $options ) {
1389 $flatOpts = [];
1390
1391foreach ( $options as $value ) {
1392if ( is_array( $value ) ) {
1393 $flatOpts = array_merge( $flatOpts, self::flattenOptions( $value ) );
1394 }else {
1395 $flatOpts[] = $value;
1396 }
1397 }
1398
1399return $flatOpts;
1400 }
1401
1415protectedstaticfunctionformatErrors( $errors ) {
1416if ( is_array( $errors ) && count( $errors ) === 1 ) {
1417 $errors = array_shift( $errors );
1418 }
1419
1420if ( is_array( $errors ) ) {
1421foreach ( $errors as &$error ) {
1422 $error = Html::rawElement('li', [],
1423 $error instanceofMessage ? $error->parse() : $error
1424 );
1425 }
1426 $errors = Html::rawElement('ul', [], implode("\n", $errors ) );
1427 } elseif ( $errors instanceofMessage ) {
1428 $errors = $errors->parse();
1429 }
1430
1431return Html::errorBox( $errors );
1432 }
1433
1440protectedfunctiongetMessage( $value ) {
1441 $message =Message::newFromSpecifier( $value );
1442
1443if ( $this->mParent ) {
1444 $message->setContext( $this->mParent );
1445 }
1446
1447return $message;
1448 }
1449
1457publicfunctionskipLoadData( $request ) {
1458return !empty( $this->mParams['nodata'] );
1459 }
1460
1469// This is probably more restrictive than it needs to be, but better safe than sorry
1470return (bool)$this->mCondState;
1471 }
1472
1484protectedfunctionescapeLabel( $label ) {
1485return $this->mOptionsLabelsNotFromMessage
1486 ? $label : htmlspecialchars( $label, ENT_NOQUOTES );
1487 }
1488
1500protectedfunctionmakeLabelSnippet( $label ) {
1501return $this->mOptionsLabelsNotFromMessage
1502 ? new \OOUI\HtmlSnippet( $label ) : $label;
1503 }
1504}
1505
1507class_alias( HTMLFormField::class,'HTMLFormField' );
wfDeprecatedMsg
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
DefinitionGlobalFunctions.php:766
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
DefinitionGlobalFunctions.php:820
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
DefinitionGlobalFunctions.php:735
if
if(!defined('MW_SETUP_CALLBACK'))
DefinitionWebStart.php:68
MediaWiki\Context\RequestContext
Group all the pieces relevant to the context of a request into one instance.
DefinitionRequestContext.php:53
MediaWiki\HTMLForm\Field\HTMLCheckField
A checkbox field.
DefinitionHTMLCheckField.php:17
MediaWiki\HTMLForm\Field\HTMLFormFieldCloner
A container for HTMLFormFields that allows for multiple copies of the set of fields to be displayed t...
DefinitionHTMLFormFieldCloner.php:48
MediaWiki\HTMLForm\HTMLFormFieldLayout
DefinitionHTMLFormFieldLayout.php:8
MediaWiki\HTMLForm\HTMLFormField
The parent class to generate form fields.
DefinitionHTMLFormField.php:27
MediaWiki\HTMLForm\HTMLFormField\parseCondStateForClient
parseCondStateForClient()
Parse the cond-state array for client-side.
DefinitionHTMLFormField.php:382
MediaWiki\HTMLForm\HTMLFormField\getTooltipAndAccessKey
getTooltipAndAccessKey()
Returns the attributes required for the tooltip and accesskey, for Html::element() etc.
DefinitionHTMLFormField.php:1241
MediaWiki\HTMLForm\HTMLFormField\getMessage
getMessage( $value)
Turns a *-message parameter (which could be a MessageSpecifier, or a message name,...
DefinitionHTMLFormField.php:1440
MediaWiki\HTMLForm\HTMLFormField\getLabel
getLabel()
DefinitionHTMLFormField.php:1190
MediaWiki\HTMLForm\HTMLFormField\getOptionsOOUI
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.
DefinitionHTMLFormField.php:1371
MediaWiki\HTMLForm\HTMLFormField\$mCondState
array $mCondState
Array to hold params for 'hide-if' or 'disable-if' statements.
DefinitionHTMLFormField.php:63
MediaWiki\HTMLForm\HTMLFormField\getOOUI
getOOUI( $value)
Get the OOUI version of the div.
DefinitionHTMLFormField.php:758
MediaWiki\HTMLForm\HTMLFormField\makeLabelSnippet
makeLabelSnippet( $label)
The keys in the array returned by getOptions() can be either HTML or plain text depending on $this->m...
DefinitionHTMLFormField.php:1500
MediaWiki\HTMLForm\HTMLFormField\getDefault
getDefault()
DefinitionHTMLFormField.php:1232
MediaWiki\HTMLForm\HTMLFormField\$mClass
string $mClass
DefinitionHTMLFormField.php:44
MediaWiki\HTMLForm\HTMLFormField\getName
getName()
Get the field name that will be used for submission.
DefinitionHTMLFormField.php:166
MediaWiki\HTMLForm\HTMLFormField\getNearestFieldValue
getNearestFieldValue( $alldata, $name, $asDisplay=false, $backCompat=false)
Fetch a field value from $alldata for the closest field matching a given name.
DefinitionHTMLFormField.php:211
MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlRaw
getHelpTextHtmlRaw( $helptext)
Generate help text HTML formatted for raw output.
DefinitionHTMLFormField.php:1084
MediaWiki\HTMLForm\HTMLFormField\flattenOptions
static flattenOptions( $options)
flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>...
DefinitionHTMLFormField.php:1388
MediaWiki\HTMLForm\HTMLFormField\getLabelHtml
getLabelHtml( $cellAttributes=[])
DefinitionHTMLFormField.php:1200
MediaWiki\HTMLForm\HTMLFormField\getTooltipAndAccessKeyOOUI
getTooltipAndAccessKeyOOUI()
Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config.
DefinitionHTMLFormField.php:1254
MediaWiki\HTMLForm\HTMLFormField\$mParent
HTMLForm null $mParent
DefinitionHTMLFormField.php:76
MediaWiki\HTMLForm\HTMLFormField\getNearestFieldByName
getNearestFieldByName( $alldata, $name, $asDisplay=false)
Fetch a field value from $alldata for the closest field matching a given name.
DefinitionHTMLFormField.php:242
MediaWiki\HTMLForm\HTMLFormField\$mShowEmptyLabels
bool $mShowEmptyLabels
If true will generate an empty div element with no label.
DefinitionHTMLFormField.php:71
MediaWiki\HTMLForm\HTMLFormField\getErrorsAndErrorClass
getErrorsAndErrorClass( $value)
Determine form errors to display and their classes.
DefinitionHTMLFormField.php:1150
MediaWiki\HTMLForm\HTMLFormField\$mOptionsLabelsNotFromMessage
bool $mOptionsLabelsNotFromMessage
DefinitionHTMLFormField.php:59
MediaWiki\HTMLForm\HTMLFormField\isHidden
isHidden( $alldata)
Test whether this field is supposed to be hidden, based on the values of the other form fields.
DefinitionHTMLFormField.php:398
MediaWiki\HTMLForm\HTMLFormField\isHelpInline
isHelpInline()
Determine if the help text should be displayed inline.
DefinitionHTMLFormField.php:1134
MediaWiki\HTMLForm\HTMLFormField\getOOUIModules
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
DefinitionHTMLFormField.php:968
MediaWiki\HTMLForm\HTMLFormField\$mParams
array array[] $mParams
DefinitionHTMLFormField.php:29
MediaWiki\HTMLForm\HTMLFormField\filter
filter( $value, $alldata)
DefinitionHTMLFormField.php:480
MediaWiki\HTMLForm\HTMLFormField\loadDataFromRequest
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
DefinitionHTMLFormField.php:538
MediaWiki\HTMLForm\HTMLFormField\$mOptions
array null false $mOptions
DefinitionHTMLFormField.php:57
MediaWiki\HTMLForm\HTMLFormField\$mVFormClass
string $mVFormClass
DefinitionHTMLFormField.php:46
MediaWiki\HTMLForm\HTMLFormField\__construct
__construct( $params)
Initialise the object.
DefinitionHTMLFormField.php:554
MediaWiki\HTMLForm\HTMLFormField\$mID
string $mID
DefinitionHTMLFormField.php:42
MediaWiki\HTMLForm\HTMLFormField\getClassName
getClassName()
Gets the non namespaced class name.
DefinitionHTMLFormField.php:924
MediaWiki\HTMLForm\HTMLFormField\$mCondStateClass
array $mCondStateClass
DefinitionHTMLFormField.php:65
MediaWiki\HTMLForm\HTMLFormField\skipLoadData
skipLoadData( $request)
Skip this field when collecting data.
DefinitionHTMLFormField.php:1457
MediaWiki\HTMLForm\HTMLFormField\forceToStringRecursive
static forceToStringRecursive( $array)
Recursively forces values in an array to strings, because issues arise with integer 0 as a value.
DefinitionHTMLFormField.php:1330
MediaWiki\HTMLForm\HTMLFormField\hasVisibleOutput
hasVisibleOutput()
If this field has a user-visible output or not.
DefinitionHTMLFormField.php:156
MediaWiki\HTMLForm\HTMLFormField\getLabelAlignOOUI
getLabelAlignOOUI()
Get label alignment when generating field for OOUI.
DefinitionHTMLFormField.php:934
MediaWiki\HTMLForm\HTMLFormField\validateCondState
validateCondState( $params)
Validate the cond-state params, the existence check of fields should be done later.
DefinitionHTMLFormField.php:252
MediaWiki\HTMLForm\HTMLFormField\needsLabel
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
DefinitionHTMLFormField.php:495
MediaWiki\HTMLForm\HTMLFormField\getOptions
getOptions()
Fetch the array of options from the field's parameters.
DefinitionHTMLFormField.php:1344
MediaWiki\HTMLForm\HTMLFormField\cancelSubmit
cancelSubmit( $value, $alldata)
Override this function if the control can somehow trigger a form submission that shouldn't actually s...
DefinitionHTMLFormField.php:429
MediaWiki\HTMLForm\HTMLFormField\getDiv
getDiv( $value)
Get the complete div for the input, including help text, labels, and whatever.
DefinitionHTMLFormField.php:706
MediaWiki\HTMLForm\HTMLFormField\getAttributes
getAttributes(array $list)
Returns the given attributes from the parameters.
DefinitionHTMLFormField.php:1272
MediaWiki\HTMLForm\HTMLFormField\getFieldLayoutOOUI
getFieldLayoutOOUI( $inputField, $config)
Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
DefinitionHTMLFormField.php:944
MediaWiki\HTMLForm\HTMLFormField\getHelpText
getHelpText()
Determine the help text to display.
DefinitionHTMLFormField.php:1109
MediaWiki\HTMLForm\HTMLFormField\$mName
string $mName
DefinitionHTMLFormField.php:36
MediaWiki\HTMLForm\HTMLFormField\getCodex
getCodex( $value)
Get the Codex version of the div.
DefinitionHTMLFormField.php:841
MediaWiki\HTMLForm\HTMLFormField\parseCondState
parseCondState( $params)
Parse the cond-state array to use the field name for submission, since the key in the form descriptor...
DefinitionHTMLFormField.php:351
MediaWiki\HTMLForm\HTMLFormField\getNearestField
getNearestField( $name, $backCompat=false)
Get the closest field matching a given name.
DefinitionHTMLFormField.php:181
MediaWiki\HTMLForm\HTMLFormField\getTableRow
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
DefinitionHTMLFormField.php:645
MediaWiki\HTMLForm\HTMLFormField\msg
msg( $key,... $params)
Get a translated interface message.
DefinitionHTMLFormField.php:142
MediaWiki\HTMLForm\HTMLFormField\getRaw
getRaw( $value)
Get the complete raw fields for the input, including help text, labels, and whatever.
DefinitionHTMLFormField.php:982
MediaWiki\HTMLForm\HTMLFormField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
MediaWiki\HTMLForm\HTMLFormField\getErrorsRaw
getErrorsRaw( $value)
Determine form errors to display, returning them in an array.
DefinitionHTMLFormField.php:1167
MediaWiki\HTMLForm\HTMLFormField\shouldInfuseOOUI
shouldInfuseOOUI()
Whether the field should be automatically infused.
DefinitionHTMLFormField.php:956
MediaWiki\HTMLForm\HTMLFormField\$mHelpClass
string false $mHelpClass
DefinitionHTMLFormField.php:48
MediaWiki\HTMLForm\HTMLFormField\needsJSForHtml5FormValidation
needsJSForHtml5FormValidation()
Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5 form ...
DefinitionHTMLFormField.php:1468
MediaWiki\HTMLForm\HTMLFormField\canDisplayErrors
canDisplayErrors()
True if this field type is able to display errors; false if validation errors need to be displayed in...
DefinitionHTMLFormField.php:124
MediaWiki\HTMLForm\HTMLFormField\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
DefinitionHTMLFormField.php:98
MediaWiki\HTMLForm\HTMLFormField\isSubmitAttempt
isSubmitAttempt(WebRequest $request)
Can we assume that the request is an attempt to submit a HTMLForm, as opposed to an attempt to just v...
DefinitionHTMLFormField.php:523
MediaWiki\HTMLForm\HTMLFormField\$mLabel
string $mLabel
String label, as HTML.
DefinitionHTMLFormField.php:40
MediaWiki\HTMLForm\HTMLFormField\getInputCodex
getInputCodex( $value, $hasErrors)
Same as getInputHTML, but for Codex.
DefinitionHTMLFormField.php:113
MediaWiki\HTMLForm\HTMLFormField\isDisabled
isDisabled( $alldata)
Test whether this field is supposed to be disabled, based on the values of the other form fields.
DefinitionHTMLFormField.php:411
MediaWiki\HTMLForm\HTMLFormField\validate
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
DefinitionHTMLFormField.php:445
MediaWiki\HTMLForm\HTMLFormField\escapeLabel
escapeLabel( $label)
The keys in the array returned by getOptions() can be either HTML or plain text depending on $this->m...
DefinitionHTMLFormField.php:1484
MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse
checkStateRecurse(array $alldata, array $params)
Helper function for isHidden and isDisabled to handle recursive data structures.
DefinitionHTMLFormField.php:307
MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlDiv
getHelpTextHtmlDiv( $helptext, $cssClasses=[])
Generate help text HTML in div format.
DefinitionHTMLFormField.php:1059
MediaWiki\HTMLForm\HTMLFormField\getVForm
getVForm( $value)
Get the complete field for the input, including help text, labels, and whatever.
DefinitionHTMLFormField.php:1000
MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlTable
getHelpTextHtmlTable( $helptext)
Generate help text HTML in table format.
DefinitionHTMLFormField.php:1030
MediaWiki\HTMLForm\HTMLFormField\formatErrors
static formatErrors( $errors)
Formats one or more errors as accepted by field validation-callback.
DefinitionHTMLFormField.php:1415
MediaWiki\HTMLForm\HTMLFormField\setShowEmptyLabel
setShowEmptyLabel( $show)
Tell the field whether to generate a separate label element if its label is blank.
DefinitionHTMLFormField.php:508
MediaWiki\HTMLForm\HTMLFormField\$mDefault
mixed $mDefault
DefinitionHTMLFormField.php:50
MediaWiki\HTMLForm\HTMLFormField\getInline
getInline( $value)
Get the complete field as an inline element.
DefinitionHTMLFormField.php:1014
MediaWiki\HTMLForm\HTMLFormField\$mDir
string $mDir
DefinitionHTMLFormField.php:38
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
DefinitionHTMLForm.php:195
MediaWiki\Html\Html
This class is a collection of static functions that serve two purposes:
DefinitionHtml.php:43
MediaWiki\Json\FormatJson
JSON formatter wrapper class.
DefinitionFormatJson.php:16
MediaWiki\Linker\Linker
Some internal bits split of from Skin.php.
DefinitionLinker.php:47
MediaWiki\Logger\LoggerFactory
Create PSR-3 logger objects.
DefinitionLoggerFactory.php:32
MediaWiki\Message\Message
The Message class deals with fetching and processing of interface message into a variety of formats.
DefinitionMessage.php:144
MediaWiki\Message\Message\newFromSpecifier
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
DefinitionMessage.php:492
MediaWiki\Message\Message\parse
parse()
Fully parse the text from wikitext to HTML.
DefinitionMessage.php:1122
MediaWiki\Request\WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
DefinitionWebRequest.php:40
MediaWiki\Request\WebRequest\wasPosted
wasPosted()
Returns true if the present request was reached by a POST operation, false otherwise (GET,...
DefinitionWebRequest.php:832
MediaWiki\Request\WebRequest\getCheck
getCheck( $name)
Return true if the named value is set in this web request's $_GET, $_POST or path router vars,...
DefinitionWebRequest.php:696
MediaWiki\Status\Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
DefinitionStatus.php:44
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
DefinitionStatusValue.php:41
Wikimedia\HtmlArmor\HtmlArmor
Marks HTML that shouldn't be escaped.
DefinitionHtmlArmor.php:18
Wikimedia\Message\MessageParam
Value object representing a message parameter that consists of a list of values.
DefinitionMessageParam.php:14
Wikimedia\Message\MessageSpecifier
DefinitionMessageSpecifier.php:12
MediaWiki\HTMLForm
DefinitionCodexHTMLForm.php:10

[8]ページ先頭

©2009-2025 Movatter.jp