Use correct case of function ImageGallery::toHTML
[lhc/web/wiklou.git] / includes / Html.php
index 48dbdba..fa868e3 100644 (file)
@@ -101,6 +101,34 @@ class Html {
                'itemscope',
        );
 
+       /**
+        * Modifies a set of attributes meant for button elements
+        * and apply a set of default attributes when $wgUseMediaWikiUIEverywhere enabled.
+        * @param array $modifiers to add to the button
+        * @see https://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+        * @return array $attrs A modified attribute array
+        */
+       public static function buttonAttributes( $attrs, $modifiers = array() ) {
+               global $wgUseMediaWikiUIEverywhere;
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       if ( isset( $attrs['class'] ) ) {
+                               if ( is_array( $attrs['class'] ) ) {
+                                       $attrs['class'][] = 'mw-ui-button';
+                                       $attrs = array_merge( $attrs, $modifiers );
+                                       // ensure compatibility with Xml
+                                       $attrs['class'] = implode( ' ', $attrs['class'] );
+                               } else {
+                                       $attrs['class'] .= ' mw-ui-button ' . implode( ' ', $modifiers );
+                               }
+                       } else {
+                               $attrs['class'] = array( 'mw-ui-button' );
+                               // ensure compatibility with Xml
+                               $attrs['class'] = implode( ' ', array_merge( $attrs['class'], $modifiers ) );
+                       }
+               }
+               return $attrs;
+       }
+
        /**
         * Modifies a set of attributes meant for text input elements
         * and apply a set of default attributes.
@@ -130,6 +158,43 @@ class Html {
                return $attrs;
        }
 
+       /**
+        * Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
+        *
+        * @param string $contents The raw HTML contents of the element: *not*
+        *   escaped!
+        * @param array $attrs Associative array of attributes, e.g., array(
+        *   'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+        *   further documentation.
+        * @param array $modifiers to add to the button
+        * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+        * @return string Raw HTML
+        */
+       public static function linkButton( $contents, $attrs, $modifiers = array() ) {
+               return Html::element( 'a',
+                       self::buttonAttributes( $attrs, $modifiers ),
+                       $contents
+               );
+       }
+
+       /**
+        * Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
+        *
+        * @param string $contents The raw HTML contents of the element: *not*
+        *   escaped!
+        * @param array $attrs Associative array of attributes, e.g., array(
+        *   'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+        *   further documentation.
+        * @param array $modifiers to add to the button
+        * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+        * @return string Raw HTML
+        */
+       public static function submitButton( $contents, $attrs, $modifiers = array() ) {
+               $attrs['type'] = 'submit';
+               $attrs['value'] = $contents;
+               return Html::element( 'input', self::buttonAttributes( $attrs, $modifiers ) );
+       }
+
        /**
         * Returns an HTML element in a string.  The major advantage here over
         * manually typing out the HTML is that it will escape all attribute
@@ -937,20 +1002,13 @@ class Html {
         * Get HTML for an info box with an icon.
         *
         * @param string $text Wikitext, get this with wfMessage()->plain()
-        * @param string $icon Icon name, file in skins/common/images
+        * @param string $icon Path to icon file (used as 'src' attribute)
         * @param string $alt Alternate text for the icon
         * @param string $class Additional class name to add to the wrapper div
-        * @param bool $useStylePath
         *
         * @return string
         */
-       static function infoBox( $text, $icon, $alt, $class = false, $useStylePath = true ) {
-               global $wgStylePath;
-
-               if ( $useStylePath ) {
-                       $icon = $wgStylePath . '/common/images/' . $icon;
-               }
-
+       static function infoBox( $text, $icon, $alt, $class = false ) {
                $s = Html::openElement( 'div', array( 'class' => "mw-infobox $class" ) );
 
                $s .= Html::openElement( 'div', array( 'class' => 'mw-infobox-left' ) ) .