X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fskins%2FBaseTemplate.php;h=71ca57bf09e0a73fac542b203c8d303955dd13d0;hb=2bec3ad45c71b33b4e625287a88495599c1f0b90;hp=3408db3487467f230e32e212711380fb65803235;hpb=996b7350f3355f24abb55394ced108c0c9b8ef3a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 3408db3487..71ca57bf09 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -140,7 +140,7 @@ abstract class BaseTemplate extends QuickTemplate { if ( isset( $plink['active'] ) ) { $ptool['active'] = $plink['active']; } - foreach ( [ 'href', 'class', 'text', 'dir' ] as $k ) { + foreach ( [ 'href', 'class', 'text', 'dir', 'data' ] as $k ) { if ( isset( $plink[$k] ) ) { $ptool['links'][0][$k] = $plink[$k]; } @@ -318,6 +318,15 @@ abstract class BaseTemplate extends QuickTemplate { * * If you don't want an accesskey, set $item['tooltiponly'] = true; * + * If a "data" key is present, it must be an array, where the keys represent + * the data-xxx properties with their provided values. For example, + * $item['data'] = array( + * 'foo' => 1, + * 'bar' => 'baz', + * ); + * will render as element properties: + * data-foo='1' data-bar='baz' + * * @param array $options Can be used to affect the output of a link. * Possible options are: * - 'text-wrapper' key to specify a list of elements to wrap the text of @@ -363,6 +372,13 @@ abstract class BaseTemplate extends QuickTemplate { unset( $attrs[$k] ); } + if ( isset( $attrs['data'] ) ) { + foreach ( $attrs['data'] as $key => $value ) { + $attrs[ 'data-' . $key ] = $value; + } + unset( $attrs[ 'data' ] ); + } + if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) { $item['single-id'] = $item['id']; } @@ -425,7 +441,8 @@ abstract class BaseTemplate extends QuickTemplate { * list item directly so they will not be passed to makeLink * (however the link will still support a tooltip and accesskey from it) * If you need an id or class on a single link you should include a "links" - * array with just one link item inside of it. If you want to add a title + * array with just one link item inside of it. You can also set "link-class" in + * $item to set a class on the link itself. If you want to add a title * to the list item itself, you can set "itemtitle" to the value. * $options is also passed on to makeLink calls * @@ -450,6 +467,12 @@ abstract class BaseTemplate extends QuickTemplate { // generating tooltips and accesskeys. $link['single-id'] = $item['id']; } + if ( isset( $link['link-class'] ) ) { + // link-class should be set on the itself, + // so pass it in as 'class' + $link['class'] = $link['link-class']; + unset( $link['link-class'] ); + } $html = $this->makeLink( $key, $link, $options ); }