-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
254 lines (223 loc) · 8.27 KB
/
template.php
File metadata and controls
254 lines (223 loc) · 8.27 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/**
* @file
* Preprocessors.
*/
require_once __DIR__ . '/template.node.php';
/**
* Implements hook_preprocess_panels_pane().
*/
function kulture_theme_preprocess_panels_pane(&$vars) {
// If using lazy pane caching method, and lazy pane is returning the rendered
// content, set the lazy_pane_render variable, so the template can take action
// accordingly.
$vars['is_lazy_pane_render'] = !empty($vars['pane']->cache['method'])
&& $vars['pane']->cache['method'] === 'lazy'
&& !empty($vars['display']->skip_cache);
if ($vars['is_lazy_pane_render']) {
$vars['theme_hook_suggestions'][] = 'panels_pane__lazy_pane_render';
}
// Suggestions base on sub-type.
$vars['theme_hook_suggestions'][] = 'panels_pane__' . str_replace('-', '__', $vars['pane']->subtype);
$vars['theme_hook_suggestions'][] = 'panels_pane__' . $vars['pane']->panel . '__' . str_replace('-', '__', $vars['pane']->subtype);
// Suggestions on panel pane.
$vars['theme_hook_suggestions'][] = 'panels_pane__' . $vars['pane']->panel;
// Suggestions on menus panes.
if ($vars['pane']->subtype == 'og_menu-og_single_menu_block' || $vars['pane']->subtype == 'menu_block-3') {
$vars['theme_hook_suggestions'][] = 'panels_pane__sub_menu';
$vars['classes_array'][] = 'sub-menu-wrapper';
// Change the theme wrapper for both menu-block and OG menu.
if (isset($vars['content']['#content']) && is_array($vars['content']['#content'])) {
// Menu-block.
$vars['content']['#content']['#theme_wrappers'] = array('menu_tree__sub_menu');
}
elseif(is_array($vars['content'])) {
// OG menu.
$vars['content']['#theme_wrappers'] = array('menu_tree__sub_menu');
}
}
}
/**
* Implements theme_menu_tree().
*/
function kulture_theme_menu_tree__menu_block__1($vars) {
return '<ul class="main-menu navbar-nav mr-auto">' . $vars['tree'] . '</ul>';
}
/**
* Implements hook_process_html().
*
* Process variables for html.tpl.php.
*/
function kulture_theme_process_html(&$vars) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($vars);
}
}
/**
* Implements hook_preprocess_html().
*/
function kulture_theme_preprocess_html(&$vars) {
if (!path_is_admin(current_path())) {
$vars['a11y'] = theme('a11y');
}
// Include the libraries.
libraries_load('slick');
}
/**
* Implements hook_theme().
*/
function kulture_theme_theme($existing, $type, $theme, $path) {
return array(
'a11y' => array(
'variables' => array(
'element' => NULL,
),
'template' => 'templates/a11y',
),
'views_exposed_form_widgets_title' => array(
'variables' => array(
'element' => NULL,
),
'template' => 'templates/views/views-exposed-form-widgets-title',
),
'views_exposed_form_widgets_date_inputs' => array(
'variables' => array(
'element' => NULL,
),
'template' => 'templates/views/views-exposed-form-widgets-date-inputs',
),
);
}
/**
* Implements hook_preprocess_HOOK().
*
* Create a11y controls.
*/
function kulture_theme_preprocess_a11y(&$variables) {
$variables['size'] = l('<i class="fa fa-font"></i>', '#', [
'attributes' => [
'class' => [
'a11y-trigger',
'font-size-trigger',
],
'title' => t('Toggle font size'),
],
'html' => TRUE,
]);
$variables['contrast'] = l('<i class="fa fa-adjust"></i>', '#', [
'attributes' => [
'class' => [
'a11y-trigger',
'contrast-trigger',
],
'title' => t('Toggle high contrast'),
],
'html' => TRUE,
]);
drupal_add_js(drupal_get_path('theme', 'kulture_theme') . '/scripts/a11y.js');
}
/**
* Implements hook_process_page().
*/
function kulture_theme_process_page(&$vars) {
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($vars);
}
}
/**
* Returns HTML for a date element formatted as a range.
*/
function kulture_theme_date_display_range($variables) {
$date1 = $variables['date1'];
$date2 = $variables['date2'];
$timezone = $variables['timezone'];
$attributes_start = $variables['attributes_start'];
$attributes_end = $variables['attributes_end'];
$start_date = '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>';
$end_date = '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>';
// If microdata attributes for the start date property have been passed in,
// add the microdata in meta tags.
if (!empty($variables['add_microdata'])) {
$start_date .= '<meta' . drupal_attributes($variables['microdata']['value']['#attributes']) . '/>';
$end_date .= '<meta' . drupal_attributes($variables['microdata']['value2']['#attributes']) . '/>';
}
// Wrap the result with the attributes.
return t('!start-date - !end-date', array(
'!start-date' => $start_date,
'!end-date' => $end_date,
));
}
/**
* Implements hook_preprocess_views_exposed_form().
*/
function kulture_theme_preprocess_views_exposed_form(&$variables) {
if (arg(0) == 'arrangementer') {
$form = $variables['form'];
if ($form['#info']['filter-combine']) {
$widget = $form['#info']['filter-combine']['value'];
$item = $form[$widget];
$render = theme('views_exposed_form_widgets_title', [
'element' => [
'label' => $variables['widgets']['filter-combine']->label,
'field' => $item,
],
]
);
unset($variables['widgets']['filter-combine']->label);
$variables['widgets']['filter-combine']->widget = $render;
}
if ($form['#info']['filter-field_ding_event_date_value'] && $form['#info']['filter-field_ding_event_date_value2']) {
$widget_from = $form['#info']['filter-field_ding_event_date_value']['value'];
$widget_to = $form['#info']['filter-field_ding_event_date_value2']['value'];
$item_from = $form[$widget_from];
$item_to = $form[$widget_to];
$return = [
'from' => [
'label' => $variables['widgets']['filter-field_ding_event_date_value']->label,
'field' => $item_from,
],
'to' => [
'label' => $variables['widgets']['filter-field_ding_event_date_value2']->label,
'field' => $item_to,
],
];
$render = theme('views_exposed_form_widgets_date_inputs', [
'element' => $return,
]
);
unset($variables['widgets']['filter-field_ding_event_date_value']->label);
$variables['widgets']['filter-field_ding_event_date_value']->widget = $render;
unset($variables['widgets']['filter-field_ding_event_date_value2']);
}
}
}
/**
* Implements hook_form_views_exposed_form_alter().
*/
function kulture_theme_form_views_exposed_form_alter(&$form, &$form_state): void
{
if ($form_state['view']->name == 'ding_event' && $form_state['view']->current_display == 'ding_event_list') {
if (!empty($form['#info']['filter-term_node_tid_depth'])) {
$label = $form['#info']['filter-term_node_tid_depth']['label'];
unset($form['#info']['filter-term_node_tid_depth']['label']);
$form['event_category_term_node_tid_depth']['#title'] = '<h2 class="list-title sub-menu-title">' . $label . '</h2>';
}
if (!empty($form['#info']['filter-og_group_ref_target_id_entityreference_filter'])) {
$label = $form['#info']['filter-og_group_ref_target_id_entityreference_filter']['label'];
unset($form['#info']['filter-og_group_ref_target_id_entityreference_filter']['label']);
$form['og_group_ref_target_id_entityreference_filter']['#title'] = '<h2 class="list-title sub-menu-title">' . $label . '</h2>';
}
if (!empty($form['#info']['filter-field_ding_event_target_tid'])) {
$label = $form['#info']['filter-field_ding_event_target_tid']['label'];
unset($form['#info']['filter-field_ding_event_target_tid']['label']);
$form['field_ding_event_target_tid']['#title'] = '<h2 class="list-title sub-menu-title">' . $label . '</h2>';
}
if (!empty($form['#info']['filter-field_event_gl_municipality_tid'])) {
$label = $form['#info']['filter-field_event_gl_municipality_tid']['label'];
unset($form['#info']['filter-field_event_gl_municipality_tid']['label']);
$form['field_event_gl_municipality_tid']['#title'] = '<h2 class="list-title sub-menu-title">' . $label . '</h2>';
}
}
}