-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
240 lines (221 loc) · 8.12 KB
/
template.php
File metadata and controls
240 lines (221 loc) · 8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
/**
* @file
* template.php
*/
/**
* theme_menu_link()
*/
/**
* Overrides theme_menu_local_tasks().
*/
function ca2_menu_local_tasks(&$variables) {
$output = '';
if (!empty($variables['primary'])) {
$variables['primary']['#prefix'] = '<div class="row"><h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
$variables['primary']['#prefix'] .= '<ul class="tabs--primary nav nav-pills pull-right">';
$variables['primary']['#suffix'] = '</ul></div>';
$output .= drupal_render($variables['primary']);
}
if (!empty($variables['secondary'])) {
$variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
$variables['secondary']['#prefix'] .= '<ul class="tabs--secondary pagination pagination-sm">';
$variables['secondary']['#suffix'] = '</ul>';
$output .= drupal_render($variables['secondary']);
}
return $output;
}
/**
* Overrides theme_menu_local_task().
*/
function ca2_menu_local_task($variables) {
$link = $variables['element']['#link'];
$link_text = $link['title'];
$classes = array();
if (!empty($variables['element']['#active'])) {
// Add text to indicate active tab for non-visual users.
$active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
// If the link does not contain HTML already, check_plain() it now.
// After we set 'html'=TRUE the link will not be sanitized by l().
if (empty($link['localized_options']['html'])) {
$link['title'] = check_plain($link['title']);
}
$link['localized_options']['html'] = TRUE;
$link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
$classes[] = 'active';
}
return '<li class="' . implode(' ', $classes) . ' ' . strtolower(str_replace(' ', '-', $link['title'])) . '-link">' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
}
function ca2_menu_link(array $variables) {
//add class for li
$variables['element']['#attributes']['class'][] = 'menu-' . $variables['element']['#original_link']['mlid'];
//add class for a
$variables['element']['#localized_options']['attributes']['class'][] = 'menu-' . $variables['element']['#original_link']['mlid'];
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
// Prevent dropdown functions from being added to management menu so it
// does not affect the navbar module.
if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
$sub_menu = drupal_render($element['#below']);
}
elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
// Add our own wrapper.
unset($element['#below']['#theme_wrappers']);
$sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
// Generate as standard dropdown.
$element['#title'] .= ' <span class="caret"></span>';
$element['#attributes']['class'][] = 'dropdown';
$element['#localized_options']['html'] = TRUE;
// Set dropdown trigger element to # to prevent inadvertant page loading
// when a submenu link is clicked.
$element['#localized_options']['attributes']['data-target'] = '#';
$element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
}
}
// On primary navigation menu, class 'active' is not set on active menu item.
// @see https://drupal.org/node/1896674
if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
$element['#attributes']['class'][] = 'active';
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
function ca2_pager($variables) {
$output = "";
$items = array();
$tags = $variables['tags'];
$element = $variables['element'];
$parameters = $variables['parameters'];
$quantity = $variables['quantity'];
global $pager_page_array, $pager_total;
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// Current is the page we are currently paged to.
$pager_current = $pager_page_array[$element] + 1;
// First is the first page listed by this pager piece (re quantity).
$pager_first = $pager_current - $pager_middle + 1;
// Last is the last page listed by this pager piece (re quantity).
$pager_last = $pager_current + $quantity - $pager_middle;
// Max is the maximum page number.
$pager_max = $pager_total[$element];
// Prepare for generation loop.
$i = $pager_first;
if ($pager_last > $pager_max) {
// Adjust "center" if at end of query.
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
// Adjust "center" if at start of query.
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
// End of generation loop preparation.
// @todo add theme setting for this.
$li_first = theme('pager_first', array(
'text' => (isset($tags[0]) ? $tags[0] : t('first')),
'element' => $element,
'parameters' => $parameters,
));
$li_previous = theme('pager_previous', array(
'text' => (isset($tags[1]) ? $tags[1] : t('previous')),
'element' => $element,
'interval' => 1,
'parameters' => $parameters,
));
$li_next = theme('pager_next', array(
'text' => (isset($tags[3]) ? $tags[3] : t('next')),
'element' => $element,
'interval' => 1,
'parameters' => $parameters,
));
// @todo add theme setting for this.
$li_last = theme('pager_last', array(
'text' => (isset($tags[4]) ? $tags[4] : t('last')),
'element' => $element,
'parameters' => $parameters,
));
if ($pager_total[$element] > 1) {
// @todo add theme setting for this.
if ($li_first) {
$items[] = array(
'class' => array('pager-first'),
'data' => $li_first,
);
}
if ($li_previous) {
$items[] = array(
'class' => array('prev'),
'data' => $li_previous,
);
}
// When there is more than one page, create the pager list.
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => array('pager-ellipsis', 'disabled'),
'data' => '<span>…</span>',
);
}
// Now generate the actual pager piece.
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
// 'class' => array('pager-item'),
'data' => theme('pager_previous', array(
'text' => $i,
'element' => $element,
'interval' => ($pager_current - $i),
'parameters' => $parameters,
)),
);
}
if ($i == $pager_current) {
$items[] = array(
// Add the active class.
'class' => array('active'),
'data' => l($i, '#', array('fragment' => '', 'external' => TRUE)),
);
}
if ($i > $pager_current) {
$items[] = array(
'data' => theme('pager_next', array(
'text' => $i,
'element' => $element,
'interval' => ($i - $pager_current),
'parameters' => $parameters,
)),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => array('pager-ellipsis', 'disabled'),
'data' => '<span>…</span>',
);
}
}
// End generation.
if ($li_next) {
$items[] = array(
'class' => array('next'),
'data' => $li_next,
);
}
// @todo add theme setting for this.
if ($li_last) {
$items[] = array(
'class' => array('pager-last'),
'data' => $li_last,
);
}
return '<div class="text-center">' . theme('item_list', array(
'items' => $items,
'attributes' => array('class' => array('pagination')),
)) . '</div>';
}
return $output;
}