/
template.php
173 lines (156 loc) · 4.99 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
<?php
/**
* Override of theme_breadcrumb().
*/
function sasta_mat_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
return $output;
}
}
/**
* Override or insert variables into the maintenance page template.
*/
function sasta_mat_preprocess_maintenance_page(&$vars) {
// While markup for normal pages is split into page.tpl.php and html.tpl.php,
// the markup for the maintenance page is all in the single
// maintenance-page.tpl.php template. So, to have what's done in
// sasta_mat_preprocess_html() also happen on the maintenance page, it has to be
// called here.
sasta_mat_preprocess_html($vars);
}
/**
* Override or insert variables into the html template.
*/
function sasta_mat_preprocess_html(&$vars) {
// Toggle fixed or fluid width.
drupal_add_css('https://fonts.googleapis.com/icon?family=Material+Icons','external');
if (theme_get_setting('sasta_mat_width') == 'fluid') {
$vars['classes_array'][] = 'fluid-width';
}
// Add conditional CSS for IE6.
drupal_add_css(path_to_theme() . '/fix-ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
}
/**
* Override or insert variables into the html template.
*/
function sasta_mat_process_html(&$vars) {
// Hook into color.module
if (module_exists('color')) {
_color_html_alter($vars);
}
}
/**
* Override or insert variables into the page template.
*/
function sasta_mat_preprocess_page(&$vars) {
// Move secondary tabs into a separate variable.
$vars['tabs2'] = array(
'#theme' => 'menu_local_tasks',
'#secondary' => $vars['tabs']['#secondary'],
);
unset($vars['tabs']['#secondary']);
if (isset($vars['main_menu'])) {
$vars['primary_nav'] = theme('links__system_main_menu', array(
'links' => $vars['main_menu'],
'attributes' => array(
'class' => array('links', 'inline', 'main-menu'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
)
));
}
else {
$vars['primary_nav'] = FALSE;
}
if (isset($vars['secondary_menu'])) {
$vars['secondary_nav'] = theme('links__system_secondary_menu', array(
'links' => $vars['secondary_menu'],
'attributes' => array(
'class' => array('links', 'inline', 'secondary-menu'),
),
'heading' => array(
'text' => t('Secondary menu'),
'level' => 'h2',
'class' => array('element-invisible'),
)
));
}
else {
$vars['secondary_nav'] = FALSE;
}
// Prepare header.
$site_fields = array();
if (!empty($vars['site_name'])) {
$site_fields[] = $vars['site_name'];
}
if (!empty($vars['site_slogan'])) {
$site_fields[] = $vars['site_slogan'];
}
$vars['site_title'] = implode(' ', $site_fields);
if (!empty($site_fields)) {
$site_fields[0] = '<span>' . $site_fields[0] . '</span>';
}
$vars['site_html'] = implode(' ', $site_fields);
// Set a variable for the site name title and logo alt attributes text.
$slogan_text = $vars['site_slogan'];
$site_name_text = $vars['site_name'];
$vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text;
$main_menu = menu_tree_output(menu_tree_all_data('main-menu'));
$vars['main_menu'] = drupal_render($main_menu);
}
/**
* Override or insert variables into the node template.
*/
function sasta_mat_preprocess_node(&$vars) {
$vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];
}
/**
* Override or insert variables into the comment template.
*/
function sasta_mat_preprocess_comment(&$vars) {
$vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
}
/**
* Override or insert variables into the block template.
*/
function sasta_mat_preprocess_block(&$vars) {
$vars['title_attributes_array']['class'][] = 'title';
$vars['classes_array'][] = 'clearfix';
}
/**
* Override or insert variables into the page template.
*/
function sasta_mat_process_page(&$vars) {
// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
}
/**
* Override or insert variables into the region template.
*/
function sasta_mat_preprocess_region(&$vars) {
if ($vars['region'] == 'header') {
$vars['classes_array'][] = 'clearfix';
}
}
function sasta_mat_menu_tree($variables) {
if ($variables['theme_hook_original'] == 'menu_tree__main_menu') {
$output = '<ul class="right hide-on-med-and-down">' . $variables ['tree'] . '</ul>';
} else {
$output = '<ul class="menu">' . $variables ['tree'] . '</ul>';
}
return $output;
}
function sasta_mat_css_alter(&$css) {
// Remove defaults.css file.
unset($css['modules/system/system.menus.css']);
}