112 if ( $wgUseMediaWikiUIEverywhere ) {
113 if ( isset( $attrs[
'class'] ) ) {
114 if ( is_array( $attrs[
'class'] ) ) {
115 $attrs[
'class'][] =
'mw-ui-button';
116 $attrs[
'class'] = array_merge( $attrs[
'class'], $modifiers );
118 $attrs[
'class'] = implode(
' ', $attrs[
'class'] );
120 $attrs[
'class'] .=
' mw-ui-button ' . implode(
' ', $modifiers );
124 $attrs[
'class'] =
'mw-ui-button ' . implode(
' ', $modifiers );
139 if ( $wgUseMediaWikiUIEverywhere ) {
140 if ( isset( $attrs[
'class'] ) ) {
141 if ( is_array( $attrs[
'class'] ) ) {
142 $attrs[
'class'][] =
'mw-ui-input';
144 $attrs[
'class'] .=
' mw-ui-input';
147 $attrs[
'class'] =
'mw-ui-input';
167 return self::element(
'a',
168 self::buttonAttributes( $attrs, $modifiers ),
187 $attrs[
'type'] =
'submit';
188 $attrs[
'value'] = $contents;
189 return self::element(
'input', self::buttonAttributes( $attrs, $modifiers ) );
211 $start = self::openElement( $element,
$attribs );
212 if ( in_array( $element, self::$voidElements ) ) {
214 return substr( $start, 0, -1 ) .
'/>';
216 return "$start$contents" . self::closeElement( $element );
231 return self::rawElement( $element,
$attribs, strtr( $contents, [
252 $element = strtolower( $element );
255 if ( $element ==
'input' ) {
283 if ( isset(
$attribs[
'type'] ) && !in_array(
$attribs[
'type'], $validTypes ) ) {
291 if ( $element ==
'button' && !isset(
$attribs[
'type'] ) ) {
295 return "<$element" . self::expandAttributes(
296 self::dropDefaults( $element,
$attribs ) ) .
'>';
307 $element = strtolower( $element );
309 return "</$element>";
332 static $attribDefaults = [
333 'area' => [
'shape' =>
'rect' ],
335 'formaction' =>
'GET',
336 'formenctype' =>
'application/x-www-form-urlencoded',
342 'command' => [
'type' =>
'command' ],
345 'autocomplete' =>
'on',
346 'enctype' =>
'application/x-www-form-urlencoded',
349 'formaction' =>
'GET',
352 'keygen' => [
'keytype' =>
'rsa' ],
353 'link' => [
'media' =>
'all' ],
354 'menu' => [
'type' =>
'list' ],
355 'script' => [
'type' =>
'text/javascript' ],
358 'type' =>
'text/css',
360 'textarea' => [
'wrap' =>
'soft' ],
363 $element = strtolower( $element );
365 foreach ( $attribs
as $attrib =>
$value ) {
366 $lcattrib = strtolower( $attrib );
367 if ( is_array(
$value ) ) {
374 if ( isset( $attribDefaults[$element][$lcattrib] )
375 && $attribDefaults[$element][$lcattrib] ==
$value
377 unset( $attribs[$attrib] );
380 if ( $lcattrib ==
'class' &&
$value ==
'' ) {
381 unset( $attribs[$attrib] );
386 if ( $element ===
'link'
387 && isset( $attribs[
'type'] ) && strval( $attribs[
'type'] ) ==
'text/css'
389 unset( $attribs[
'type'] );
391 if ( $element ===
'input' ) {
392 $type = isset( $attribs[
'type'] ) ? $attribs[
'type'] : null;
393 $value = isset( $attribs[
'value'] ) ? $attribs[
'value'] : null;
394 if (
$type ===
'checkbox' ||
$type ===
'radio' ) {
399 unset( $attribs[
'value'] );
401 } elseif (
$type ===
'submit' ) {
410 unset( $attribs[
'value'] );
414 if ( $element ===
'select' && isset( $attribs[
'size'] ) ) {
415 if ( in_array(
'multiple', $attribs )
416 || ( isset( $attribs[
'multiple'] ) && $attribs[
'multiple'] !==
false )
419 if ( strval( $attribs[
'size'] ) ==
'4' ) {
420 unset( $attribs[
'size'] );
424 if ( strval( $attribs[
'size'] ) ==
'1' ) {
425 unset( $attribs[
'size'] );
482 if ( is_int(
$key ) && in_array( strtolower(
$value ), self::$boolAttribs ) ) {
501 if ( in_array(
$key, [
'max',
'min',
'pattern',
'required' ] )
508 $spaceSeparatedListAttributes = [
518 if ( in_array(
$key, $spaceSeparatedListAttributes ) ) {
523 if ( is_array(
$value ) ) {
527 if ( is_string( $v ) ) {
530 if ( !isset(
$value[$v] ) ) {
542 $value = implode(
' ', $newValue );
552 } elseif ( is_array(
$value ) ) {
553 throw new MWException(
"HTML attribute $key can not contain a list of values" );
558 if ( in_array(
$key, self::$boolAttribs ) ) {
559 $ret .=
" $key=\"\"";
582 $ret .=
" $key=$quote" . strtr(
$value, $map ) . $quote;
600 if ( preg_match(
'/[<&]/', $contents ) ) {
601 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
604 return self::rawElement(
'script', $attrs, $contents );
615 $attrs = [
'src' => $url ];
617 return self::element(
'script', $attrs );
633 $contents = strtr( $contents, [
637 ']]>' =>
'\5D\5D\3E '
640 if ( preg_match(
'/[<&]/', $contents ) ) {
641 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
644 return self::rawElement(
'style', [
658 return self::element(
'link', [
659 'rel' =>
'stylesheet',
680 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
683 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
686 return self::element(
'input',
$attribs );
747 return self::element(
'label',
$attribs, $label );
778 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
783 $spacedValue =
"\n" .
$value;
787 return self::element(
'textarea', self::getTextInputAttributes(
$attribs ), $spacedValue );
800 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
804 if ( isset(
$params[
'all'] ) ) {
810 $options += $wgContLang->getFormattedNamespaces();
821 $nsName =
wfMessage(
'blanknamespace' )->text();
822 } elseif ( is_int( $nsId ) ) {
823 $nsName = $wgContLang->convertNamespace( $nsId );
825 $optionsOut[$nsId] = $nsName;
848 array $selectAttribs = []
850 ksort( $selectAttribs );
853 if ( isset(
$params[
'selected'] ) ) {
858 if ( preg_match(
'/^\d+$/',
$params[
'selected'] ) ) {
866 if ( !isset(
$params[
'disable'] ) || !is_array(
$params[
'disable'] ) ) {
876 $optionsHtml[] = self::element(
878 'disabled' => in_array( $nsId,
$params[
'disable'] ),
880 'selected' => $nsId ===
$params[
'selected'],
885 if ( !array_key_exists(
'id', $selectAttribs ) ) {
886 $selectAttribs[
'id'] =
'namespace';
889 if ( !array_key_exists(
'name', $selectAttribs ) ) {
890 $selectAttribs[
'name'] =
'namespace';
894 if ( isset(
$params[
'label'] ) ) {
895 $ret .= self::element(
897 'for' => isset( $selectAttribs[
'id'] ) ? $selectAttribs[
'id'] : null,
903 $ret .= self::openElement(
'select', $selectAttribs )
905 . implode(
"\n", $optionsHtml )
907 . self::closeElement(
'select' );
925 $isXHTML = self::isXmlMimeType( $wgMimeType );
930 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?" .
">\n";
933 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
936 foreach ( $wgXhtmlNamespaces
as $tag => $ns ) {
941 $ret .=
"<!DOCTYPE html>\n";
944 if ( $wgHtml5Version ) {
966 # http://www.whatwg.org/html/infrastructure.html#xml-mime-type
969 # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
970 return (
bool)preg_match(
'!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
983 static function infoBox( $text, $icon, $alt, $class =
'' ) {
984 $s = self::openElement(
'div', [
'class' =>
"mw-infobox $class" ] );
986 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-left' ] ) .
987 self::element(
'img',
993 self::closeElement(
'div' );
995 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-right' ] ) .
997 self::closeElement(
'div' );
998 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1000 $s .= self::closeElement(
'div' );
1002 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1032 foreach ( $urls
as $density => $url ) {
1034 $candidates[] = $url .
' ' . (float)$density .
'x';
1036 return implode(
", ", $candidates );
static closeElement($element)
Returns "$element>".
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
static inlineScript($contents)
Output a "".
when a variable name is used in a it is silently declared as a new local masking the global
static infoBox($text, $icon, $alt, $class= '')
Get HTML for an info box with an icon.
static radio($name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes...
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static textarea($name, $value= '', array $attribs=[])
Convenience function to produce a
static dropDefaults($element, array $attribs)
Given an element name and an associative array of element attributes, return an array that is functio...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static check($name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
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 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
This class is a collection of static functions that serve two purposes:
static inlineStyle($contents, $media= 'all')
Output a "