-
Notifications
You must be signed in to change notification settings - Fork 36
/
template.php
119 lines (106 loc) · 4.27 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
<?php
/**
* Preprocess function to determine number of columns for main content area.
**/
function foundation_preprocess_page(&$variables)
{
if (!empty($variables['page']['left']) && !empty($variables['page']['right'])) {
$variables['main_columns'] = 'large-6';
} elseif (!empty($variables['page']['left']) || !empty($variables['page']['right'])) {
$variables['main_columns'] = 'large-9';
} elseif (empty($variables['page']['left']) && empty($variables['page']['right'])) {
$variables['main_columns'] = 'large-12';
}
}
/**
* Overwrite theme_button().
*/
function foundation_button($variables)
{
$element = $variables['element'];
$element['#attributes']['type'] = 'submit';
element_set_attributes($element, array('id', 'name', 'value'));
$element['#attributes']['class'][] = 'form-'.$element['#button_type'];
if (!empty($element['#attributes']['disabled'])) {
$element['#attributes']['class'][] = 'form-button-disabled';
}
//custom class
$element['#attributes']['class'][] = 'button';
$element['#attributes']['class'][] = 'small';
$element['#attributes']['class'][] = 'radius';
return '<input'.drupal_attributes($element['#attributes']).' />';
}
/**
* Override theme_breadcrumb().
**/
function foundation_breadcrumb($variables)
{
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
$output = '<ul class="breadcrumbs">';
foreach ($breadcrumb as $value) {
$output .= '<li>'.$value.'</li>';
}
$output .= '</ul>';
return $output;
}
}
/**
* Override theme_status_messages().
**/
function foundation_status_messages($variables)
{
$display = $variables['display'];
$output = '';
$status_heading = array(
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
);
foreach (drupal_get_messages($display) as $type => $messages) {
//convert to foundation classes
switch ($type) {
case 'error': $type = 'alert';
break;
case 'status': $type = 'success';
break;
case 'warning': $type = 'warning';
break;
}
$output .= "<div class=\"callout $type\" data-closable>";
if (!empty($status_heading[$type])) {
$output .= '<h2 class="element-invisible">'.$status_heading[$type].'</h2>';
}
if (count($messages) > 1) {
$output .= ' <ul>';
foreach ($messages as $message) {
$output .= ' <li>'.$message.'</li>';
}
$output .= ' </ul>';
} else {
$output .= $messages[0];
}
$output .= '<button class="close-button" aria-label="Close alert" type="button" data-close><span aria-hidden="true">×</span></button></div>';
}
return $output;
}
/**
* Override theme_menu_local_task().
**/
function foundation_menu_local_task($variables)
{
$link = $variables['element']['#link'];
$link_text = $link['title'];
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));
}
return '<dd'.(!empty($variables['element']['#active']) ? ' class="tabs-title is-active"' : ' class="tabs-title"').'>'.l($link_text, $link['href'], $link['localized_options'])."</dd>\n";
}