49 $this->uniqueId = static::class . ++self::$counter .
'x';
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' ) {
343 $html = Html::rawElement(
'table',
345 Html::rawElement(
'tbody', [],
"\n$html\n" ) ) .
"\n";
353 if ( !empty( $this->mParams[
'row-legend'] ) ) {
354 $legend = $this->
msg( $this->mParams[
'row-legend'] )->text();
364 foreach ( (array)$values as $key =>
$value ) {
365 if ( $key ===
'nonjs' ) {
368 $html .= Html::rawElement(
'li', [
'class' =>
'mw-htmlform-cloner-li' ],
374 $html = Html::rawElement(
'ul', [
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...
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
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
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
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
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
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
Allows to change the fields on the form that will be generated $name
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