14 protected $mLabel; # String label, as HTML. Set on construction.
80 public function msg() {
83 if ( $this->mParent ) {
84 return $this->mParent->msg( ...
$args );
115 while (
preg_match(
'/^(.+)\[([^\]]+)\]$/', $tmp, $m ) ) {
119 if (
substr( $tmp, 0, 2 ) ==
'wp' &&
130 while (
preg_match(
'/^(.+)\[([^\]]+)\]$/', $tmp, $m ) ) {
137 for ( $i = count( $thisKeys ) - 1; $i >= 0; $i-- ) {
140 foreach (
$keys as $key ) {
168 foreach (
$params as $i => $p ) {
171 "Expected array, found " .
gettype( $p ) .
" at index $i"
181 foreach (
$params as $i => $p ) {
184 "Expected array, found " .
gettype( $p ) .
" at index $i"
194 foreach (
$params as $i => $p ) {
197 "Expected array, found " .
gettype( $p ) .
" at index $i"
207 foreach (
$params as $i => $p ) {
210 "Expected array, found " .
gettype( $p ) .
" at index $i"
220 if ( count(
$params ) !== 1 ) {
221 throw new MWException(
"NOT takes exactly one parameter" );
226 "Expected array, found " .
gettype( $p ) .
" at index 0"
233 if ( count(
$params ) !== 2 ) {
234 throw new MWException(
"$op takes exactly two parameters" );
238 throw new MWException(
"Parameters for $op must be strings" );
243 return (
$value === $testValue );
245 return (
$value !== $testValue );
251 }
catch ( Exception $ex ) {
253 "Invalid hide-if specification for $this->mName: " .
254 $ex->getMessage() .
" in " . var_export( $origParams,
true ),
269 if ( !$this->mHideIf ) {
302 if ( $this->
isHidden( $alldata ) ) {
306 if (
isset( $this->mParams[
'required'] )
307 && $this->mParams[
'required'] !==
false
310 return $this->
msg(
'htmlform-required' );
313 if (
isset( $this->mValidationCallback ) ) {
314 return ( $this->mValidationCallback )(
$value,
$alldata, $this->mParent );
321 if (
isset( $this->mFilterCallback ) ) {
322 $value = ( $this->mFilterCallback )(
$value, $alldata, $this->mParent );
348 $this->mShowEmptyLabels =
$show;
362 return $request->getCheck(
'wpEditToken' ) ||
$request->getCheck(
'wpFormIdentifier' );
373 if (
$request->getCheck( $this->mName ) ) {
374 return $request->getText( $this->mName );
392 $this->mParent =
$params[
'parent'];
395 # Generate the label from a message, if possible
399 if (
$params[
'label'] ===
' ' ||
$params[
'label'] ===
"\u{00A0}" ) {
401 $this->mLabel =
"\u{00A0}";
406 $this->mLabel =
$params[
'label-raw'];
409 $this->mName =
"wp{$params['fieldname']}";
411 $this->mName =
$params[
'name'];
418 $validName = urlencode( $this->mName );
419 $validName =
str_replace( [
'%5B',
'%5D' ], [
'[',
']' ], $validName );
420 if ( $this->mName != $validName && !
isset(
$params[
'nodata'] ) ) {
421 throw new MWException(
"Invalid name '{$this->mName}' passed to " . __METHOD__ );
424 $this->mID =
"mw-input-{$this->mName}";
427 $this->mDefault =
$params[
'default'];
432 $validId = urlencode( $id );
434 if ( $id != $validId ) {
435 throw new MWException(
"Invalid id '$id' passed to " . __METHOD__ );
442 $this->mClass =
$params[
'cssclass'];
446 $this->mHelpClass =
$params[
'csshelpclass'];
450 $this->mValidationCallback =
$params[
'validation-callback'];
454 $this->mFilterCallback =
$params[
'filter-callback'];
458 $this->mShowEmptyLabels =
false;
462 $this->mHideIf =
$params[
'hide-if'];
477 $fieldType = static::class;
479 $cellAttributes = [];
483 if ( !empty( $this->mParams[
'vertical-label'] ) ) {
484 $cellAttributes[
'colspan'] = 2;
485 $verticalLabel =
true;
487 $verticalLabel =
false;
492 $field = Html::rawElement(
494 [
'class' =>
'mw-input' ] + $cellAttributes,
495 $inputHtml .
"\n$errors"
498 if ( $this->mHideIf ) {
499 $rowAttributes[
'data-hide-if'] = FormatJson::encode( $this->mHideIf );
500 $rowClasses .=
' mw-htmlform-hide-if';
503 if ( $verticalLabel ) {
504 $html = Html::rawElement(
'tr',
505 $rowAttributes + [
'class' =>
"mw-htmlform-vertical-label $rowClasses" ], $label );
506 $html .= Html::rawElement(
'tr',
508 'class' =>
"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses"
513 Html::rawElement(
'tr',
515 'class' =>
"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses"
535 $fieldType = static::class;
537 $cellAttributes = [];
542 'mw-htmlform-nolabel' => ( $label ===
'' )
545 $horizontalLabel = $this->mParams[
'horizontal-label'] ??
false;
547 if ( $horizontalLabel ) {
548 $field =
"\u{00A0}" . $inputHtml .
"\n$errors";
550 $field = Html::rawElement(
552 [
'class' => $outerDivClass ] + $cellAttributes,
553 $inputHtml .
"\n$errors"
556 $divCssClasses = [
"mw-htmlform-field-$fieldType",
559 $wrapperAttributes = [
562 if ( $this->mHideIf ) {
563 $wrapperAttributes[
'data-hide-if'] = FormatJson::encode( $this->mHideIf );
564 $wrapperAttributes[
'class'][] =
' mw-htmlform-hide-if';
566 $html = Html::rawElement(
'div', $wrapperAttributes, $label . $field );
583 if ( !$inputField ) {
598 $inputField =
new OOUI\Widget( [
'content' =>
new OOUI\
HtmlSnippet( $inputField ) ] );
602 $fieldType = static::class;
605 foreach ( $errors as &$error ) {
610 'classes' => [
"mw-htmlform-field-$fieldType", $this->mClass ],
618 $preloadModules =
false;
621 $preloadModules =
true;
622 $config[
'classes'][] =
'mw-htmlform-field-autoinfuse';
627 if ( $label && $label !==
"\u{00A0}" && $label !==
' ' ) {
631 if ( $this->mHideIf ) {
632 $preloadModules =
true;
633 $config[
'hideIf'] = $this->mHideIf;
638 if ( $preloadModules ) {
639 $this->mParent->getOutput()->addModules(
'mediawiki.htmlform.ooui' );
640 $this->mParent->getOutput()->addModules( $this->
getOOUIModules() );
661 if (
isset( $this->mClassWithButton ) ) {
662 $buttonWidget = $this->mClassWithButton->getInputOOUI(
'' );
703 $cellAttributes = [];
724 $this->mVFormClass =
' mw-ui-vform-field';
738 $cellAttributes = [];
741 $html =
"\n" . $errors .
742 $label .
"\u{00A0}" .
762 if ( $this->mHideIf ) {
763 $rowAttributes[
'data-hide-if'] = FormatJson::encode( $this->mHideIf );
764 $rowAttributes[
'class'] =
'mw-htmlform-hide-if';
767 $tdClasses = [
'htmlform-tip' ];
768 if ( $this->mHelpClass !==
false ) {
769 $tdClasses[] = $this->mHelpClass;
771 $row = Html::rawElement(
'td', [
'colspan' => 2,
'class' => $tdClasses ], $helptext );
772 $row = Html::rawElement(
'tr', $rowAttributes, $row );
790 $wrapperAttributes = [
791 'class' =>
'htmlform-tip',
793 if ( $this->mHelpClass !==
false ) {
794 $wrapperAttributes[
'class'] .=
" {$this->mHelpClass}";
796 if ( $this->mHideIf ) {
797 $wrapperAttributes[
'data-hide-if'] = FormatJson::encode( $this->mHideIf );
798 $wrapperAttributes[
'class'] .=
' mw-htmlform-hide-if';
800 $div = Html::rawElement(
'div', $wrapperAttributes, $helptext );
824 if (
isset( $this->mParams[
'help-message'] ) ) {
825 $this->mParams[
'help-messages'] = [ $this->mParams[
'help-message'] ];
828 if (
isset( $this->mParams[
'help-messages'] ) ) {
829 foreach ( $this->mParams[
'help-messages'] as $msg ) {
832 if ( $msg->exists() ) {
836 $helptext .= $this->
msg(
'word-separator' )->escaped();
838 $helptext .= $msg->parse();
842 $helptext = $this->mParams[
'help'];
857 return $this->mParams[
'help-inline'] ??
true;
875 if (
is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
879 $errors = self::formatErrors( $errors );
880 $errorClass =
'mw-htmlform-invalid-input';
896 if (
is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
901 $errors = [ $errors ];
903 foreach ( $errors as &$error ) {
904 if ( $error instanceof
Message ) {
905 $error = $error->parse();
916 return $this->mLabel ??
'';
920 # Don't output a for= attribute for labels with no associated input.
921 # Kind of hacky here, possibly we don't want these to be <label>s at all.
925 $for[
'for'] = $this->mID;
930 if ( $labelValue !==
"\u{00A0}" && $labelValue !==
' ' && $labelValue !==
'' ) {
934 $displayFormat = $this->mParent->getDisplayFormat();
936 $horizontalLabel = $this->mParams[
'horizontal-label'] ??
false;
938 if ( $displayFormat ===
'table' ) {
940 Html::rawElement(
'td',
941 [
'class' =>
'mw-label' ] + $cellAttributes,
942 Html::rawElement(
'label', $for, $labelValue ) );
943 }
elseif ( $hasLabel || $this->mShowEmptyLabels ) {
944 if ( $displayFormat ===
'div' && !$horizontalLabel ) {
946 Html::rawElement(
'div',
947 [
'class' =>
'mw-label' ] + $cellAttributes,
948 Html::rawElement(
'label', $for, $labelValue ) );
950 $html = Html::rawElement(
'label', $for, $labelValue );
958 return $this->mDefault ??
null;
967 if ( empty( $this->mParams[
'tooltip'] ) ) {
980 if ( empty( $this->mParams[
'tooltip'] ) ) {
997 static $boolAttribs = [
'disabled',
'required',
'autofocus',
'multiple',
'readonly' ];
1000 foreach ( $list as $key ) {
1001 if (
in_array( $key, $boolAttribs ) ) {
1002 if ( !empty( $this->mParams[$key] ) ) {
1006 $ret[$key] = $this->mParams[$key];
1023 $key = $this->
msg( $key )->plain();
1040 return array_map( [ __CLASS__,
'forceToStringRecursive' ], $array );
1053 if ( $this->mOptions ===
false ) {
1055 $this->mOptions = $this->
lookupOptionsKeys( $this->mParams[
'options-messages'] );
1057 $this->mOptionsLabelsNotFromMessage =
true;
1058 $this->mOptions = self::forceToStringRecursive( $this->mParams[
'options'] );
1060 $message = $this->
getMessage( $this->mParams[
'options-message'] )->inContentLanguage()->plain();
1061 $this->mOptions = Xml::listDropDownOptions( $message );
1063 $this->mOptions =
null;
1067 return $this->mOptions;
1077 if ( $oldoptions ===
null ) {
1081 return Xml::listDropDownOptionsOoui( $oldoptions );
1122 if (
is_array( $errors ) && count( $errors ) === 1 ) {
1128 foreach ( $errors as $error ) {
1129 if ( $error instanceof
Message ) {
1130 $lines[] = Html::rawElement(
'li', [], $error->parse() );
1132 $lines[] = Html::rawElement(
'li', [], $error );
1136 return Html::rawElement(
'ul', [
'class' =>
'error' ], implode(
"\n",
$lines ) );
1138 if ( $errors instanceof
Message ) {
1139 $errors = $errors->parse();
1142 return Html::rawElement(
'span', [
'class' =>
'error' ], $errors );
1153 $message = Message::newFromSpecifier(
$value );
1155 if ( $this->mParent ) {
1156 $message->setContext( $this->mParent );
1169 return !empty( $this->mParams[
'nodata'] );
1180 if ( $this->mHideIf ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static titleAttrib( $name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
The Message class provides methods which fulfil two basic services:
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
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
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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 & $options
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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))