Go to the documentation of this file.
52 if ( empty( $this->mParams[
'fields'] ) || !is_array( $this->mParams[
'fields'] ) ) {
53 throw new MWException(
'HTMLFormFieldCloner called without any fields' );
57 if ( isset( $this->mParams[
'fields'][
'delete'] ) ) {
58 $class =
'mw-htmlform-cloner-delete-button';
59 $info = $this->mParams[
'fields'][
'delete'] + [
60 'formnovalidate' =>
true,
63 unset( $info[
'name'], $info[
'class'] );
65 if ( !isset( $info[
'type'] ) || $info[
'type'] !==
'submit' ) {
67 'HTMLFormFieldCloner delete field, if specified, must be of type "submit"'
71 if ( !in_array( $class, explode(
' ', $info[
'cssclass'] ) ) ) {
72 $info[
'cssclass'] .=
" $class";
75 $this->mParams[
'fields'][
'delete'] = $info;
88 foreach ( $this->mParams[
'fields']
as $fieldname => $info ) {
89 $name =
"{$this->mName}[$key][$fieldname]";
90 if ( isset( $info[
'name'] ) ) {
91 $info[
'name'] =
"{$this->mName}[$key][{$info['name']}]";
93 $info[
'name'] =
$name;
95 if ( isset( $info[
'id'] ) ) {
96 $info[
'id'] = Sanitizer::escapeIdForAttribute(
"{$this->mID}--$key--{$info['id']}" );
98 $info[
'id'] = Sanitizer::escapeIdForAttribute(
"{$this->mID}--$key--$fieldname" );
102 if ( $this->mHideIf ) {
103 if ( isset( $info[
'hide-if'] ) ) {
112 $fields[$fieldname] = $field;
127 foreach ( $values
as $fieldname =>
$value ) {
128 $name =
"{$this->mName}[$key][$fieldname]";
141 if ( !
$request->getCheck(
'wpEditToken' ) &&
$request->getArray( $this->mName ) === null ) {
145 $values =
$request->getArray( $this->mName );
146 if ( $values ===
null ) {
151 foreach ( $values
as $key =>
$value ) {
152 if ( $key ===
'create' || isset(
$value[
'delete'] ) ) {
164 foreach ( $fields
as $fieldname => $field ) {
165 if ( $field->skipLoadData( $subrequest ) ) {
167 } elseif ( !empty( $field->mParams[
'disabled'] ) ) {
168 $row[$fieldname] = $field->getDefault();
170 $row[$fieldname] = $field->loadDataFromRequest( $subrequest );
176 if ( isset( $values[
'create'] ) ) {
180 foreach ( $fields
as $fieldname => $field ) {
181 if ( !empty( $field->mParams[
'nodata'] ) ) {
184 $row[$fieldname] = $field->getDefault();
194 $ret = parent::getDefault();
198 if (
$ret ===
null ) {
201 foreach ( $fields
as $fieldname => $field ) {
202 if ( !empty( $field->mParams[
'nodata'] ) ) {
205 $row[$fieldname] = $field->getDefault();
215 if ( isset( $values[
'nonjs'] ) ) {
219 foreach ( $values
as $key =>
$value ) {
221 foreach ( $fields
as $fieldname => $field ) {
222 if ( !array_key_exists( $fieldname,
$value ) ) {
225 if ( $field->cancelSubmit(
$value[$fieldname], $alldata ) ) {
231 return parent::cancelSubmit( $values, $alldata );
235 if ( isset( $this->mParams[
'required'] )
236 && $this->mParams[
'required'] !==
false
239 return $this->
msg(
'htmlform-cloner-required' );
242 if ( isset( $values[
'nonjs'] ) ) {
249 foreach ( $values
as $key =>
$value ) {
251 foreach ( $fields
as $fieldname => $field ) {
252 if ( !array_key_exists( $fieldname,
$value ) ) {
255 if ( $field->isHidden( $alldata ) ) {
258 $ok = $field->validate(
$value[$fieldname], $alldata );
259 if ( $ok !==
true ) {
265 return parent::validate( $values, $alldata );
276 $displayFormat = isset( $this->mParams[
'format'] )
277 ? $this->mParams[
'format']
278 : $this->mParent->getDisplayFormat();
281 $getFieldHtmlMethod = $displayFormat ==
'table' ?
'getTableRow' : (
'get' . $displayFormat );
288 foreach ( $fields
as $fieldname => $field ) {
289 $v = array_key_exists( $fieldname, $values )
290 ? $values[$fieldname]
291 : $field->getDefault();
298 $html .= $field->$getFieldHtmlMethod( $v );
300 $labelValue = trim( $field->getLabel() );
301 if ( $labelValue !=
' ' && $labelValue !==
'' ) {
307 if ( !isset( $fields[
'delete'] ) ) {
308 $name =
"{$this->mName}[$key][delete]";
309 $label = isset( $this->mParams[
'delete-button-message'] )
310 ? $this->mParams[
'delete-button-message']
311 :
'htmlform-cloner-delete';
314 'formnovalidate' =>
true,
316 'id' => Sanitizer::escapeIdForAttribute(
"{$this->mID}--$key--delete" ),
317 'cssclass' =>
'mw-htmlform-cloner-delete-button',
320 $v = $field->getDefault();
322 if ( $displayFormat ===
'table' ) {
323 $html .= $field->$getFieldHtmlMethod( $v );
325 $html .= $field->getInputHTML( $v );
329 if ( $displayFormat !==
'raw' ) {
331 'mw-htmlform-cloner-row',
335 $classes[] =
'mw-htmlform-nolabel';
339 'class' => implode(
' ', $classes ),
342 if ( $displayFormat ===
'table' ) {
353 if ( !empty( $this->mParams[
'row-legend'] ) ) {
354 $legend = $this->
msg( $this->mParams[
'row-legend'] )->text();
365 if ( $key ===
'nonjs' ) {
375 'id' =>
"mw-htmlform-cloner-list-{$this->mID}",
376 'class' =>
'mw-htmlform-cloner-ul',
378 'data-unique-id' => $this->uniqueId,
381 $name =
"{$this->mName}[create]";
382 $label = isset( $this->mParams[
'create-button-message'] )
383 ? $this->mParams[
'create-button-message']
384 :
'htmlform-cloner-create';
387 'formnovalidate' =>
true,
389 'id' => Sanitizer::escapeIdForAttribute(
"{$this->mID}--create" ),
390 'cssclass' =>
'mw-htmlform-cloner-create-button',
393 $html .= $field->getInputHTML( $field->getDefault() );
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
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
Allows to change the fields on the form that will be generated $name
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
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
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 & $ret
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
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
the array() calling protocol came about after MediaWiki 1.4rc1.