-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
200 lines (175 loc) · 5.62 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
<?php
/**
* Page alter.
*/
function bootstrap_scholar_page_alter($page) {
$mobileoptimized = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'MobileOptimized',
'content' => 'width'
)
);
$handheldfriendly = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'HandheldFriendly',
'content' => 'true'
)
);
$viewport = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1'
)
);
drupal_add_html_head($mobileoptimized, 'MobileOptimized');
drupal_add_html_head($handheldfriendly, 'HandheldFriendly');
drupal_add_html_head($viewport, 'viewport');
}
/**
* Preprocess variables for html.tpl.php
*/
function bootstrap_scholar_preprocess_html(&$variables) {
/**
* Add IE8 Support
*/
drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => '(lt IE 9)', '!IE' => FALSE), 'preprocess' => FALSE));
/**
* Bootstrap CDN
*/
if (theme_get_setting('bootstrap_css_cdn', 'bootstrap_scholar')) {
$cdn = '//maxcdn.bootstrapcdn.com/bootstrap/' . theme_get_setting('bootstrap_css_cdn', 'bootstrap_scholar') . '/css/bootstrap.min.css';
drupal_add_css($cdn, array('type' => 'external'));
}
if (theme_get_setting('bootstrap_js_cdn', 'bootstrap_scholar')) {
$cdn = '//maxcdn.bootstrapcdn.com/bootstrap/' . theme_get_setting('bootstrap_js_cdn', 'bootstrap_scholar') . '/js/bootstrap.min.js';
drupal_add_js($cdn, array('type' => 'external'));
}
/**
* Add Javascript for enable/disable scrollTop action
*/
if (theme_get_setting('scrolltop_display', 'bootstrap_scholar')) {
drupal_add_js('jQuery(document).ready(function($) {
$(window).scroll(function() {
if($(this).scrollTop() != 0) {
$("#toTop").fadeIn();
} else {
$("#toTop").fadeOut();
}
});
$("#toTop").click(function() {
$("body,html").animate({scrollTop:0},800);
});
});',
array('type' => 'inline', 'scope' => 'header'));
}
//EOF:Javascript
}
/**
* Override or insert variables into the html template.
*/
function bootstrap_scholar_process_html(&$vars) {
// Hook into color.module
if (module_exists('color')) {
_color_html_alter($vars);
}
}
/**
* Preprocess variables for page template.
*/
function bootstrap_scholar_preprocess_page(&$vars) {
/**
* insert variables into page template.
*/
if($vars['page']['sidebar_first'] && $vars['page']['sidebar_second']) {
$vars['sidebar_grid_class'] = 'col-md-3';
$vars['main_grid_class'] = 'col-md-6';
} elseif ($vars['page']['sidebar_first'] || $vars['page']['sidebar_second']) {
$vars['sidebar_grid_class'] = 'col-md-4';
$vars['main_grid_class'] = 'col-md-8';
} else {
$vars['main_grid_class'] = 'col-md-12';
}
if($vars['page']['header_top_left'] && $vars['page']['header_top_right']) {
$vars['header_top_left_grid_class'] = 'col-md-8';
$vars['header_top_right_grid_class'] = 'col-md-4';
} elseif ($vars['page']['header_top_right'] || $vars['page']['header_top_left']) {
$vars['header_top_left_grid_class'] = 'col-md-12';
$vars['header_top_right_grid_class'] = 'col-md-12';
}
/**
* Removes welcome message in the front page and creates a blank page.
*/
if (drupal_is_front_page() && theme_get_setting('blank_front_page_display')) {
unset($vars['page']['content']['system_main']['default_message']);
drupal_set_title(''); //removes welcome message (page title)
}
/**
* Add Javascript
*/
if($vars['page']['pre_header_first'] || $vars['page']['pre_header_second'] || $vars['page']['pre_header_third']) {
drupal_add_js('
function hidePreHeader(){
jQuery(".toggle-control").html("<a href=\"javascript:showPreHeader()\"><span class=\"glyphicon glyphicon-plus\"></span></a>");
jQuery("#pre-header-inside").slideUp("fast");
}
function showPreHeader() {
jQuery(".toggle-control").html("<a href=\"javascript:hidePreHeader()\"><span class=\"glyphicon glyphicon-minus\"></span></a>");
jQuery("#pre-header-inside").slideDown("fast");
}
',
array('type' => 'inline', 'scope' => 'footer', 'weight' => 3));
}
//EOF:Javascript
}
/**
* Override or insert variables into the page template.
*/
function bootstrap_scholar_process_page(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
}
/**
* Preprocess variables for block.tpl.php
*/
function bootstrap_scholar_preprocess_block(&$variables) {
$variables['classes_array'][]='clearfix';
}
/**
* Override theme_breadrumb().
*
* Print breadcrumbs as a list, with separators.
*/
function bootstrap_scholar_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
$breadcrumb[] = drupal_get_title();
$breadcrumbs = '<ol class="breadcrumb">';
$count = count($breadcrumb) - 1;
foreach ($breadcrumb as $key => $value) {
$breadcrumbs .= '<li>' . $value . '</li>';
}
$breadcrumbs .= '</ol>';
return $breadcrumbs;
}
}
/**
* Search block form alter.
*/
function bootstrap_scholar_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
unset($form['search_block_form']['#title']);
$form['search_block_form']['#title_display'] = 'invisible';
$form_default = t('Search this website...');
$form['search_block_form']['#default_value'] = $form_default;
$form['actions']['submit']['#attributes']['value'][] = '';
$form['search_block_form']['#attributes'] = array('onblur' => "if (this.value == '') {this.value = '{$form_default}';}", 'onfocus' => "if (this.value == '{$form_default}') {this.value = '';}" );
}
}