From: kaldari Date: Tue, 2 Jun 2015 01:46:07 +0000 (-0700) Subject: Fixing definition and use of $attrs parameter in Html::buttonAttributes X-Git-Tag: 1.31.0-rc.0~11212^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=f74b88311b3f3c9f545d8dfdd04e1fb70e6aa6c2;p=lhc%2Fweb%2Fwiklou.git Fixing definition and use of $attrs parameter in Html::buttonAttributes Also clarifying definition of $modifiers parameter. Also simplifying code for case where $attrs['class'] is not set. Change-Id: I425211681ba75cb71c1ccc3b3c038c075ea9acb9 --- diff --git a/includes/Html.php b/includes/Html.php index 6907245bc3..6da70b1dee 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -104,8 +104,8 @@ class Html { /** * Modifies a set of attributes meant for button elements * and apply a set of default attributes when $wgUseMediaWikiUIEverywhere enabled. - * @param array $attrs - * @param string[] $modifiers to add to the button + * @param array $attrs HTML attributes in an associative array + * @param string[] $modifiers classes 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 */ @@ -115,16 +115,15 @@ class Html { if ( isset( $attrs['class'] ) ) { if ( is_array( $attrs['class'] ) ) { $attrs['class'][] = 'mw-ui-button'; - $attrs = array_merge( $attrs, $modifiers ); + $attrs['class'] = array_merge( $attrs['class'], $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 ) ); + $attrs['class'] = 'mw-ui-button ' . implode( ' ', $modifiers ); } } return $attrs; @@ -162,7 +161,7 @@ class Html { * @param array $attrs Associative array of attributes, e.g., array( * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for * further documentation. - * @param string[] $modifiers to add to the button + * @param string[] $modifiers classes to add to the button * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */ @@ -182,7 +181,7 @@ class Html { * @param array $attrs Associative array of attributes, e.g., array( * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for * further documentation. - * @param string[] $modifiers to add to the button + * @param string[] $modifiers classes to add to the button * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */