112 if ( isset( $attrs[
'class'] ) ) {
113 if ( is_array( $attrs[
'class'] ) ) {
114 $attrs[
'class'][] =
'mw-ui-button';
115 $attrs[
'class'] = array_merge( $attrs[
'class'], $modifiers );
117 $attrs[
'class'] = implode(
' ', $attrs[
'class'] );
119 $attrs[
'class'] .=
' mw-ui-button ' . implode(
' ', $modifiers );
123 $attrs[
'class'] =
'mw-ui-button ' . implode(
' ', $modifiers );
139 if ( isset( $attrs[
'class'] ) ) {
140 if ( is_array( $attrs[
'class'] ) ) {
141 $attrs[
'class'][] =
'mw-ui-input';
143 $attrs[
'class'] .=
' mw-ui-input';
146 $attrs[
'class'] =
'mw-ui-input';
165 public static function linkButton( $contents, array $attrs, array $modifiers = [] ) {
166 return self::element(
'a',
167 self::buttonAttributes( $attrs, $modifiers ),
185 public static function submitButton( $contents, array $attrs, array $modifiers = [] ) {
186 $attrs[
'type'] =
'submit';
187 $attrs[
'value'] = $contents;
188 return self::element(
'input', self::buttonAttributes( $attrs, $modifiers ) );
210 $start = self::openElement( $element,
$attribs );
211 if ( in_array( $element, self::$voidElements ) ) {
213 return substr( $start, 0, -1 ) .
'/>';
215 return "$start$contents" . self::closeElement( $element );
232 return self::rawElement( $element,
$attribs, strtr( $contents, [
255 $element = strtolower( $element );
258 if ( $element ==
'input' ) {
286 if ( isset(
$attribs[
'type'] ) && !in_array(
$attribs[
'type'], $validTypes ) ) {
294 if ( $element ==
'button' && !isset(
$attribs[
'type'] ) ) {
298 return "<$element" . self::expandAttributes(
299 self::dropDefaults( $element,
$attribs ) ) .
'>';
310 $element = strtolower( $element );
312 return "</$element>";
335 static $attribDefaults = [
336 'area' => [
'shape' =>
'rect' ],
338 'formaction' =>
'GET',
339 'formenctype' =>
'application/x-www-form-urlencoded',
347 'autocomplete' =>
'on',
348 'enctype' =>
'application/x-www-form-urlencoded',
351 'formaction' =>
'GET',
354 'keygen' => [
'keytype' =>
'rsa' ],
355 'link' => [
'media' =>
'all' ],
356 'menu' => [
'type' =>
'list' ],
357 'script' => [
'type' =>
'text/javascript' ],
360 'type' =>
'text/css',
362 'textarea' => [
'wrap' =>
'soft' ],
365 $element = strtolower( $element );
368 $lcattrib = strtolower( $attrib );
369 if ( is_array(
$value ) ) {
376 if ( isset( $attribDefaults[$element][$lcattrib] )
377 && $attribDefaults[$element][$lcattrib] ==
$value
382 if ( $lcattrib ==
'class' &&
$value ==
'' ) {
388 if ( $element ===
'link'
393 if ( $element ===
'input' ) {
396 if (
$type ===
'checkbox' ||
$type ===
'radio' ) {
403 } elseif (
$type ===
'submit' ) {
416 if ( $element ===
'select' && isset(
$attribs[
'size'] ) ) {
417 if ( in_array(
'multiple',
$attribs )
421 if ( strval(
$attribs[
'size'] ) ==
'4' ) {
426 if ( strval(
$attribs[
'size'] ) ==
'1' ) {
484 if ( is_int( $key ) && in_array( strtolower(
$value ), self::$boolAttribs ) ) {
490 $key = strtolower( $key );
494 $spaceSeparatedListAttributes = [
504 if ( in_array( $key, $spaceSeparatedListAttributes ) ) {
509 if ( is_array(
$value ) ) {
512 foreach (
$value as $k => $v ) {
513 if ( is_string( $v ) ) {
516 if ( !isset(
$value[$v] ) ) {
528 $value = implode(
' ', $newValue );
538 } elseif ( is_array(
$value ) ) {
539 throw new MWException(
"HTML attribute $key can not contain a list of values" );
544 if ( in_array( $key, self::$boolAttribs ) ) {
545 $ret .=
" $key=\"\"";
547 $ret .=
" $key=$quote" . Sanitizer::encodeAttribute(
$value ) . $quote;
565 if ( preg_match(
'/[<&]/', $contents ) ) {
566 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
569 return self::rawElement(
'script', $attrs, $contents );
580 $attrs = [
'src' => $url ];
582 return self::element(
'script', $attrs );
602 $contents = strtr( $contents, [
606 ']]>' =>
'\5D\5D\3E '
609 if ( preg_match(
'/[<&]/', $contents ) ) {
610 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
613 return self::rawElement(
'style', [
627 return self::element(
'link', [
628 'rel' =>
'stylesheet',
649 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
652 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
655 return self::element(
'input',
$attribs );
666 public static function check( $name, $checked =
false, array
$attribs = [] ) {
691 $html = self::element(
'h2', [], $heading ) .
$html;
693 return self::rawElement(
'div', [
'class' => $className ],
$html );
703 return self::messageBox(
$html,
'warningbox' );
714 return self::messageBox(
$html,
'errorbox', $heading );
724 return self::messageBox(
$html,
'successbox' );
735 public static function radio( $name, $checked =
false, array
$attribs = [] ) {
762 return self::element(
'label',
$attribs, $label );
793 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
798 $spacedValue =
"\n" .
$value;
802 return self::element(
'textarea', self::getTextInputAttributes(
$attribs ), $spacedValue );
815 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
819 if ( isset(
$params[
'all'] ) ) {
829 foreach (
$options as $nsId => $nsName ) {
836 $nsName =
wfMessage(
'blanknamespace' )->text();
837 } elseif ( is_int( $nsId ) ) {
840 $optionsOut[$nsId] = $nsName;
863 array $selectAttribs = []
865 ksort( $selectAttribs );
868 if ( isset(
$params[
'selected'] ) ) {
873 if ( preg_match(
'/^\d+$/',
$params[
'selected'] ) ) {
881 if ( !isset(
$params[
'disable'] ) || !is_array(
$params[
'disable'] ) ) {
890 foreach (
$options as $nsId => $nsName ) {
891 $optionsHtml[] = self::element(
893 'disabled' => in_array( $nsId,
$params[
'disable'] ),
895 'selected' => $nsId ===
$params[
'selected'],
900 if ( !array_key_exists(
'id', $selectAttribs ) ) {
901 $selectAttribs[
'id'] =
'namespace';
904 if ( !array_key_exists(
'name', $selectAttribs ) ) {
905 $selectAttribs[
'name'] =
'namespace';
909 if ( isset(
$params[
'label'] ) ) {
910 $ret .= self::element(
912 'for' => isset( $selectAttribs[
'id'] ) ? $selectAttribs[
'id'] :
null,
918 $ret .= self::openElement(
'select', $selectAttribs )
920 . implode(
"\n", $optionsHtml )
922 . self::closeElement(
'select' );
945 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?" .
">\n";
948 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
956 $ret .=
"<!DOCTYPE html>\n";
978 # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
979 return (
bool)preg_match(
'!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
992 static function infoBox( $text, $icon, $alt, $class =
'' ) {
993 $s = self::openElement(
'div', [
'class' =>
"mw-infobox $class" ] );
995 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-left' ] ) .
996 self::element(
'img',
1002 self::closeElement(
'div' );
1004 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-right' ] ) .
1006 self::closeElement(
'div' );
1007 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1009 $s .= self::closeElement(
'div' );
1011 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1041 foreach (
$urls as $density => $url ) {
1044 $density = (
string)(
float)$density;
1045 $candidates[$density] = $url;
1049 ksort( $candidates, SORT_NUMERIC );
1050 $candidates = array_unique( $candidates );
1053 foreach ( $candidates as $density => $url ) {
1054 $candidates[$density] = $url .
' ' . $density .
'x';
1057 return implode(
", ", $candidates );
$wgMimeType
The default Content-Type header.
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
$wgHtml5Version
Defines the value of the version attribute in the <html> tag, if any.
$wgXhtmlNamespaces
Permit other namespaces in addition to the w3.org default.
This class is a collection of static functions that serve two purposes:
static label( $label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
static textarea( $name, $value='', array $attribs=[])
Convenience function to produce a <textarea> element.
static infoBox( $text, $icon, $alt, $class='')
Get HTML for an info box with an icon.
static namespaceSelectorOptions(array $params=[])
Helper for Html::namespaceSelector().
static linkedScript( $url)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static messageBox( $html, $className, $heading='')
Return the HTML for a message box.
static isXmlMimeType( $mimetype)
Determines if the given MIME type is xml.
static linkButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static htmlHeader(array $attribs=[])
Constructs the opening html-tag with necessary doctypes depending on global variables.
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
static dropDefaults( $element, array $attribs)
Given an element name and an associative array of element attributes, return an array that is functio...
static errorBox( $html, $heading='')
Return an error box.
static submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes.
static radio( $name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static warningBox( $html)
Return a warning box.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
static successBox( $html)
Return a success box.
static check( $name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
static srcSet(array $urls)
Generate a srcset attribute value.
static closeElement( $element)
Returns "</$element>".
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static inlineStyle( $contents, $media='all', $attribs=[])
Output a "<style>" tag with the given contents for the given media type (if any).
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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
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
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