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