1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Build and save the responsive layouts and styles
|
6
|
*
|
7
|
* This is the main submit handler for building the core layout and processing
|
8
|
* the responsive stylesheets. The output is five stylesheets saved to public
|
9
|
* files - the main responsive layout, two conditional stylesheets, the main
|
10
|
* responsive styles (the aggregated styles with embedded media queries) and a
|
11
|
* default layout CSS file (for when desktop first method has been selected).
|
12
|
*/
|
13
|
function at_core_submit_reponsive($values, $theme_name, $path) {
|
14
|
global $path_to_at_core;
|
15
|
|
16
|
// Set up some paths we use to get and save files
|
17
|
$path_to_responsive_css = drupal_get_path('theme', $theme_name) . '/css/';
|
18
|
$path_to_panels_css = $path_to_at_core . '/layouts/css/';
|
19
|
|
20
|
// Initialize
|
21
|
$smalltouch_landscape_panels_data = array();
|
22
|
|
23
|
// Get the page layout config array
|
24
|
$layout_variables = page_layout();
|
25
|
|
26
|
// $layouts will hold all the page level layouts
|
27
|
$layouts = array();
|
28
|
|
29
|
// Initialize the $is_default_layout variable, we use this to test against
|
30
|
$is_default_layout = $values['global_default_layout'];
|
31
|
|
32
|
// Get the panels config array
|
33
|
$rpl = responsive_panels_data_structure();
|
34
|
|
35
|
// We need to add a float to some panels layouts in certain instances
|
36
|
$float = ".at-panel .region {display:inline;float:left}";
|
37
|
|
38
|
// Holds all styles from the responsive stylesheets
|
39
|
$responsive_styles = array();
|
40
|
$panel_subtypes = array();
|
41
|
$panel_styles = array();
|
42
|
|
43
|
// Get the values for the panels layouts
|
44
|
unset($rpl['one']); // unset panels layout one, it has no layout data
|
45
|
foreach ($rpl as $grouped => $panels_layout_groups) {
|
46
|
foreach ($panels_layout_groups as $panel_layout_group) {
|
47
|
foreach ($panel_layout_group as $group_items => $item_value) {
|
48
|
$panel_subtypes[] = $item_value['theme'];
|
49
|
if (array_key_exists('styles', $item_value)) {
|
50
|
$panel_styles[] = $item_value['styles'];
|
51
|
}
|
52
|
}
|
53
|
}
|
54
|
}
|
55
|
|
56
|
// If the Cascading media queries CSS file is enabled, load these styles first
|
57
|
if ($values['enable_custom_media_queries'] === 1) {
|
58
|
if (file_exists($path_to_responsive_css . 'responsive.custom.css')) {
|
59
|
$responsive_css = drupal_load_stylesheet($path_to_responsive_css . 'responsive.custom.css', FALSE);
|
60
|
$responsive_styles[] = $responsive_css . "\n";
|
61
|
}
|
62
|
}
|
63
|
|
64
|
// Set variables for respond.js
|
65
|
$load_respondjs = FALSE;
|
66
|
if ($values['load_respondjs'] === 1) {
|
67
|
$load_respondjs = TRUE;
|
68
|
}
|
69
|
|
70
|
// Set variables for onmediaquery.js and media_queries.js
|
71
|
$responsive_js_css = '';
|
72
|
$responsive_js = FALSE;
|
73
|
if ($values['load_onmediaqueryjs'] === 1 && $values['disable_responsive_styles'] === 0) {
|
74
|
$responsive_js = TRUE;
|
75
|
}
|
76
|
|
77
|
// Gutter width
|
78
|
$gutters = "/* Gutters are not currently overridden in theme settings, but may be in theme CSS */";
|
79
|
if (isset($values['enable_markup_overides']) && $values['enable_markup_overides'] === 1) {
|
80
|
if (isset($values['global_gutter_width']) && is_numeric($values['global_gutter_width'])) {
|
81
|
$gutter = check_plain($values['global_gutter_width']) . 'px';
|
82
|
$gutters = "/* Gutters */" . "\n" . "#main-content,.block-inner,.pane-inner,.menu-wrapper,.branding-elements,.breadcrumb-wrapper,.attribution,.at-panel .rounded-corner,.block-panels-mini > .block-title,.rendered-by-ds .at-panel .region-inner,div.messages,.at-gutter {margin-left:$gutter;margin-right:$gutter;} #content .panel-display,#content .panel-flexible {margin-left:-$gutter;margin-right:-$gutter;}";
|
83
|
}
|
84
|
}
|
85
|
|
86
|
// Smalltouch Portrait
|
87
|
if ($values['smalltouch_portrait_media_query']) {
|
88
|
|
89
|
$device = 'smalltouch_portrait';
|
90
|
|
91
|
// Build an array of page layout settings values
|
92
|
foreach ($layout_variables as $key => $value) {
|
93
|
if (isset($values["$device" . '_' . "$value"])) {
|
94
|
$smalltouch_portrait_layout_data[$value] = filter_xss_admin($values["$device" . '_' . "$value"]);
|
95
|
}
|
96
|
}
|
97
|
// In smalltouch portrait we invoke the layout builder, but the values are not
|
98
|
// used since the CSS is actually hard coded. I have done this because, at some
|
99
|
// stage in the future this layout might not be hard coded and we might really
|
100
|
// need to return a dynamically built layout. Note that $layout is only ever
|
101
|
// used in desktop first - never in mobile first.
|
102
|
$layout = at_build_page_layout($smalltouch_portrait_layout_data['layout'], $smalltouch_portrait_layout_data['sidebar_first'], $smalltouch_portrait_layout_data['sidebar_second'], $smalltouch_portrait_layout_data['sidebar_unit'], $theme_name);
|
103
|
|
104
|
$method = $smalltouch_portrait_layout_data['layout'];
|
105
|
$comment = "/* $device $method */\n";
|
106
|
$width = "\n" . '.container {width:' . $smalltouch_portrait_layout_data['page_width'] . $smalltouch_portrait_layout_data['page_unit'] . '}';
|
107
|
$media_query = $smalltouch_portrait_layout_data['media_query'];
|
108
|
|
109
|
if ($responsive_js == TRUE) {
|
110
|
$responsive_js_css = 'html {font-family: smalltouch_portrait} /* Font family for media_queries.js */';
|
111
|
}
|
112
|
|
113
|
// If mobile first then smalltouch portrait needs to do nothing, else its
|
114
|
// problematic to set the layout later due to the cascade and inheritance
|
115
|
if ($is_default_layout === 'smalltouch-portrait') {
|
116
|
$css = '';
|
117
|
// If responsive js is TRUE we output the media query with CSS styles
|
118
|
if ($responsive_js == TRUE) {
|
119
|
$css = $comment . '@media ' . $media_query . ' {' . "\n" . $responsive_js_css . "\n" . '}';
|
120
|
}
|
121
|
}
|
122
|
else {
|
123
|
// Smalltouch portrait panels are all 100% width and stacked, we need to
|
124
|
// overpower the default layouts when in desktop first mode
|
125
|
$smalltouch_portrait_panels_layout = '.at-panel .region,.at-panel .panel-row,.at-panel .panel-row .region,.at-panel .inset-wrapper{float:none;display:block;width:100%}';
|
126
|
|
127
|
// Build the styles string
|
128
|
$styles = $width . "\n" . $layout . "\n" . $smalltouch_portrait_panels_layout;
|
129
|
|
130
|
// Reset styles if we are loading responsive js
|
131
|
if ($responsive_js == TRUE) {
|
132
|
$styles = "\n" . $responsive_js_css . "\n" . $width . "\n" . $layout . "\n" . $smalltouch_portrait_panels_layout;
|
133
|
}
|
134
|
|
135
|
// CSS wrapped in the media query
|
136
|
$css = $comment . '@media ' . $media_query . ' {' . $styles . "\n" . '}';
|
137
|
}
|
138
|
|
139
|
// Get and wrap the responsive CSS styles in the relative media query
|
140
|
$responsive_smalltouch_portrait_css = '';
|
141
|
if (file_exists($path_to_responsive_css . 'responsive.smalltouch.portrait.css')) {
|
142
|
$responsive_smalltouch_portrait_css = $path_to_responsive_css . 'responsive.smalltouch.portrait.css';
|
143
|
}
|
144
|
// Legacy support for pre 7.x-3.2 subthemes
|
145
|
elseif (file_exists($path_to_responsive_css . 'responsive.smartphone.portrait.css')) {
|
146
|
$responsive_smalltouch_portrait_css = $path_to_responsive_css . 'responsive.smartphone.portrait.css';
|
147
|
}
|
148
|
if (!empty($responsive_smalltouch_portrait_css)) {
|
149
|
$responsive_css = drupal_load_stylesheet($responsive_smalltouch_portrait_css, FALSE);
|
150
|
$responsive_styles[] = '@media ' . $media_query . ' {' . "\n" . $responsive_css . "\n" . '}';
|
151
|
}
|
152
|
|
153
|
$layouts[] = $css;
|
154
|
}
|
155
|
|
156
|
// Smalltouch Landscape
|
157
|
if ($values['smalltouch_landscape_layout']) {
|
158
|
|
159
|
$device = 'smalltouch_landscape';
|
160
|
|
161
|
// Build an array of page layout settings values
|
162
|
foreach ($layout_variables as $key => $value) {
|
163
|
if (isset($values["$device" . '_' . "$value"])) {
|
164
|
$smalltouch_landscape_layout_data[$value] = check_plain($values["$device" . '_' . "$value"]);
|
165
|
}
|
166
|
}
|
167
|
$layout = at_build_page_layout($smalltouch_landscape_layout_data['layout'], $smalltouch_landscape_layout_data['sidebar_first'], $smalltouch_landscape_layout_data['sidebar_second'], $smalltouch_landscape_layout_data['sidebar_unit'], $theme_name);
|
168
|
|
169
|
$method = $smalltouch_landscape_layout_data['layout'];
|
170
|
$comment = "/* $device $method */\n";
|
171
|
$width = "\n" . '.container {width:' . $smalltouch_landscape_layout_data['page_width'] . $smalltouch_landscape_layout_data['page_unit'] . '}';
|
172
|
$media_query = $smalltouch_landscape_layout_data['media_query'];
|
173
|
|
174
|
// Get the panel layout settings
|
175
|
foreach ($panel_subtypes as $subtype) {
|
176
|
$smalltouch_landscape_panel_settings[] = $device . '_' . $subtype;
|
177
|
}
|
178
|
|
179
|
foreach ($smalltouch_landscape_panel_settings as $setting) {
|
180
|
if (!empty($values[$setting])) {
|
181
|
$option = $values[$setting];
|
182
|
}
|
183
|
else {
|
184
|
// Provide a fallback layout in case settings fail during submit
|
185
|
$smalltouch_landscape_panel_substr_setting = substr($setting, 21);
|
186
|
$smalltouch_landscape_panel_substr_setting = str_replace('_', '-', $smalltouch_landscape_panel_substr_setting) . '-stack';
|
187
|
$option = $smalltouch_landscape_panel_substr_setting;
|
188
|
}
|
189
|
$smalltouch_landscape_panels_data[] = $option;
|
190
|
}
|
191
|
|
192
|
// Generate the panels layouts
|
193
|
$smalltouch_landscape_panels_css = at_build_panels_layout_css($panel_styles, $smalltouch_landscape_panels_data);
|
194
|
$panels_layouts = $float . $smalltouch_landscape_panels_css;
|
195
|
|
196
|
// Build the styles string
|
197
|
$styles = $width . "\n" . $layout . "\n" . $panels_layouts;
|
198
|
|
199
|
// Reset styles if we are loading responsive js
|
200
|
if ($responsive_js == TRUE) {
|
201
|
$responsive_js_css = "\n" . 'html {font-family: smalltouch_landscape} /* Font family for media_queries.js */';
|
202
|
$styles = $responsive_js_css . $width . "\n" . $layout . "\n" . $panels_layouts;
|
203
|
}
|
204
|
|
205
|
// CSS wrapped in the media query
|
206
|
$css = $comment . '@media ' . $media_query . ' {' . $styles . "\n" . '}';
|
207
|
|
208
|
// Get and wrap the responsive CSS styles in the relative media query
|
209
|
$responsive_smalltouch_landscape_css = '';
|
210
|
if (file_exists($path_to_responsive_css . 'responsive.smalltouch.landscape.css')) {
|
211
|
$responsive_smalltouch_landscape_css = $path_to_responsive_css . 'responsive.smalltouch.landscape.css';
|
212
|
}
|
213
|
// Legacy support for pre 7.x-3.2 subthemes
|
214
|
elseif (file_exists($path_to_responsive_css . 'responsive.smartphone.landscape.css')) {
|
215
|
$responsive_smalltouch_landscape_css = $path_to_responsive_css . 'responsive.smartphone.landscape.css';
|
216
|
}
|
217
|
if (!empty($responsive_smalltouch_landscape_css)) {
|
218
|
$responsive_css = drupal_load_stylesheet($responsive_smalltouch_landscape_css, FALSE);
|
219
|
$responsive_styles[] = '@media ' . $media_query . ' {' . "\n" . $responsive_css . "\n" . '}';
|
220
|
}
|
221
|
|
222
|
$layouts[] = $css;
|
223
|
}
|
224
|
|
225
|
// Tablet Portrait
|
226
|
if ($values['tablet_portrait_layout']) {
|
227
|
|
228
|
$device = 'tablet_portrait';
|
229
|
|
230
|
// Build an array of page layout settings values
|
231
|
foreach ($layout_variables as $key => $value) {
|
232
|
if (isset($values["$device" . '_' . "$value"])) {
|
233
|
$tablet_portrait_layout_data[$value] = check_plain($values["$device" . '_' . "$value"]);
|
234
|
}
|
235
|
}
|
236
|
// Workaround upgrade issues for some settings
|
237
|
if ($tablet_portrait_layout_data['layout'] == 'two_col_stack') {
|
238
|
$tablet_portrait_layout_data['layout'] = 'two_sidebars_right_stack';
|
239
|
}
|
240
|
$layout = at_build_page_layout($tablet_portrait_layout_data['layout'], $tablet_portrait_layout_data['sidebar_first'], $tablet_portrait_layout_data['sidebar_second'], $tablet_portrait_layout_data['sidebar_unit'], $theme_name);
|
241
|
|
242
|
$method = $tablet_portrait_layout_data['layout'];
|
243
|
$comment = "/* $device $method */\n";
|
244
|
$width = "\n" . '.container {width:' . $tablet_portrait_layout_data['page_width'] . $tablet_portrait_layout_data['page_unit'] . '}';
|
245
|
$media_query = $tablet_portrait_layout_data['media_query'];
|
246
|
|
247
|
$tablet_portrait_panel_settings = array();
|
248
|
$tablet_portrait_panels_data = array();
|
249
|
// Get the panel layout settings and CSS for these layouts
|
250
|
foreach ($panel_subtypes as $subtype) {
|
251
|
$tablet_portrait_panel_settings[] = $device . '_' . $subtype;
|
252
|
}
|
253
|
|
254
|
foreach ($tablet_portrait_panel_settings as $setting) {
|
255
|
if (!empty($values[$setting])) {
|
256
|
$option = $values[$setting];
|
257
|
}
|
258
|
else {
|
259
|
// Provide a fallback layout in case settings fail during submit
|
260
|
$tablet_portrait_panel_substr_setting = substr($setting, 16);
|
261
|
$tablet_portrait_panel_substr_setting = str_replace('_', '-', $tablet_portrait_panel_substr_setting);
|
262
|
$option = $tablet_portrait_panel_substr_setting;
|
263
|
}
|
264
|
$tablet_portrait_panels_data[] = $option;
|
265
|
}
|
266
|
|
267
|
// Generate the panels layouts
|
268
|
$tablet_portrait_panels_css = at_build_panels_layout_css($panel_styles, $tablet_portrait_panels_data);
|
269
|
$panels_layouts = $float . $tablet_portrait_panels_css;
|
270
|
|
271
|
// Build the styles string
|
272
|
$styles = $width . "\n" . $layout . "\n" . $panels_layouts;
|
273
|
|
274
|
// Reset styles if we are loading responsive js
|
275
|
if ($responsive_js == TRUE) {
|
276
|
$responsive_js_css = "\n" . 'html {font-family: tablet_portrait} /* Font family for media_queries.js */';
|
277
|
$styles = $responsive_js_css . $width . "\n" . $layout . "\n" . $panels_layouts;
|
278
|
}
|
279
|
|
280
|
// CSS wrapped in the media query
|
281
|
$css = $comment . '@media ' . $media_query . ' {' . $styles . "\n" . '}';
|
282
|
|
283
|
// Get and wrap the responsive CSS styles in the relative media query
|
284
|
if (file_exists($path_to_responsive_css . 'responsive.tablet.portrait.css')) {
|
285
|
$responsive_css = drupal_load_stylesheet($path_to_responsive_css . 'responsive.tablet.portrait.css', FALSE);
|
286
|
$responsive_styles[] = '@media ' . $media_query . ' {' . "\n" . $responsive_css . "\n" . '}';
|
287
|
}
|
288
|
|
289
|
$layouts[] = $css;
|
290
|
}
|
291
|
|
292
|
// Tablet Landscape
|
293
|
if ($values['tablet_landscape_layout']) {
|
294
|
|
295
|
$device = 'tablet_landscape';
|
296
|
|
297
|
// Build an array of page layout settings values
|
298
|
foreach ($layout_variables as $key => $value) {
|
299
|
if (isset($values["$device" . '_' . "$value"])) {
|
300
|
$tablet_landscape_layout_data[$value] = check_plain($values["$device" . '_' . "$value"]);
|
301
|
}
|
302
|
}
|
303
|
// Workaround upgrade issues for some settings
|
304
|
if ($tablet_portrait_layout_data['layout'] == 'two_col_stack') {
|
305
|
$tablet_portrait_layout_data['layout'] = 'two_sidebars_right_stack';
|
306
|
}
|
307
|
$layout = at_build_page_layout($tablet_landscape_layout_data['layout'], $tablet_landscape_layout_data['sidebar_first'], $tablet_landscape_layout_data['sidebar_second'], $tablet_landscape_layout_data['sidebar_unit'], $theme_name);
|
308
|
|
309
|
$method = $tablet_landscape_layout_data['layout'];
|
310
|
$comment = "/* $device $method */\n";
|
311
|
$width = "\n" . '.container {width:' . $tablet_landscape_layout_data['page_width'] . $tablet_landscape_layout_data['page_unit'] . '}';
|
312
|
$media_query = $tablet_landscape_layout_data['media_query'];
|
313
|
|
314
|
// Get the panel layout settings
|
315
|
foreach ($panel_subtypes as $subtype) {
|
316
|
$tablet_landscape_panel_settings[] = $device . '_' . $subtype;
|
317
|
}
|
318
|
foreach ($tablet_landscape_panel_settings as $setting) {
|
319
|
if (!empty($values[$setting])) {
|
320
|
$option = $values[$setting];
|
321
|
}
|
322
|
else {
|
323
|
// Provide a fallback layout in case settings fail during submit
|
324
|
$tablet_landscape_panel_substr_setting = substr($setting, 17);
|
325
|
$tablet_landscape_panel_substr_setting = str_replace('_', '-', $tablet_landscape_panel_substr_setting);
|
326
|
$option = $tablet_landscape_panel_substr_setting;
|
327
|
}
|
328
|
$tablet_landscape_panels_data[] = $option;
|
329
|
}
|
330
|
// Generate the panels layouts
|
331
|
$tablet_landscape_panels_css = at_build_panels_layout_css($panel_styles, $tablet_landscape_panels_data);
|
332
|
$panels_layouts = $float . $tablet_landscape_panels_css;
|
333
|
|
334
|
// Build the styles string
|
335
|
$styles = $width . "\n" . $layout . "\n" . $panels_layouts;
|
336
|
|
337
|
// Reset styles if we are loading responsive js
|
338
|
if ($responsive_js == TRUE) {
|
339
|
$responsive_js_css = "\n" . 'html {font-family: tablet_landscape} /* Font family for media_queries.js */';
|
340
|
$styles = $responsive_js_css . $width . "\n" . $layout . "\n" . $panels_layouts;
|
341
|
}
|
342
|
|
343
|
// CSS wrapped in the media query
|
344
|
$css = $comment . '@media ' . $media_query . ' {' . $styles . "\n" . '}';
|
345
|
|
346
|
// Get and wrap the responsive CSS styles in the relative media query
|
347
|
if (file_exists($path_to_responsive_css . 'responsive.tablet.landscape.css')) {
|
348
|
$responsive_css = drupal_load_stylesheet($path_to_responsive_css . 'responsive.tablet.landscape.css', FALSE);
|
349
|
$responsive_styles[] = '@media ' . $media_query . ' {' . "\n" . $responsive_css . "\n" . '}';
|
350
|
}
|
351
|
|
352
|
$layouts[] = $css;
|
353
|
}
|
354
|
|
355
|
// Standard Layout (bigscreen)
|
356
|
if ($values['bigscreen_layout']) {
|
357
|
|
358
|
$device = 'bigscreen';
|
359
|
|
360
|
// Build an array of page layout settings values
|
361
|
foreach ($layout_variables as $key => $value) {
|
362
|
if (isset($values["$device" . '_' . "$value"])) {
|
363
|
$bigscreen_layout_data[$value] = check_plain($values["$device" . '_' . "$value"]);
|
364
|
}
|
365
|
}
|
366
|
$layout = at_build_page_layout($bigscreen_layout_data['layout'], $bigscreen_layout_data['sidebar_first'], $bigscreen_layout_data['sidebar_second'], $bigscreen_layout_data['sidebar_unit'], $theme_name);
|
367
|
|
368
|
$method = $bigscreen_layout_data['layout'];
|
369
|
$comment = "/* $device $method */";
|
370
|
$width = "\n" . '.container {width:' . $bigscreen_layout_data['page_width'] . $bigscreen_layout_data['page_unit'] . '}';
|
371
|
$media_query = $bigscreen_layout_data['media_query'];
|
372
|
|
373
|
// Standard layout can have a max-width
|
374
|
if ($values['bigscreen_set_max_width'] === 1 && $bigscreen_layout_data['page_unit'] === '%') {
|
375
|
if (!empty($values['bigscreen_max_width'])) {
|
376
|
$width = "\n" . '.container {width:' . $bigscreen_layout_data['page_width'] . $bigscreen_layout_data['page_unit'] . ';max-width:' . $values['bigscreen_max_width'] . $values['bigscreen_max_width_unit'] . '}';
|
377
|
}
|
378
|
else {
|
379
|
$width = "\n" . '.container {width:' . $bigscreen_layout_data['page_width'] . $bigscreen_layout_data['page_unit'] . ';max-width:' . $values['bigscreen_max_width'] . $values['bigscreen_max_width_unit'] . '}';
|
380
|
}
|
381
|
}
|
382
|
$bigscreen_panels_data = array();
|
383
|
// Get the panel layout settings
|
384
|
foreach ($panel_subtypes as $subtype) {
|
385
|
$bigscreen_panel_settings[] = $device . '_' . $subtype;
|
386
|
}
|
387
|
foreach ($bigscreen_panel_settings as $setting) {
|
388
|
if (!empty($values[$setting])) {
|
389
|
$option = $values[$setting];
|
390
|
}
|
391
|
else {
|
392
|
// Provide a fallback layout in case settings fail during submit
|
393
|
$bigscreen_panel_substr_setting = substr($setting, 16);
|
394
|
$bigscreen_panel_substr_setting = str_replace('_', '-', $bigscreen_panel_substr_setting);
|
395
|
$option = $bigscreen_panel_substr_setting;
|
396
|
}
|
397
|
$bigscreen_panels_data[] = $option;
|
398
|
}
|
399
|
// Generate the panels layouts
|
400
|
$bigscreen_panels_css = at_build_panels_layout_css($panel_styles, $bigscreen_panels_data);
|
401
|
|
402
|
// Prepend the float
|
403
|
$panels_layouts = $float . $bigscreen_panels_css;
|
404
|
|
405
|
// Build the styles string
|
406
|
$styles = $width . "\n" . $layout . "\n" . $panels_layouts;
|
407
|
|
408
|
// Reset styles if we are loading responsive js
|
409
|
if ($responsive_js == TRUE) {
|
410
|
$responsive_js_css = "\n" . 'html {font-family: standard} /* Font family for media_queries.js */';
|
411
|
$styles = $responsive_js_css . $width . "\n" . $layout . "\n" . $panels_layouts;
|
412
|
}
|
413
|
|
414
|
// We need to do some conditional checks to account for the users settings:
|
415
|
// - is this mobile first or desktop first?
|
416
|
// - is the responsive capability disabled?
|
417
|
|
418
|
// Mobile first or Desktop first?
|
419
|
if ($is_default_layout === 'standard-layout') {
|
420
|
// DESKTOP FIRST
|
421
|
// Just the responsive js font family
|
422
|
$css = '';
|
423
|
if ($responsive_js == TRUE) {
|
424
|
$css = $comment . "\n" . '@media ' . $media_query . ' {' . $responsive_js_css . "\n" . '}';
|
425
|
}
|
426
|
|
427
|
// Prepare a "default layout" for output to file when desktop first
|
428
|
$desktop_first_layout = $gutters . "\n" . $comment . $styles . "\n";
|
429
|
}
|
430
|
else {
|
431
|
// MOIBLE FIRST
|
432
|
$css = $comment . "\n" . '@media ' . $media_query . ' {' . $styles . "\n" . '}';
|
433
|
$desktop_first_layout = '/* Not likely, this is mobile first - this themer is rocking the hardest! */';
|
434
|
}
|
435
|
|
436
|
// Responsive capability OFF?
|
437
|
if ($values['disable_responsive_styles'] === 1) {
|
438
|
// If its off we have to load something, so we choose to use the bigscreen
|
439
|
// layout and load that
|
440
|
$desktop_first_layout = $gutters . "\n" . $comment . $styles;
|
441
|
}
|
442
|
|
443
|
// add $css to the layouts array
|
444
|
$layouts[] = $css;
|
445
|
}
|
446
|
//****** END bigscreen layout ******//
|
447
|
|
448
|
// Internet Exploder
|
449
|
// We only want to load what is absolutely required for IE, depending on the
|
450
|
// theme settings and what version we are targeting, remember, this only takes
|
451
|
// care of generating the stylesheets so what you see here are lots of messages
|
452
|
// being set for the themer to get a handle on what is going on, load.inc and
|
453
|
// adaptivetheme_preprocess_html() are actually loading the files.
|
454
|
|
455
|
// $lt_ie9_css's assigned values all come from the bigscreen layout, since its
|
456
|
// the last layout to assign values to those variables
|
457
|
$lt_ie9_css = $comment . $width . "\n" . $layout . "\n" . $panels_layouts;
|
458
|
|
459
|
// Reset $lt_ie9_css if we are loading responsive js
|
460
|
if ($responsive_js == TRUE) {
|
461
|
$lt_ie9_css = $comment . $responsive_js_css . $width . "\n" . $layout . "\n" . $panels_layouts;
|
462
|
}
|
463
|
|
464
|
// Get the lt ie8 panels layouts if enabled
|
465
|
$lt_ie8_css = '/* IE6/7 percentage rounding error fixes are OFF */';
|
466
|
if ($values['load_ltie8css'] === 1) {
|
467
|
$ie_panels_layouts = drupal_load_stylesheet($path_to_panels_css . 'ie_defaults.css', FALSE);
|
468
|
$lt_ie8_css = $ie_panels_layouts;
|
469
|
}
|
470
|
|
471
|
// Respond.js is OFF
|
472
|
if ($load_respondjs == FALSE) {
|
473
|
|
474
|
// should we load the IE6/7 rounding error fixes?
|
475
|
if ($values['load_ltie8css'] === 1) {
|
476
|
|
477
|
// add the E6/7 rounding error fixes to $lt_ie9_css, set a message in $lt_ie8_css
|
478
|
$lt_ie9_css = $comment . $width . "\n" . $layout . "\n" . $panels_layouts . "\n" . $ie_panels_layouts;
|
479
|
$lt_ie8_css = '/* The IE6/7 panels layouts are loading in the lt IE9 CSS, to save an HTTP request hit on your server */';
|
480
|
|
481
|
// Desktop first?
|
482
|
if ($is_default_layout === 'standard-layout') {
|
483
|
// repopulate $lt_ie8_css
|
484
|
$lt_ie8_css = $ie_panels_layouts;
|
485
|
}
|
486
|
}
|
487
|
}
|
488
|
|
489
|
// Respond.js is ON
|
490
|
if ($load_respondjs == TRUE) {
|
491
|
$lt_ie9_css = '/* respond.js is loading so we dont load this file. IE6, 7 and 8 will rely on respond.js to work its magic */';
|
492
|
}
|
493
|
|
494
|
// Desktop first?
|
495
|
if ($is_default_layout === 'standard-layout') {
|
496
|
$lt_ie9_css = '/* The standard layout is the default layout, IE styles are not required because you are doing desktop first design */';
|
497
|
}
|
498
|
|
499
|
// Responsive capability OFF?
|
500
|
if ($values['disable_responsive_styles'] === 1) {
|
501
|
$lt_ie9_css = '/* Responsive capabilites are disabled, we no longer need to load an IE specific layout */';
|
502
|
}
|
503
|
|
504
|
// Get and wrap the responsive CSS styles in the relative media query
|
505
|
if (file_exists($path_to_responsive_css . 'responsive.desktop.css')) {
|
506
|
$responsive_css = drupal_load_stylesheet($path_to_responsive_css . 'responsive.desktop.css', FALSE);
|
507
|
$responsive_styles[] = '@media ' . $media_query . ' {' . "\n" . $responsive_css . "\n" . '}';
|
508
|
}
|
509
|
|
510
|
// Generate the layout and responsive styles stylesheets
|
511
|
// Here we generate five files:
|
512
|
// 1. $theme_name.default.layout
|
513
|
// 2. $theme_name.responsive.layout
|
514
|
// 3. $theme_name.lt-ie9.layout
|
515
|
// 4. $theme_name.lt-ie8.layout
|
516
|
// 5. $theme_name.responsive.styles
|
517
|
// adaptivetheme_preprocess_html() will take care of loading the right ones
|
518
|
// when they are needed.
|
519
|
|
520
|
// responsive layout
|
521
|
$responsive_layout_data = implode("\n", $layouts);
|
522
|
|
523
|
// Prepend the gutters to the responsive layout if we're doing mobile first
|
524
|
if ($is_default_layout !== 'standard-layout') {
|
525
|
$responsive_layout = $gutters . "\n" . $responsive_layout_data;
|
526
|
}
|
527
|
else {
|
528
|
$responsive_layout = $responsive_layout_data;
|
529
|
}
|
530
|
|
531
|
// Nuke $responsive_layout if we really don't need it
|
532
|
if ($values['disable_responsive_styles'] == 1) {
|
533
|
$responsive_layout = '/* Responsive capabilites are disabled, only the standard layout is loaded in themename.default.layout.css */';
|
534
|
}
|
535
|
|
536
|
// IE assignments, not sure why I am doing this, could be that I meant to do
|
537
|
// something at this stage and have forgotton for now...
|
538
|
$lt_ie9_layout = $lt_ie9_css;
|
539
|
$lt_ie8_layout = $lt_ie8_css;
|
540
|
|
541
|
// Aggregate the design stylesheets
|
542
|
$responsive_css = implode("\n", $responsive_styles);
|
543
|
|
544
|
// Regex relative paths. This mimics Drupal cores drupal_build_css_cache(), but
|
545
|
// its not as powerful because assets must be relative to the theme root.
|
546
|
$_base = base_path() . $path_to_responsive_css;
|
547
|
_drupal_build_css_path(NULL, $_base);
|
548
|
$responsive_css = preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $responsive_css);
|
549
|
|
550
|
// Build a keyed array: file names as key, layout data as value
|
551
|
$files = array(
|
552
|
"$theme_name.default.layout" => $desktop_first_layout,
|
553
|
"$theme_name.responsive.layout" => $responsive_layout,
|
554
|
"$theme_name.lt-ie9.layout" => $lt_ie9_layout,
|
555
|
"$theme_name.lt-ie8.layout" => $lt_ie8_layout,
|
556
|
"$theme_name.responsive.styles" => $responsive_css,
|
557
|
);
|
558
|
|
559
|
// Loop over the array and save each file, and we're done!
|
560
|
foreach ($files as $key => $value) {
|
561
|
$filepath = "$path/$key.css";
|
562
|
file_unmanaged_save_data($value, $filepath, FILE_EXISTS_REPLACE);
|
563
|
}
|
564
|
}
|