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