root / drupal7 / sites / all / themes / bootstrap / templates / menu / menu-local-action.func.php @ 7547bb19
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for bootstrap_menu_local_action().
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Returns HTML for a single local action link.
|
9 |
*
|
10 |
* @param array $variables
|
11 |
* An associative array containing:
|
12 |
* - element: A render element containing:
|
13 |
* - #link: A menu link array with 'title', 'href', and 'localized_options'
|
14 |
* keys.
|
15 |
*
|
16 |
* @return string
|
17 |
* The constructed HTML.
|
18 |
*
|
19 |
* @see theme_menu_local_action()
|
20 |
*
|
21 |
* @ingroup theme_functions
|
22 |
*/
|
23 |
function bootstrap_menu_local_action($variables) { |
24 |
$link = $variables['element']['#link']; |
25 |
|
26 |
$options = isset($link['localized_options']) ? $link['localized_options'] : array(); |
27 |
|
28 |
// Filter the title if the "html" is set, otherwise l() will automatically
|
29 |
// sanitize using check_plain(), so no need to call that here.
|
30 |
$title = empty($options['html']) ? filter_xss_admin($link['title']) : $link['title']; |
31 |
|
32 |
$icon = _bootstrap_iconize_text($title); |
33 |
$href = !empty($link['href']) ? $link['href'] : FALSE; |
34 |
|
35 |
// Format the action link.
|
36 |
if ($href) { |
37 |
// Turn link into a mini-button and colorize based on title.
|
38 |
if ($class = _bootstrap_colorize_text($title)) { |
39 |
if (!isset($options['attributes']['class'])) { |
40 |
$options['attributes']['class'] = array(); |
41 |
} |
42 |
$string = is_string($options['attributes']['class']); |
43 |
if ($string) { |
44 |
$options['attributes']['class'] = explode(' ', $options['attributes']['class']); |
45 |
} |
46 |
$options['attributes']['class'][] = 'btn'; |
47 |
$options['attributes']['class'][] = 'btn-xs'; |
48 |
$options['attributes']['class'][] = 'btn-' . $class; |
49 |
if ($string) { |
50 |
$options['attributes']['class'] = implode(' ', $options['attributes']['class']); |
51 |
} |
52 |
} |
53 |
// Force HTML so we can render any icon that may have been added.
|
54 |
$options['html'] = !empty($options['html']) || !empty($icon) ? TRUE : FALSE; |
55 |
} |
56 |
|
57 |
return $href ? l($icon . $title, $href, $options) : $icon . $title; |
58 |
} |