49 $this->uniqueId = get_class( $this ) . ++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'] + [
62 unset( $info[
'name'], $info[
'class'] );
64 if ( !isset( $info[
'type'] ) || $info[
'type'] !==
'submit' ) {
66 'HTMLFormFieldCloner delete field, if specified, must be of type "submit"'
70 if ( !in_array( $class, explode(
' ', $info[
'cssclass'] ) ) ) {
71 $info[
'cssclass'] .=
" $class";
74 $this->mParams[
'fields'][
'delete'] = $info;
87 foreach ( $this->mParams[
'fields']
as $fieldname => $info ) {
88 $name =
"{$this->mName}[$key][$fieldname]";
89 if ( isset( $info[
'name'] ) ) {
90 $info[
'name'] =
"{$this->mName}[$key][{$info['name']}]";
92 $info[
'name'] =
$name;
94 if ( isset( $info[
'id'] ) ) {
100 $fields[$fieldname] = $field;
115 foreach ( $values
as $fieldname =>
$value ) {
116 $name =
"{$this->mName}[$key][$fieldname]";
129 if ( !
$request->getCheck(
'wpEditToken' ) &&
$request->getArray( $this->mName ) === null ) {
133 $values =
$request->getArray( $this->mName );
134 if ( $values === null ) {
140 if (
$key ===
'create' || isset(
$value[
'delete'] ) ) {
152 foreach ( $fields
as $fieldname => $field ) {
153 if ( $field->skipLoadData( $subrequest ) ) {
155 } elseif ( !empty( $field->mParams[
'disabled'] ) ) {
156 $row[$fieldname] = $field->getDefault();
158 $row[$fieldname] = $field->loadDataFromRequest( $subrequest );
164 if ( isset( $values[
'create'] ) ) {
168 foreach ( $fields
as $fieldname => $field ) {
169 if ( !empty( $field->mParams[
'nodata'] ) ) {
172 $row[$fieldname] = $field->getDefault();
182 $ret = parent::getDefault();
186 if (
$ret === null ) {
189 foreach ( $fields
as $fieldname => $field ) {
190 if ( !empty( $field->mParams[
'nodata'] ) ) {
193 $row[$fieldname] = $field->getDefault();
203 if ( isset( $values[
'nonjs'] ) ) {
209 foreach ( $fields
as $fieldname => $field ) {
210 if ( !array_key_exists( $fieldname,
$value ) ) {
213 if ( $field->cancelSubmit(
$value[$fieldname], $alldata ) ) {
219 return parent::cancelSubmit( $values, $alldata );
223 if ( isset( $this->mParams[
'required'] )
224 && $this->mParams[
'required'] !==
false
227 return $this->
msg(
'htmlform-cloner-required' )->parseAsBlock();
230 if ( isset( $values[
'nonjs'] ) ) {
239 foreach ( $fields
as $fieldname => $field ) {
240 if ( !array_key_exists( $fieldname,
$value ) ) {
243 $ok = $field->validate(
$value[$fieldname], $alldata );
244 if ( $ok !==
true ) {
250 return parent::validate( $values, $alldata );
261 $displayFormat = isset( $this->mParams[
'format'] )
262 ? $this->mParams[
'format']
263 : $this->mParent->getDisplayFormat();
266 $getFieldHtmlMethod = $displayFormat ==
'table' ?
'getTableRow' : (
'get' . $displayFormat );
273 foreach ( $fields
as $fieldname => $field ) {
274 $v = array_key_exists( $fieldname, $values )
275 ? $values[$fieldname]
276 : $field->getDefault();
283 $html .= $field->$getFieldHtmlMethod( $v );
285 $labelValue = trim( $field->getLabel() );
286 if ( $labelValue !=
' ' && $labelValue !==
'' ) {
292 if ( !isset( $fields[
'delete'] ) ) {
293 $name =
"{$this->mName}[$key][delete]";
294 $label = isset( $this->mParams[
'delete-button-message'] )
295 ? $this->mParams[
'delete-button-message']
296 :
'htmlform-cloner-delete';
301 'cssclass' =>
'mw-htmlform-cloner-delete-button',
304 $v = $field->getDefault();
306 if ( $displayFormat ===
'table' ) {
307 $html .= $field->$getFieldHtmlMethod( $v );
309 $html .= $field->getInputHTML( $v );
313 if ( $displayFormat !==
'raw' ) {
315 'mw-htmlform-cloner-row',
319 $classes[] =
'mw-htmlform-nolabel';
323 'class' => implode(
' ', $classes ),
326 if ( $displayFormat ===
'table' ) {
337 if ( !empty( $this->mParams[
'row-legend'] ) ) {
338 $legend = $this->
msg( $this->mParams[
'row-legend'] )->text();
349 if (
$key ===
'nonjs' ) {
359 'id' =>
"mw-htmlform-cloner-list-{$this->mID}",
360 'class' =>
'mw-htmlform-cloner-ul',
362 'data-unique-id' => $this->uniqueId,
365 $name =
"{$this->mName}[create]";
366 $label = isset( $this->mParams[
'create-button-message'] )
367 ? $this->mParams[
'create-button-message']
368 :
'htmlform-cloner-create';
373 'cssclass' =>
'mw-htmlform-cloner-create-button',
376 $html .= $field->getInputHTML( $field->getDefault() );
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
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
the array() calling protocol came about after MediaWiki 1.4rc1.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
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
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
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
static fieldset($legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
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
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 escapeId($id, $options=[])
Given a value, escape it so that it can be used in an id attribute and return it. ...
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
error also a ContextSource you ll probably need to make sure the header is varied on $request
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
Allows to change the fields on the form that will be generated $name