42 $out =
'<' . $element;
46 if ( is_null( $contents ) ) {
49 if ( $allowShortTag && $contents ===
'' ) {
52 $out .=
'>' . htmlspecialchars( $contents ) .
"</$element>";
72 foreach (
$attribs as $name => $val ) {
73 $out .=
" {$name}=\"" . Sanitizer::encodeAttribute( $val ) .
'"';
77 throw new MWException(
'Expected attribute array, got something else in ' . __METHOD__ );
99 return self::element( $element,
$attribs, $contents );
110 return '<' . $element . self::expandAttributes(
$attribs ) .
'>';
119 return "</$element>";
132 return self::openElement( $element,
$attribs ) . $contents .
"</$element>";
144 public static function monthSelector( $selected =
'', $allmonths =
null, $id =
'month' ) {
147 $data =
new XmlSelect(
'month', $id, $selected );
148 if ( is_null( $selected ) ) {
151 if ( !is_null( $allmonths ) ) {
154 for ( $i = 1; $i < 13; $i++ ) {
158 $data->setAttribute(
'class',
'mw-month-selector' );
159 return $data->getHTML();
169 # Offset overrides year/month selection
170 if ( $month && $month !== -1 ) {
171 $encMonth = intval( $month );
176 $encYear = intval( $year );
177 } elseif ( $encMonth ) {
178 $timestamp = MWTimestamp::getInstance();
179 $thisMonth = intval( $timestamp->format(
'n' ) );
180 $thisYear = intval( $timestamp->format(
'Y' ) );
181 if ( intval( $encMonth ) > $thisMonth ) {
184 $encYear = $thisYear;
188 $inputAttribs = [
'id' =>
'year',
'maxlength' => 4,
'size' => 7 ];
189 return self::label(
wfMessage(
'year' )->
text(),
'year' ) .
' ' .
190 Html::input(
'year', $encYear,
'number', $inputAttribs ) .
' ' .
192 self::monthSelector( $encMonth, -1 );
206 $inLanguage =
null, $overrideAttrs = [],
Message $msg =
null
210 $include = $customisedOnly ?
'mwfile' :
'mw';
211 $languages = Language::fetchLanguageNames( $inLanguage, $include );
232 $attrs = [
'id' =>
'wpUserLanguage',
'name' =>
'wpUserLanguage' ];
233 $attrs = array_merge( $attrs, $overrideAttrs );
235 if ( $msg ===
null ) {
239 self::label( $msg->text(), $attrs[
'id'] ),
240 self::tags(
'select', $attrs,
$options )
252 return self::element(
'span', [
'class' => $class ] +
$attribs, $text );
264 return self::tags( $tag, [
'class' => $class ] +
$attribs, $text );
276 $attributes = [
'name' =>
$name ];
279 $attributes[
'size'] = $size;
283 $attributes[
'value'] =
$value;
286 return self::element(
'input',
287 Html::getTextInputAttributes( $attributes +
$attribs ) );
301 return self::input( $name, $size,
$value,
302 array_merge(
$attribs, [
'type' =>
'password' ] ) );
313 public static function attrib( $name, $present =
true ) {
314 return $present ? [ $name =>
$name ] : [];
325 return self::element(
'input', array_merge(
328 'type' =>
'checkbox',
330 self::attrib(
'checked', $checked ),
343 return self::element(
'input', [
346 'value' =>
$value ] + self::attrib(
'checked', $checked ) +
$attribs );
360 $a = [
'for' => $id ];
362 foreach ( [
'class',
'title' ] as $attr ) {
368 return self::element(
'label', $a, $label );
381 public static function inputLabel( $label, $name, $id, $size =
false,
385 return $label .
' ' .
$input;
404 self::label( $label, $id,
$attribs ),
424 self::label( $label, $id,
$attribs );
427 $chkLabel = self::openElement(
'div', [
'class' =>
'mw-ui-checkbox' ] ) .
428 $chkLabel . self::closeElement(
'div' );
448 return self::radio( $name,
$value, $checked, [
'id' => $id ] +
$attribs ) .
450 self::label( $label, $id,
$attribs );
470 $baseAttrs[
'class'] =
'mw-ui-button mw-ui-progressive';
474 return Html::element(
'input',
$attribs );
485 public static function option( $text,
$value =
null, $selected =
false,
487 if ( !is_null(
$value ) ) {
493 return Html::element(
'option',
$attribs, $text );
509 public static function listDropDown( $name =
'', $list =
'', $other =
'',
510 $selected =
'', $class =
'',
$tabindex =
null
512 $options = self::listDropDownOptions( $list, [
'other' => $other ] );
514 $xmlSelect =
new XmlSelect( $name, $name, $selected );
518 $xmlSelect->setAttribute(
'class', $class );
521 $xmlSelect->setAttribute(
'tabindex',
$tabindex );
524 return $xmlSelect->getHTML();
543 if ( isset(
$params[
'other'] ) ) {
548 foreach ( explode(
"\n", $list ) as $option ) {
552 } elseif ( substr(
$value, 0, 1 ) ==
'*' && substr(
$value, 1, 1 ) !=
'*' ) {
553 # A new group is starting...
556 } elseif ( substr(
$value, 0, 2 ) ==
'**' ) {
559 if ( $optgroup ===
false ) {
565 # groupless reason list
586 if ( is_array(
$value ) ) {
587 $optionsOoui[] = [
'optgroup' => (
string)$text ];
588 foreach (
$value as $text2 => $value2 ) {
589 $optionsOoui[] = [
'data' => (
string)$value2,
'label' => (
string)$text2 ];
592 $optionsOoui[] = [
'data' => (
string)
$value,
'label' => (
string)$text ];
611 $s = self::openElement(
'fieldset',
$attribs ) .
"\n";
614 $s .= self::element(
'legend',
null, $legend ) .
"\n";
617 if ( $content !==
false ) {
618 $s .= $content .
"\n";
619 $s .= self::closeElement(
'fieldset' ) .
"\n";
637 return self::element(
'textarea',
638 Html::getTextInputAttributes(
664 return FormatJson::encode(
$value, $pretty, FormatJson::UTF8_OK );
679 foreach (
$args as &$arg ) {
680 $arg = self::encodeJsVar( $arg, $pretty );
681 if ( $arg ===
false ) {
686 return "$name(" . ( $pretty
687 ? (
' ' . implode(
', ',
$args ) .
' ' )
688 : implode(
',',
$args )
704 $parser = xml_parser_create(
"UTF-8" );
706 # case folding violates XML standard, turn it off
707 xml_parser_set_option(
$parser, XML_OPTION_CASE_FOLDING,
false );
709 if ( !xml_parse(
$parser, $text,
true ) ) {
733 Sanitizer::hackDocType() .
738 return self::isWellFormed(
$html );
751 [
'"',
'>',
'<' ],
766 public static function buildForm( $fields, $submitLabel =
null, $submitAttribs = [] ) {
768 $form .=
"<table><tbody>";
770 foreach ( $fields as $labelmsg =>
$input ) {
771 $id =
"mw-$labelmsg";
772 $form .= self::openElement(
'tr', [
'id' => $id ] );
778 $form .= self::tags(
'td', [
'class' =>
'mw-label' ],
wfMessage( $labelmsg )->parse() );
779 $form .= self::openElement(
'td', [
'class' =>
'mw-input' ] )
780 .
$input . self::closeElement(
'td' );
781 $form .= self::closeElement(
'tr' );
784 if ( $submitLabel ) {
785 $form .= self::openElement(
'tr' );
786 $form .= self::tags(
'td', [],
'' );
787 $form .= self::openElement(
'td', [
'class' =>
'mw-submit' ] )
788 . self::submitButton(
wfMessage( $submitLabel )->
text(), $submitAttribs )
789 . self::closeElement(
'td' );
790 $form .= self::closeElement(
'tr' );
793 $form .=
"</tbody></table>";
808 if ( is_array( $headers ) ) {
811 foreach ( $headers as $id =>
$header ) {
814 if ( is_string( $id ) ) {
820 $s .= self::closeElement(
'thead' );
823 foreach (
$rows as $id => $row ) {
826 if ( is_string( $id ) ) {
833 $s .= self::closeElement(
'table' );
847 foreach ( $cells as $id => $cell ) {
850 if ( is_string( $id ) ) {
857 $s .= self::closeElement(
'tr' );
$wgLanguageCode
Site language code.
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
The Message class provides methods which fulfil two basic services:
A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to interpret a given string a...
Class for generating HTML <select> or <datalist> elements.
Module of static functions for generating XML.
static password( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML password input field.
static closeElement( $element)
Shortcut to close an XML element.
static textarea( $name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
static inputLabelSep( $label, $name, $id, $size=false, $value=false, $attribs=[])
Same as Xml::inputLabel() but return input and label in an array.
static isWellFormed( $text)
Check if a string is well-formed XML.
static listDropDownOptions( $list, $params=[])
Build options for a drop-down box from a textual list.
static encodeJsVar( $value, $pretty=false)
Encode a variable of arbitrary type to JavaScript.
static listDropDownOptionsOoui( $options)
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc.
static isWellFormedXmlFragment( $text)
Check if a string is a well-formed XML fragment.
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
static dateMenu( $year, $month)
static buildForm( $fields, $submitLabel=null, $submitAttribs=[])
Generate a form (without the opening form element).
static attrib( $name, $present=true)
Internal function for use in checkboxes and radio buttons and such.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
static openElement( $element, $attribs=null)
This opens an XML element.
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
static wrapClass( $text, $class, $tag='span', $attribs=[])
Shortcut to make a specific element with a class attribute.
static buildTable( $rows, $attribs=[], $headers=null)
Build a table of data.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
static languageSelector( $selected, $customisedOnly=true, $inLanguage=null, $overrideAttrs=[], Message $msg=null)
Construct a language selector appropriate for use in a form or preferences.
static expandAttributes( $attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static span( $text, $class, $attribs=[])
Shortcut to make a span element.
static escapeTagsOnly( $in)
Replace " > and < with their respective HTML entities ( ", >, <)
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
static radio( $name, $value, $checked=false, $attribs=[])
Convenience function to build an HTML radio button.
static buildTableRow( $attribs, $cells)
Build a row for a table.
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
static monthSelector( $selected='', $allmonths=null, $id='month')
Create a date selector.
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
static elementClean( $element, $attribs=[], $contents='')
Format an XML element as with self::element(), but run text through the $wgContLang->normalize() vali...
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
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
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 class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
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 $rows
do that in ParserLimitReportFormat instead $parser
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
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 see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
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 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
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff & $tabindex
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 see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
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
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff or overridable Default is either copyrightwarning or copyrightwarning2 overridable Default is editpage tos summary such as anonymity and the real check
if(is_array($mode)) switch( $mode) $input
switch( $options['output']) $languages