root / drupal7 / sites / all / themes / bootstrap / templates / filter / filter-tips.func.php @ 5024cef7
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Stub file for bootstrap_filter_tips().
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Returns HTML for a set of filter tips.
|
10 |
*
|
11 |
* @param array $variables
|
12 |
* An associative array containing:
|
13 |
* - tips: An array containing descriptions and a CSS ID in the form of
|
14 |
* 'module-name/filter-id' (only used when $long is TRUE) for each
|
15 |
* filter in one or more text formats. Example:.
|
16 |
*
|
17 |
* @code
|
18 |
* array(
|
19 |
* 'Full HTML' => array(
|
20 |
* 0 => array(
|
21 |
* 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
|
22 |
* 'id' => 'filter/2',
|
23 |
* ),
|
24 |
* ),
|
25 |
* );
|
26 |
* @endcode
|
27 |
* - long: (optional) Whether the passed-in filter tips contain extended
|
28 |
* explanations, i.e. intended to be output on the path 'filter/tips'
|
29 |
* (TRUE), or are in a short format, i.e. suitable to be displayed below a
|
30 |
* form element. Defaults to FALSE.
|
31 |
*
|
32 |
* @return string
|
33 |
* The constructed HTML.
|
34 |
*
|
35 |
* @see theme_filter_tips()
|
36 |
* @see _filter_tips()
|
37 |
*
|
38 |
* @ingroup theme_functions
|
39 |
*/
|
40 |
function bootstrap_filter_tips(array $variables) { |
41 |
$format_id = arg(2); |
42 |
$current_path = current_path();
|
43 |
$tips = _filter_tips(-1, TRUE); |
44 |
|
45 |
// Create a place holder for the tabs.
|
46 |
$build['tabs'] = array( |
47 |
'#theme' => 'item_list', |
48 |
'#items' => array(), |
49 |
'#attributes' => array( |
50 |
'class' => array( |
51 |
'nav',
|
52 |
'nav-tabs',
|
53 |
), |
54 |
'role' => 'tablist', |
55 |
), |
56 |
); |
57 |
|
58 |
// Create a placeholder for the panes.
|
59 |
$build['panes'] = array( |
60 |
'#theme_wrappers' => array('container'), |
61 |
'#attributes' => array( |
62 |
'class' => array( |
63 |
'tab-content',
|
64 |
), |
65 |
), |
66 |
); |
67 |
|
68 |
foreach ($tips as $name => $list) { |
69 |
$machine_name = str_replace('-', '_', drupal_html_class($name)); |
70 |
$tab = array( |
71 |
'data' => array( |
72 |
'#type' => 'link', |
73 |
'#title' => check_plain($name), |
74 |
'#href' => $current_path, |
75 |
'#attributes' => array( |
76 |
'role' => 'tab', |
77 |
'data-toggle' => 'tab', |
78 |
), |
79 |
'#options' => array( |
80 |
'fragment' => $machine_name, |
81 |
), |
82 |
), |
83 |
); |
84 |
if (!$format_id || $format_id === $machine_name) { |
85 |
$tab['class'][] = 'active'; |
86 |
$format_id = $machine_name; |
87 |
} |
88 |
$build['tabs']['#items'][] = $tab; |
89 |
|
90 |
// Extract the actual tip.
|
91 |
$tiplist = array(); |
92 |
foreach ($list as $tip) { |
93 |
$tiplist[] = $tip['tip']; |
94 |
} |
95 |
|
96 |
// Construct the pane.
|
97 |
$pane = array( |
98 |
'#theme_wrappers' => array('container'), |
99 |
'#attributes' => array( |
100 |
'class' => array( |
101 |
'tab-pane',
|
102 |
'fade',
|
103 |
), |
104 |
'id' => $machine_name, |
105 |
), |
106 |
'list' => array( |
107 |
'#theme' => 'item_list', |
108 |
'#items' => $tiplist, |
109 |
), |
110 |
); |
111 |
if ($format_id === $machine_name) { |
112 |
$pane['#attributes']['class'][] = 'active'; |
113 |
$pane['#attributes']['class'][] = 'in'; |
114 |
$format_id = $machine_name; |
115 |
} |
116 |
$build['panes'][] = $pane; |
117 |
} |
118 |
|
119 |
return drupal_render($build); |
120 |
} |