/
template.php
293 lines (264 loc) · 11.2 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
/**
* Add body classes if certain regions have content.
*/
function casasrealprod_preprocess_html(&$variables) {
if (!empty($variables['page']['featured'])) {
$variables['classes_array'][] = 'featured';
}
if (!empty($variables['page']['triptych_first'])
|| !empty($variables['page']['triptych_middle'])
|| !empty($variables['page']['triptych_last'])) {
$variables['classes_array'][] = 'triptych';
}
if (!empty($variables['page']['footer_firstcolumn'])
|| !empty($variables['page']['footer_secondcolumn'])
|| !empty($variables['page']['footer_thirdcolumn'])
|| !empty($variables['page']['footer_fourthcolumn'])) {
$variables['classes_array'][] = 'footer-columns';
}
// Add conditional stylesheets for IE
drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}
/**
* Override or insert variables into the page template for HTML output.
*/
function casasrealprod_process_html(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($variables);
}
}
function casasrealprod_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<div class="breadcrumb">' . implode(' | ', $breadcrumb) . '</div>';
return $output;
}
}
/**
* Override or insert variables into the page template.
*/
function casasrealprod_process_page(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render elements.
$variables['title_prefix']['shortcut_wrapper'] = array(
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '</div>',
'#weight' => -99,
);
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
if (isset($variables['node']) &&
$variables['node']->type == "casas" &&
strpos(drupal_get_path_alias(), '/booking')>0) {
drupal_add_js(drupal_get_path('theme', 'casasrealprod') . '/js/casas_booking_manager.js');
$breadcrumbs = array();
$breadcrumbs[] = l(t('Home'), '<front>');
$breadcrumbs[] = l(t('Las Casas'), 'node/10');
$breadcrumbs[] = l($variables['node']->title, 'node/'.$variables['node']->nid);
drupal_set_breadcrumb($breadcrumbs);
$variables['title'] = t('Search for Availability');
$variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
}
if (strpos(drupal_get_path_alias(), 'bookings') !== FALSE) {
drupal_add_js(drupal_get_path('theme', 'casasrealprod') . '/js/casas_booking_manager.js');
}
if (strpos(drupal_get_path_alias(), 'checkout') !== FALSE) {
$parts = explode('/', current_path());
$last = array_pop($parts);
$title = drupal_get_title();
if (is_numeric($last)) {
$title = t('Fill your personal data');
}
else if ($last == 'review') {
$title = t('Review order');
}
$variables['title'] = $title;
}
}
/**
* Implements hook_preprocess_maintenance_page().
*/
function casasrealprod_preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
// or during site installation. Setting site_name to an empty string makes
// the site and update pages look cleaner.
// @see template_preprocess_maintenance_page
if (!$variables['db_is_active']) {
$variables['site_name'] = '';
}
drupal_add_css(drupal_get_path('theme', 'casasrealprod') . '/css/maintenance-page.css');
}
/**
* Override or insert variables into the maintenance page template.
*/
function casasrealprod_process_maintenance_page(&$variables) {
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
//fgc
// set the default language if necessary
$language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
$variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title);
$variables['base_path'] = base_path();
$variables['front_page'] = url();
$variables['breadcrumb'] = 'uiuui';
$variables['feed_icons'] = '';
$variables['help'] = '';
$variables['language'] = $language;
$variables['language']->dir = $language->direction ? 'rtl' : 'ltr';
$variables['logo'] = theme_get_setting('logo');
$variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
$variables['main_menu'] = array();
$variables['secondary_menu'] = array();
$variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
$variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
$variables['tabs'] = '';
$variables['title'] = drupal_get_title();
}
/**
* Override or insert variables into the node template.
*/
function casasrealprod_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
}
/**
* Override or insert variables into the block template.
*/
function casasrealprod_preprocess_block(&$variables) {
// In the header region visually hide block titles.
if ($variables['block']->region == 'header') {
$variables['title_attributes_array']['class'][] = 'element-invisible';
}
}
/**
* Implements theme_menu_tree().
*/
function casasrealprod_menu_tree($variables) {
return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
}
/**
* Implements theme_field__field_type().
*/
function casasrealprod_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) {
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
}
$output .= '</ul>';
// Render the top-level DIV.
$output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '">' . $output . '</div>';
return $output;
}
function casasrealprod_commerce_price_formatted_components($variables) {
if (strpos(drupal_get_path_alias(), 'bookings') !== FALSE ||
strpos(drupal_get_path_alias(), 'chekcout') !== FALSE) {
$content = array();
foreach ($variables['components'] as $name => $component) {
$content[] = array(
'#type' => 'markup',
'#prefix' => '<div class="'. drupal_html_class('component-type-' . $name) .'">',
'#markup' => $component['title'] .'<span>'. $component['formatted_price'] .'</span>',
'#suffix' => '</div>',
);
}
return '<div class="commerce-price-formatted-components">'. drupal_render($content) .'</div>';
}
else {
return theme_commerce_price_formatted_components($variables);
}
}
/**
* Implements hook_field_widget_form_alter().
*/
function casasrealprod_field_widget_form_alter(&$element, &$form_state, $context) {
if ($element['#field_name'] == 'field_cr_customer_condiciones') {
$element['#title'] = t('I accept the !policy',
array(
'!policy' => l(
t('private policy and use conditions'),
$context['field']['settings']['policy'],
array('attributes' => array('target' => '_blank')))
)
);
}
}
function casasrealprod_preprocess_mimemail_message(&$variables) {
global $base_url;
$variables['logo'] = $base_url . theme_get_setting('logo');
$variables['front_page'] = url();
}
function casasrealprod_preprocess_views_view(&$vars) {
if (isset($vars['view']->name)) {
if ($vars['view']->name == 'casas_checkout_form') {
$title = '';
$parts = explode('/', current_path());
$last = array_pop($parts);
if (is_numeric($last)) {
$title = t('Enjoy your experience for');
}
else if ($last == 'review') {
$title = t('Billing information');
}
$title = '<div class="commerce-order-handler-area-order-total-title">'. $title .'</div>';
$vars['footer'] = '<div class="commerce-order-handler-area-order-total-wrapper">'. $title . $vars['footer'] .'</div>';
}
}
}
function casasrealprod_preprocess_views_view_fields(&$vars) {
if (isset($vars['view']->name)) {
if ($vars['view']->name == 'casas_checkout_form') {
if ($vars['row']->commerce_line_item_field_data_commerce_line_items_type == 'rooms_service_booking') {
$label = 'Total';
$label_html = $vars['fields']['commerce_total']->wrapper_prefix . $label .':'. $vars['fields']['commerce_total']->wrapper_prefix;
$vars['fields']['commerce_total']->label = $label;
$vars['fields']['commerce_total']->label_html = $label_html;
}
}
}
}