Révision d7f58da2
Ajouté par Florent Torregrosa il y a presque 10 ans
drupal7/sites/all/themes/mayo/template.php | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Construst HTML code for the top/bottom block columns |
|
9 |
* Includes for MAYO css creation form settings. |
|
10 |
*/ |
|
11 |
global $theme_key, $path_to_mayo; |
|
12 |
$theme_key = $GLOBALS['theme_key']; |
|
13 |
$path_to_mayo = drupal_get_path('theme', 'mayo'); |
|
14 |
include_once($path_to_mayo . '/inc/load.inc'); // drupal_add_css() wrappers |
|
15 |
include_once($path_to_mayo . '/inc/get.inc'); // get theme info, settings, css etc |
|
16 |
|
|
17 |
/** |
|
18 |
* Construct HTML code for the top/bottom block columns |
|
10 | 19 |
*/ |
11 | 20 |
function mayo_build_columns($columns) { |
12 | 21 |
$styles = array(); |
... | ... | |
54 | 63 |
return $out; |
55 | 64 |
} |
56 | 65 |
|
57 |
/** |
|
58 |
* Calculate margins of contents and sidebars based on the layout style |
|
59 |
*/ |
|
60 |
function mayo_get_margins($content, $sb_first, $sb_second) { |
|
61 |
$sb_layout_style = theme_get_setting('sidebar_layout_style'); |
|
62 |
|
|
63 |
$c_margin_l = $sf_margin_l = $ss_margin_l = 5; |
|
64 |
$c_margin_r = $sf_margin_r = $ss_margin_r = 5; |
|
65 |
|
|
66 |
switch($sb_layout_style) { |
|
67 |
case 1: |
|
68 |
if ($sb_first) { |
|
69 |
$sf_margin_l = 0; |
|
70 |
} |
|
71 |
else { |
|
72 |
$c_margin_l = 0; |
|
73 |
} |
|
74 |
if ($sb_second) { |
|
75 |
$ss_margin_r = 0; |
|
76 |
} |
|
77 |
else { |
|
78 |
$c_margin_r = 0; |
|
79 |
} |
|
80 |
break; |
|
81 |
case 2: // both sidebars come left |
|
82 |
if ($sb_first) { |
|
83 |
$sf_margin_l = 0; |
|
84 |
} |
|
85 |
else if ($sb_second) { |
|
86 |
$ss_margin_l = 0; |
|
87 |
} |
|
88 |
else { |
|
89 |
$c_margin_l = 0; |
|
90 |
} |
|
91 |
$c_margin_r = 0; |
|
92 |
break; |
|
93 |
case 3: // both sidebars come right |
|
94 |
if ($sb_second) { |
|
95 |
$ss_margin_r = 0; |
|
96 |
} |
|
97 |
else if ($sb_first) { |
|
98 |
$sf_margin_r = 0; |
|
99 |
} |
|
100 |
else { |
|
101 |
$c_margin_r = 0; |
|
102 |
} |
|
103 |
$c_margin_l = 0; |
|
104 |
break; |
|
105 |
} |
|
106 |
$c_margin_style = 'margin-left: ' . $c_margin_l . 'px; margin-right: ' . $c_margin_r . 'px;'; |
|
107 |
$sf_margin_style = 'margin-left: ' . $sf_margin_l . 'px; margin-right: ' . $sf_margin_r . 'px;'; |
|
108 |
$ss_margin_style = 'margin-left: ' . $ss_margin_l . 'px; margin-right: ' . $ss_margin_r . 'px;'; |
|
109 |
|
|
110 |
return array( |
|
111 |
'content' => $c_margin_style, |
|
112 |
'sb_first' => $sf_margin_style, |
|
113 |
'sb_second' => $ss_margin_style, |
|
114 |
); |
|
115 |
} |
|
116 |
|
|
117 | 66 |
/** |
118 | 67 |
* Return a themed breadcrumb links |
119 | 68 |
* |
... | ... | |
141 | 90 |
|
142 | 91 |
/** |
143 | 92 |
* Custom search block form |
144 |
* No 'submit button'
|
|
93 |
* Magnifying glass icon used instead of 'submit button'.
|
|
145 | 94 |
* Use javascript to show/hide the 'search this site' prompt inside of the text field |
146 | 95 |
*/ |
147 | 96 |
function mayo_preprocess_search_block_form(&$variables) { |
... | ... | |
151 | 100 |
|
152 | 101 |
unset($variables['form']['actions']['submit']); |
153 | 102 |
unset($variables['form']['actions']['#children']); |
154 |
$variables['form']['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/search-submit.png'); |
|
103 |
|
|
155 | 104 |
$variables['form']['search_block_form']['#value'] = $prompt; |
156 | 105 |
$variables['form']['search_block_form']['#size'] = theme_get_setting('searchbox_size'); |
157 | 106 |
$variables['form']['search_block_form']['#attributes'] = array( |
... | ... | |
193 | 142 |
* Implements hook_preprocess_html(). |
194 | 143 |
*/ |
195 | 144 |
function mayo_preprocess_html(&$variables) { |
145 |
global $theme_key; |
|
146 |
// Adds classes to <body class=""> |
|
147 |
$settings_array = array( |
|
148 |
'round_corners', |
|
149 |
'dark_messages', |
|
150 |
); |
|
151 |
foreach ($settings_array as $setting) { |
|
152 |
if (theme_get_setting($setting) !== 0) { |
|
153 |
$variables['classes_array'][] = theme_get_setting($setting); |
|
154 |
} |
|
155 |
} |
|
196 | 156 |
|
197 | 157 |
// Add conditional stylesheet for IE |
198 | 158 |
drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); |
... | ... | |
205 | 165 |
'weight' => 10, |
206 | 166 |
); |
207 | 167 |
|
208 |
// Add optional stylesheets |
|
209 |
|
|
210 |
if (theme_get_setting('dark_messages')) { |
|
211 |
// add dark.css if it's selected at the theme setting page. |
|
212 |
drupal_add_css(drupal_get_path('theme', 'mayo') . '/css/dark.css', $options); |
|
213 |
} |
|
214 |
|
|
215 |
$round_corners = theme_get_setting('round_corners'); |
|
216 |
if ($round_corners == 1 || $round_corners == 3) { |
|
217 |
drupal_add_css(drupal_get_path('theme', 'mayo') . '/css/round-sidebar.css', $options); |
|
218 |
} |
|
219 |
if ($round_corners == 2 || $round_corners == 3) { |
|
220 |
drupal_add_css(drupal_get_path('theme', 'mayo') . '/css/round-node.css', $options); |
|
221 |
} |
|
222 |
|
|
223 | 168 |
if (theme_get_setting('menubar_style') == 2) { |
224 | 169 |
drupal_add_css(drupal_get_path('theme', 'mayo') . '/css/black-menu.css', $options); |
225 | 170 |
} |
226 | 171 |
|
172 |
// Add old legacy MAYO styles for Superfish. |
|
173 |
if (theme_get_setting('legacy_superfish_styles') == 1) { |
|
174 |
drupal_add_css(drupal_get_path('theme', 'mayo') . '/css/mayo-superfish.css', $options); |
|
175 |
} |
|
176 |
|
|
227 | 177 |
$options = array( |
228 | 178 |
'type' => 'inline', |
229 | 179 |
'group' => CSS_THEME, |
230 | 180 |
'weight' => 10, |
231 | 181 |
); |
232 | 182 |
|
233 |
/* |
|
234 |
$font_family = array( |
|
235 |
0 => "font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', 'URW Palladio L', Baskerville, serif; ", |
|
236 |
1 => "font-family: Verdana, Geneva, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', sans-serif; ", |
|
237 |
); |
|
238 |
*/ |
|
239 | 183 |
$font_family = array( |
240 | 184 |
// Added Japanese font support |
241 | 185 |
0 => "font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', 'URW Palladio L', Baskerville, Meiryo, 'Hiragino Mincho Pro', 'MS PMincho', serif; ", |
... | ... | |
268 | 212 |
drupal_add_css(".sidebar h2 { font-size: 1.2em; }", $options); |
269 | 213 |
drupal_add_css("#content .node h2 { font-size: 1.4em; }", $options); |
270 | 214 |
} |
215 |
// Get the path to the directory where our CSS files are saved |
|
216 |
$theme_name = $theme_key; |
|
217 |
$path = variable_get('theme_' . $theme_name . '_files_directory'); |
|
218 |
// Load Layout |
|
219 |
mayo_load_layout_css($path, $theme_name); |
|
271 | 220 |
} |
272 | 221 |
|
273 | 222 |
/** |
... | ... | |
279 | 228 |
_color_html_alter($variables); |
280 | 229 |
} |
281 | 230 |
} |
231 |
|
|
232 |
/** |
|
233 |
* Implements hook_page_alter(). |
|
234 |
*/ |
|
235 |
function mayo_page_alter($page) { |
|
236 |
// Add meta tag for viewport, for easier responsive theme design. |
|
237 |
$viewport = array( |
|
238 |
'#type' => 'html_tag', |
|
239 |
'#tag' => 'meta', |
|
240 |
'#attributes' => array( |
|
241 |
'name' => 'viewport', |
|
242 |
'content' => 'width=device-width, initial-scale=1', |
|
243 |
), |
|
244 |
); |
|
245 |
drupal_add_html_head($viewport, "viewport"); |
|
246 |
} |
Formats disponibles : Unified diff
Switch MAYO on version 7.x-2.0 to be adaptative.