/
template.php
executable file
·238 lines (193 loc) · 9.49 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
234
235
236
237
238
<?php
/**
* @file
* Teamwork15 parent theme template functions
*
*/
/**
* Implements hook_preprocess_maintenance_page().
*/
function teamwork_15_preprocess_maintenance_page(&$variables) {
backdrop_add_css(backdrop_get_path('theme', 'bartik') . '/css/maintenance-page.css');
}
/**
* Implements hook_preprocess_layout().
*/
function teamwork_15_preprocess_layout(&$variables) {
if ($variables['content']['header']) {
$variables['content']['header'] = '<div class="l-header-inner">' . $variables['content']['header'] . '</div>';
}
if (theme_get_setting('teamwork_15_cdn') > 0)
{
backdrop_add_css('http://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/pure-min.css', array('type' => 'external', 'every_page' => TRUE, 'group' => CSS_DEFAULT));
}
$var1 = theme_get_setting('teamwork_15_juiced_main_background');
$var2 = theme_get_setting('teamwork_15_juiced_big_statement_background');
$var3 = theme_get_setting('teamwork_15_juiced_main_background_blurred');
$var4 = theme_get_setting('teamwork_15_juiced_big_statement_background_blurred');
if ($var1 && $var3 > 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .juiced-main::before { content: ' '; width: 100%; height: 100%; display: block; position: absolute; z-index: -100; -webkit-filter: blur(20px); -moz-filter: blur(20px); -o-filter: blur(20px); -ms-filter: blur(20px); filter: blur(20px); opacity: 0.4; background: url($var1) no-repeat; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if ($var1 && $var3 == 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .juiced-main { background: url($var1) no-repeat; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if ($var2 && $var4 > 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .l-big-statement::before { content: ' '; width: 100%; height: 100%; display: block; position: absolute; z-index: -100; -webkit-filter: blur(20px); -moz-filter: blur(20px); -o-filter: blur(20px); -ms-filter: blur(20px); filter: blur(20px); opacity: 0.4; background: url($var2) no-repeat fixed; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if ($var2 && $var4 == 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .l-big-statement { background: url($var2) no-repeat fixed; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
$var5 = theme_get_setting('teamwork_15_body_main_background');
$var6 = theme_get_setting('teamwork_15_footer_main_background');
$var7 = theme_get_setting('teamwork_15_body_main_background_blurred');
$var8 = theme_get_setting('teamwork_15_footer_main_background_blurred');
if ($var5 && $var7 > 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .layout::before { content: ' '; width: 100%; height: 100%; display: block; position: absolute; z-index: -100; -webkit-filter: blur(20px); -moz-filter: blur(20px); -o-filter: blur(20px); -ms-filter: blur(20px); filter: blur(20px); opacity: 0.4; background: url($var5) no-repeat; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if ($var5 && $var7 == 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { .layout { background: url($var5) no-repeat; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if ($var6 && $var8 > 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { footer.l-footer::before { content: ' '; width: 100%; height: 100%; display: block; position: absolute; z-index: -100; -webkit-filter: blur(20px); -moz-filter: blur(20px); -o-filter: blur(20px); -ms-filter: blur(20px); filter: blur(20px); opacity: 0.4; background: url($var6) no-repeat fixed; background-size: cover; background-position: center; } footer.l-footer { background: transparent; } }", array('type' => 'inline'));
}
if ($var6 && $var8 == 0)
{
backdrop_add_css("@media screen and (min-width: 769px) { footer.l-footer { background: url($var6) no-repeat fixed; background-size: cover; background-position: center; } }", array('type' => 'inline'));
}
if (theme_get_setting('teamwork_15_script1') > 0)
{
backdrop_add_js("https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js", array('type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, 'preprocess' => TRUE));
}
if (theme_get_setting('teamwork_15_script2') > 0)
{
backdrop_add_js("https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js", array('type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, 'preprocess' => TRUE));
}
if (theme_get_setting('teamwork_15_script3') > 0)
{
backdrop_add_js("https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", array('type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, 'preprocess' => TRUE));
}
if (theme_get_setting('teamwork_15_script4') > 0)
{
backdrop_add_js("https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.4/hammer.min.js", array('type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, 'preprocess' => TRUE));
}
// backdrop_add_js("themes/teamwork_15/js/scripts.js", array('type' => 'file', 'scope' => 'footer', 'every_page' => TRUE, 'preprocess' => TRUE));
// backdrop_add_js("document.write('<script src=\"http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1\"></' + 'script>')", array('type' => 'inline', 'scope' => 'footer', 'weight' => 9999));
}
/**
* Implements theme_field__field_type().
*/
function teamwork_15_field__taxonomy_term_reference($variables) {
$output = '';
// Render the label, if it's not hidden.
if (!$variables['label_hidden']) {
$output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
}
// Render the items.
$output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
foreach ($variables['items'] as $delta => $item) {
$item_attributes = (isset($variables['item_attributes'][$delta])) ? backdrop_attributes($variables['item_attributes'][$delta]) : '';
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $item_attributes . '>' . backdrop_render($item) . '</li>';
}
$output .= '</ul>';
// Render the surrounding DIV with appropriate classes and attributes.
if (!in_array('clearfix', $variables['classes'])) {
$variables['classes'][] = 'clearfix';
}
$output = '<div class="' . implode(' ', $variables['classes']) . '"' . backdrop_attributes($variables['attributes']) . '>' . $output . '</div>';
return $output;
}
/**
* Implements theme_preprocess_image_style().
*/
function teamwork_15_preprocess_image_style(&$vars) {
$vars['attributes']['class'][] = 'pure-img';
}
function teamwork_15_button(&$vars) {
$classes = array('button-success', 'pure-button-primary', 'button-xlarge', 'pure-button');
if (!isset($vars['#attributes']['class'])) {
$vars['#attributes'] = array('class' => $classes);
}
else {
$vars['#attributes']['class'] = array_merge($vars['#attributes']['class'], $classes);
}
if (!isset($vars['element']['#attributes']['class'])) {
$vars['element']['#attributes'] = array('class' => $classes);
}
else {
$vars['element']['#attributes']['class'] = array_merge($vars['element']['#attributes']['class'], $classes);
}
return theme_button($vars);
}
function teamwork_15_css_alter(&$css) {
if (theme_get_setting('teamwork_15_cdn') > 0)
{
$css_to_remove = array();
$css_to_remove[] = backdrop_get_path('theme','teamwork_15') . '/css/pure.min.css';
foreach ($css_to_remove as $index => $css_file) {
unset($css[$css_file]);
}
}
}
/**
* Implements hook_form_alter()
*/
function teamwork_15_form_alter(&$form, &$form_state, $form_id) {
$classes = array('pure-form', 'pure-form-aligned');
if (!isset($form['#attributes']['class'])) {
$form['#attributes'] = array('class' => $classes);
}
else {
$form['#attributes']['class'] = array_merge($form['#attributes']['class'], $classes);
}
}
function teamwork_15_menu_tree($variables) {
return '<ul class="menu">' . $variables['tree'] . '</ul>';
}
/**
* Overrides theme_form_element_label().
*/
function teamwork_15_form_element_label(&$variables) {
$element = $variables['element'];
$title = filter_xss_admin($element['#title']);
// If the element is required, a required marker is appended to the label.
$required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
// // This is also used in the installer, pre-database setup.
$t = get_t();
$attributes = array();
if (!empty($element['#id'])) {
$attributes['for'] = $element['#id'];
}
$output = '';
if (isset($variables['#children'])) {
if ($element['#type'] === "radio")
{
$output .= $variables['#children'];
}
if ($element['#type'] === "checkbox")
{
$output .= $variables['#children'];
}
}
return ' <label' . backdrop_attributes($attributes) . '></label><div>' . $t('!title', array('!title' => $title)) . "</div> \n";
}
/**
* Implements theme_preprocess_menu_link().
*/
function teamwork_15_menu_link(array $variables) {
$element = $variables['element'];
$classes = array('pure-menu-item');
$element['#attributes']['class'] = array_merge($element['#attributes']['class'], $classes);
$sub_menu = '';
if ($element['#below']) {
$sub_menu = backdrop_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . backdrop_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}