MediaWiki  1.28.0
VFormHTMLForm.php
Go to the documentation of this file.
1 <?php
2 
27 class VFormHTMLForm extends HTMLForm {
32  protected $mWrapperLegend = false;
33 
38  protected $displayFormat = 'vform';
39 
40  public function isVForm() {
41  wfDeprecated( __METHOD__, '1.25' );
42  return true;
43  }
44 
45  public static function loadInputFromParameters( $fieldname, $descriptor,
46  HTMLForm $parent = null
47  ) {
48  $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
49  $field->setShowEmptyLabel( false );
50  return $field;
51  }
52 
53  function getHTML( $submitResult ) {
54  // This is required for VForm HTMLForms that use that style regardless
55  // of wgUseMediaWikiUIEverywhere (since they pre-date it).
56  // When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
57  // with the addModuleStyles in SpecialPage->setHeaders.
58  $this->getOutput()->addModuleStyles( [
59  'mediawiki.ui',
60  'mediawiki.ui.button',
61  'mediawiki.ui.input',
62  'mediawiki.ui.checkbox',
63  ] );
64 
65  return parent::getHTML( $submitResult );
66  }
67 
68  protected function getFormAttributes() {
69  $attribs = parent::getFormAttributes();
70  $attribs['class'] = [ 'mw-ui-vform', 'mw-ui-container', 'visualClear' ];
71  return $attribs;
72  }
73 
74  function wrapForm( $html ) {
75  // Always discard $this->mWrapperLegend
76  return Html::rawElement( 'form', $this->getFormAttributes(), $html );
77  }
78 
79  function getButtons() {
80  $buttons = '';
81 
82  if ( $this->mShowSubmit ) {
83  $attribs = [];
84 
85  if ( isset( $this->mSubmitID ) ) {
86  $attribs['id'] = $this->mSubmitID;
87  }
88 
89  if ( isset( $this->mSubmitName ) ) {
90  $attribs['name'] = $this->mSubmitName;
91  }
92 
93  if ( isset( $this->mSubmitTooltip ) ) {
94  $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
95  }
96 
97  $attribs['class'] = [
98  'mw-htmlform-submit',
99  'mw-ui-button mw-ui-big mw-ui-block',
100  ];
101  foreach ( $this->mSubmitFlags as $flag ) {
102  $attribs['class'][] = 'mw-ui-' . $flag;
103  }
104 
105  $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
106  }
107 
108  if ( $this->mShowReset ) {
109  $buttons .= Html::element(
110  'input',
111  [
112  'type' => 'reset',
113  'value' => $this->msg( 'htmlform-reset' )->text(),
114  'class' => 'mw-ui-button mw-ui-big mw-ui-block',
115  ]
116  ) . "\n";
117  }
118 
119  if ( $this->mShowCancel ) {
120  $target = $this->mCancelTarget ?: Title::newMainPage();
121  if ( $target instanceof Title ) {
122  $target = $target->getLocalURL();
123  }
124  $buttons .= Html::element(
125  'a',
126  [
127  'class' => 'mw-ui-button mw-ui-big mw-ui-block',
128  'href' => $target,
129  ],
130  $this->msg( 'cancel' )->text()
131  ) . "\n";
132  }
133 
134  foreach ( $this->mButtons as $button ) {
135  $attrs = [
136  'type' => 'submit',
137  'name' => $button['name'],
138  'value' => $button['value']
139  ];
140 
141  if ( $button['attribs'] ) {
142  $attrs += $button['attribs'];
143  }
144 
145  if ( isset( $button['id'] ) ) {
146  $attrs['id'] = $button['id'];
147  }
148 
149  $attrs['class'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : [];
150  $attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block';
151 
152  $buttons .= Html::element( 'input', $attrs ) . "\n";
153  }
154 
155  if ( !$buttons ) {
156  return '';
157  }
158 
159  return Html::rawElement( 'div',
160  [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";
161  }
162 }
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1936
the array() calling protocol came about after MediaWiki 1.4rc1.
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:556
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:209
static tooltipAndAccesskeyAttribs($name, array $msgParams=[])
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2182
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
msg()
Get a Message object with context set Parameters are the same as wfMessage()
string $displayFormat
Symbolic display format name.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
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
Definition: hooks.txt:1936
Object handling generic submission, CSRF protection, layout and other logic for UI forms...
Definition: HTMLForm.php:128
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
getSubmitText()
Get the text for the submit button, either customised or a default.
Definition: HTMLForm.php:1361
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Compact stacked vertical format for forms.
static loadInputFromParameters($fieldname, $descriptor, HTMLForm $parent=null)
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:229
getHTML($submitResult)
getOutput()
Get the OutputPage object.