MediaWiki  master
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 static function loadInputFromParameters( $fieldname, $descriptor,
42  ) {
43  $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
44  $field->setShowEmptyLabel( false );
45  return $field;
46  }
47 
48  public function getHTML( $submitResult ) {
49  // This is required for VForm HTMLForms that use that style regardless
50  // of wgUseMediaWikiUIEverywhere (since they pre-date it).
51  // When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
52  // with the addModuleStyles in SpecialPage->setHeaders.
53  $this->getOutput()->addModuleStyles( [
54  'mediawiki.ui',
55  'mediawiki.ui.button',
56  'mediawiki.ui.input',
57  'mediawiki.ui.checkbox',
58  ] );
59 
60  return parent::getHTML( $submitResult );
61  }
62 
63  protected function getFormAttributes() {
64  $attribs = parent::getFormAttributes();
65  $attribs['class'] = [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ];
66  return $attribs;
67  }
68 
69  public function wrapForm( $html ) {
70  // Always discard $this->mWrapperLegend
71  return Html::rawElement( 'form', $this->getFormAttributes(), $html );
72  }
73 
74  public function getButtons() {
75  $buttons = '';
76 
77  if ( $this->mShowSubmit ) {
78  $attribs = [];
79 
80  if ( isset( $this->mSubmitID ) ) {
81  $attribs['id'] = $this->mSubmitID;
82  }
83 
84  if ( isset( $this->mSubmitName ) ) {
85  $attribs['name'] = $this->mSubmitName;
86  }
87 
88  if ( isset( $this->mSubmitTooltip ) ) {
89  $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
90  }
91 
92  $attribs['class'] = [
93  'mw-htmlform-submit',
94  'mw-ui-button mw-ui-big mw-ui-block',
95  ];
96  foreach ( $this->mSubmitFlags as $flag ) {
97  $attribs['class'][] = 'mw-ui-' . $flag;
98  }
99 
100  $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
101  }
102 
103  if ( $this->mShowReset ) {
104  $buttons .= Html::element(
105  'input',
106  [
107  'type' => 'reset',
108  'value' => $this->msg( 'htmlform-reset' )->text(),
109  'class' => 'mw-ui-button mw-ui-big mw-ui-block',
110  ]
111  ) . "\n";
112  }
113 
114  if ( $this->mShowCancel ) {
115  $target = $this->mCancelTarget ?: Title::newMainPage();
116  if ( $target instanceof Title ) {
117  $target = $target->getLocalURL();
118  }
119  $buttons .= Html::element(
120  'a',
121  [
122  'class' => 'mw-ui-button mw-ui-big mw-ui-block',
123  'href' => $target,
124  ],
125  $this->msg( 'cancel' )->text()
126  ) . "\n";
127  }
128 
129  foreach ( $this->mButtons as $button ) {
130  $attrs = [
131  'type' => 'submit',
132  'name' => $button['name'],
133  'value' => $button['value']
134  ];
135 
136  if ( $button['attribs'] ) {
137  $attrs += $button['attribs'];
138  }
139 
140  if ( isset( $button['id'] ) ) {
141  $attrs['id'] = $button['id'];
142  }
143 
144  $attrs['class'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : [];
145  $attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block';
146 
147  $buttons .= Html::element( 'input', $attrs ) . "\n";
148  }
149 
150  if ( !$buttons ) {
151  return '';
152  }
153 
154  return Html::rawElement( 'div',
155  [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";
156  }
157 }
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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:1982
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
Definition: Title.php:653
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
string $displayFormat
Symbolic display format name.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
getHTML( $submitResult)
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:1982
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
getSubmitText()
Get the text for the submit button, either customised or a default.
Definition: HTMLForm.php:1411
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.
$parent
Definition: pageupdater.txt:71
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
wrapForm( $html)
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2144