-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.php
233 lines (200 loc) · 6.79 KB
/
template.php
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
<?php
/**
* Implements hook_preprocess_node().
*
* Override or insert variables into the node templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("node" in this case.)
*/
function latto_odense_preprocess_node(&$variables, $hook) {
$hooks = theme_get_registry(FALSE);
if (isset($hooks['opening_hours_week']) && $variables['type'] == 'ding_library') {
$variables['opening_hours'] = theme('opening_hours_week', array('node' => $variables['node']));
}
}
/**
* Implements hook_preprocess_table().
* adds classes table table-striped
*/
function latto_odense_preprocess_table(&$variables) {
if (isset($variables['attributes']['class']) && is_string($variables['attributes']['class'])) {
// Convert classes to an array.
$variables['attributes']['class'] = explode(' ', $variables['attributes']['class']);
}
$variables['attributes']['class'][] = 'table table-striped';
}
/**
* alters forms.
*/
function latto_odense_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'search_block_form':
unset($form['search_block_form']['#default_value']);
$form['actions']['#suffix'] = '<div class="clearfix"></div>';
break;
case 'user_login_block':
unset($form['name']['#title']);
$form['name']['#attributes']['placeholder'] = t('Cpr- eller kortnummer:');
$form['name']['#type'] = 'password';
$form['pass']['#attributes']['placeholder'] = t('Adgangskode:');
unset($form['pass']['#title']);
$form['links']['#markup'] = "";
$form['actions']['submit']['#attributes']['class'][] = 'btn';
$form['actions']['submit']['#attributes']['class'][] = 'btn-info';
break;
case 'comment_node_ding_news_form':
$form['actions']['submit']['#prefix'] = '<div>';
$form['actions']['submit']['#suffix'] = '</div>';
$form['actions']['preview']['#prefix'] = '<div>';
$form['actions']['preview']['#suffix'] = '</div>';
$form['subject']['#type'] = 'hidden';
break;
}
}
/**
* Implements theme_menu_tree().
*
* Addes wrapper clases for the default menu.
*/
function latto_odense_menu_tree__menu_block__1($vars) {
return '<ul class="main-menu">' . $vars['tree'] . '</ul>';
}
function latto_odense_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
// Class attributes by menu_attributes
if (isset($element['#localized_options']['attributes']['class'])) {
$array_class = $element['#localized_options']['attributes']['class'];
$icon = '<br/>';
foreach ($array_class as $i => $class) {
if (substr($class, 0, 5) == 'icon-' ) {
// Don't put the class on the <a> tag
unset ($element['#localized_options']['attributes']['class'][$i]);
// It should go on a <i> tag (FontAwesome)
$icon .= '<i class="' . $class . '"></i>';
}
}
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
if (!empty($icon)) {
// Insert the icons (<i> tags) into the <a> tag.
$output = substr_replace($output, $icon, -4, 0);
}
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
/**
* Implements HOOK_theme().
*/
/*
function latto_odense_theme() {
return array(
'nomarkup' => array(
'render element' => 'element',
),
);
}
function theme_nomarkup($variables){
$output = '';
//Render the items.
foreach ($variables['items'] as $delta => $item){
$output .= drupal_render($item);
}
return $output;
}
*/
/**
* Implements hook_menu_local_task()
*
* @param array $variables
*
* return string with html
*/
function latto_odense_menu_local_tasks(&$variables) {
$output = '';
$has_access = user_access('access contextual links');
if (!empty($variables['primary'])) {
// Only display contextual links if the user has the correct permissions enabled.
// Otherwise, the default primary tabs will be used.
$variables['primary']['#prefix'] = '<ul class="nav nav-tabs">';
$variables['primary']['#suffix'] = '</ul>';
$output .= drupal_render($variables['primary']);
}
if (!empty($variables['secondary'])) {
$variables['secondary']['#prefix'] = '<ul class="nav nav-tabs">';
$variables['secondary']['#suffix'] = '</ul>';
$output .= drupal_render($variables['secondary']);
}
return $output;
}
function latto_odense_links__library_menu($variables) {
$links = $variables['links'];
$attributes = $variables['attributes'];
$heading = $variables['heading'];
global $language_url;
$output = '';
if (count($links) > 0) {
$output = '';
// Treat the heading first if it is present to prepend it to the
// list of links.
if (!empty($heading)) {
if (is_string($heading)) {
// Prepare the array that will be used when the passed heading
// is a string.
$heading = array(
'text' => $heading,
// Set the default level of the heading.
'level' => 'h2',
);
}
$output .= '<' . $heading['level'];
if (!empty($heading['class'])) {
$output .= drupal_attributes(array('class' => $heading['class']));
}
$output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
}
$output .= '<ul class="nav nav-tabs">';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = array($key);
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class[] = 'first';
}
if ($i == $num_links) {
$class[] = 'last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language_url->language)) {
$class[] = 'active';
}
$output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
elseif (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes.
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
?>