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