Projet

Général

Profil

Paste
Télécharger (36,6 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / inc / preprocess.inc @ a08833bd

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * All Preprocess functions for templates and theme fucntions.
6
 * If you need to add or modify preprocess functions do it in your sub-theme.
7
 */
8
9
/**
10
 * Preprocess variables for all templates.
11
 */
12
function adaptivetheme_preprocess(&$vars) {
13 74f6bef0 Assos Assos
  // Provide variables to all templates to test for a mobile and tablet context, this
14
  // requires the Mobile Detect or Browscap modules.  TRUE/FALSE mean the feature
15
  // was detected; NULL means the feature could not be properly detected.
16
  $browser = at_get_browser();
17
  $vars['is_mobile'] = $browser['is_mobile'];
18
  $vars['is_tablet'] = $browser['is_tablet'];
19 85ad3d82 Assos Assos
}
20
21
/**
22
 * Preprocess variables for html.tpl.php
23
 */
24
function adaptivetheme_preprocess_html(&$vars) {
25
  global $theme_key, $language;
26
  $theme_name = $theme_key;
27
28
  // Set variable for the base path
29
  $vars['base_path'] = base_path();
30
31
  // Get the info file data
32
  $info = at_get_info($theme_name);
33
34
  // DOCTYPE
35
  // AT no longer uses doctype switching or $rdf_profile, these maintain
36
  // backwards compatibility with pre 7.x-2.1 versions of html.tpl.php
37
  $vars['doctype'] = '<!DOCTYPE html>' . "\n";
38
  $vars['rdf_profile'] = '';
39
40 74f6bef0 Assos Assos
  // Use a proper attributes array for the html attributes.
41
  // You can add more attributes to the html elment, for example in a sub-theme you can do this:
42
  // $vars['html_attributes_array']['xmlns:og'][] = 'http://opengraphprotocol.org/schema/';
43 85ad3d82 Assos Assos
  $vars['html_attributes_array']['lang'][] = $language->language;
44
  $vars['html_attributes_array']['dir'][] = $language->dir;
45
46
  // Convert RDF Namespaces into structured data using drupal_attributes.
47
  $vars['rdf_namespaces'] = array();
48
  if (function_exists('rdf_get_namespaces')) {
49
    foreach (rdf_get_namespaces() as $prefix => $uri) {
50
      $prefixes[] = $prefix . ': ' . $uri;
51
    }
52
    $vars['rdf_namespaces_array']['prefix'] = implode(' ', $prefixes);
53
  }
54
55
  // Get the path to the directory where our CSS files are saved
56
  $path = variable_get('theme_' . $theme_name . '_files_directory');
57
58
  // Load Layout
59 74f6bef0 Assos Assos
  at_load_layout_css($path, $theme_name);
60
61
  // Add layout settings as JS settings, we use this for responsive JS,
62
  // such as the Menu Toggle javascript.
63
  at_load_layout_js_settings($theme_name);
64 85ad3d82 Assos Assos
65
  // Load Responsive Styles.
66 a08833bd Assos Assos
  if (at_get_setting('disable_responsive_styles', $theme_name) == 0) {
67 74f6bef0 Assos Assos
    at_load_responsive_css($path, $theme_name);
68 85ad3d82 Assos Assos
  }
69
70 74f6bef0 Assos Assos
  // Load fonts and/or Custom CSS and the menu toggle files
71 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
72 85ad3d82 Assos Assos
    // Fonts CSS
73 a08833bd Assos Assos
    if (at_get_setting('enable_font_settings', $theme_name) == 1) {
74 74f6bef0 Assos Assos
      at_load_fonts($path, $theme_name);
75 85ad3d82 Assos Assos
    }
76
    // Custom CSS
77 a08833bd Assos Assos
    if (at_get_setting('enable_custom_css', $theme_name) == 1) {
78 74f6bef0 Assos Assos
      at_load_custom_css($path, $theme_name);
79
    }
80
    // Load the menu toggle js and css files
81 a08833bd Assos Assos
    if (at_get_setting('enable_menu_toggle', $theme_name) == 1) {
82 74f6bef0 Assos Assos
      at_load_menu_toggle($path, $theme_name);
83 85ad3d82 Assos Assos
    }
84
    // Load Extension Settings CSS
85 74f6bef0 Assos Assos
    at_load_extensions_css($theme_name);
86 85ad3d82 Assos Assos
  }
87
88
  // Load conditional stylesheets declared in the info file
89
  if (isset($info['ie_stylesheets'])) {
90 74f6bef0 Assos Assos
    at_load_subtheme_conditional_styles($theme_name);
91 85ad3d82 Assos Assos
  }
92
93
  // Load specific subtheme scripts
94 a08833bd Assos Assos
  if (at_get_setting('load_onmediaqueryjs', $theme_name) == 1) {
95 74f6bef0 Assos Assos
    at_load_subtheme_script('scripts/media_queries.js', $theme_name, 'footer', '100');
96 85ad3d82 Assos Assos
  }
97
98 74f6bef0 Assos Assos
  // Load polyfills
99
  $vars['polyfills'] = at_load_polyfills($theme_name, $vars);
100 85ad3d82 Assos Assos
101 74f6bef0 Assos Assos
  // Set the skip navigation target ID
102 85ad3d82 Assos Assos
  $vars['skip_link_target'] = '#main-content';
103
  if (at_get_setting('skip_link_target', $theme_name)) {
104 a08833bd Assos Assos
    $vars['skip_link_target'] = check_plain(at_get_setting('skip_link_target', $theme_name));
105 85ad3d82 Assos Assos
  }
106
107
  // Generate body classes
108 74f6bef0 Assos Assos
  if ($html_classes = at_generate_html_classes($vars, $theme_name)) {
109 85ad3d82 Assos Assos
    foreach ($html_classes as $class_name) {
110
      $vars['classes_array'][] = $class_name;
111
    }
112
  }
113
114
  // Do some legacy stuff for 7.x-2.x themes that have google webfonts running
115
  // on the old system. Scan for the existence of a "release" key and
116
  // conditionally load google.web.fonts.inc
117 a08833bd Assos Assos
  if (!isset($info['release']) || $info['release'] == '7.x-2.x') {
118 85ad3d82 Assos Assos
    include_once(drupal_get_path('theme', 'adaptivetheme') . '/inc/google.web.fonts.inc');
119
  }
120
121 74f6bef0 Assos Assos
  // Load debuggers if enabled.
122 a08833bd Assos Assos
  if (at_get_setting('expose_regions', $theme_name) == 1 || at_get_setting('show_window_size', $theme_name) == 1 || at_get_setting('load_all_panels', $theme_name) == 1) {
123 74f6bef0 Assos Assos
    at_load_debuggers($theme_name);
124 85ad3d82 Assos Assos
  }
125
}
126
127
/**
128
 * Preprocess variables for page.tpl.php
129
 */
130
function adaptivetheme_preprocess_page(&$vars) {
131
  global $theme_key;
132
  $theme_name = $theme_key;
133
134
  // Set up logo element
135 a08833bd Assos Assos
  if (at_get_setting('toggle_logo', $theme_name) == 1) {
136 74f6bef0 Assos Assos
    $vars['site_logo'] = &drupal_static('adaptivetheme_preprocess_page_site_logo');
137 85ad3d82 Assos Assos
    if (empty($vars['site_logo'])) {
138 74f6bef0 Assos Assos
      $logo_image_path = check_url($vars['logo']);
139
      $logo_image_alt = check_plain(variable_get('site_name', t('Home page')));
140
      $logo_image_vars = array('path' => $logo_image_path, 'alt' => $logo_image_alt, 'attributes' => array('class' => 'site-logo'));
141
      $vars['logo_img'] = theme('image', $logo_image_vars);
142
      if (at_get_setting('logo_title') == 1) {
143
        $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('attributes' => array('title' => $logo_image_alt), 'html' => TRUE)) : '';
144
      }
145
      else {
146
        $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('html' => TRUE)) : '';
147
      }
148 85ad3d82 Assos Assos
    }
149
    // Maintain backwards compatibility with 7.x-2.x sub-themes
150
    $vars['linked_site_logo'] = $vars['site_logo'];
151
  }
152
  else {
153
    $vars['site_logo'] = '';
154
    $vars['logo_img'] = '';
155
    $vars['linked_site_logo'] = '';
156
  }
157
158
  // Site name
159
  $vars['site_name'] = &drupal_static('adaptivetheme_preprocess_page_site_name');
160
  if (empty($vars['site_name'])) {
161
    $vars['site_name_title'] = variable_get('site_name', 'Drupal');
162 a08833bd Assos Assos
    $vars['site_name'] = l($vars['site_name_title'], '<front>', $options = array('attributes' => array('title' => t('Home page'))));
163 85ad3d82 Assos Assos
    $vars['site_name_unlinked'] = $vars['site_name_title'];
164
  }
165
166
  // Site name visibility and other classes and variables
167
  $vars['site_name_attributes_array'] = array();
168
  $vars['visibility'] = '';
169
  $vars['hide_site_name'] = FALSE;
170 a08833bd Assos Assos
  if (at_get_setting('toggle_name', $theme_name) == 0) {
171 85ad3d82 Assos Assos
    // Keep the visibility variable to maintain backwards compatibility
172
    $vars['visibility'] = 'element-invisible';
173
    $vars['site_name_attributes_array']['class'][] = $vars['visibility'];
174
    $vars['hide_site_name'] = TRUE;
175
  }
176
177
  // Build a variable for the main menu
178
  if (isset($vars['main_menu'])) {
179 74f6bef0 Assos Assos
    $main_menu_title = at_get_setting('menu_button_link_text') ? at_get_setting('menu_button_link_text') : t('Main menu');
180 85ad3d82 Assos Assos
    $vars['primary_navigation'] = theme('links', array(
181
      'links' => $vars['main_menu'],
182
      'attributes' => array(
183
        'class' => array('menu', 'primary-menu', 'clearfix'),
184
       ),
185
      'heading' => array(
186 74f6bef0 Assos Assos
        'text'  => $main_menu_title,
187 85ad3d82 Assos Assos
        'level' => 'h2',
188
        'class' => array('element-invisible'),
189 74f6bef0 Assos Assos
        'id'    => array('primary-menu'),
190 85ad3d82 Assos Assos
      )
191
    ));
192
  }
193
194
  // Build a variable for the secondary menu
195
  if (isset($vars['secondary_menu'])) {
196
    $vars['secondary_navigation'] = theme('links', array(
197
      'links' => $vars['secondary_menu'],
198
      'attributes' => array(
199
        'class' => array('menu', 'secondary-menu', 'clearfix'),
200
      ),
201
      'heading' => array(
202 74f6bef0 Assos Assos
        'text'  => t('Secondary menu'),
203 85ad3d82 Assos Assos
        'level' => 'h2',
204
        'class' => array('element-invisible'),
205 74f6bef0 Assos Assos
        'id'    => 'secondary-menu',
206 85ad3d82 Assos Assos
      )
207
    ));
208
  }
209
210
  // Build variables for Primary and Secondary local tasks
211
  $vars['primary_local_tasks'] = menu_primary_local_tasks();
212
  $vars['secondary_local_tasks'] = menu_secondary_local_tasks();
213
214
  // Add back the $search_box var to D7
215
  if (module_exists('search')) {
216
    $search_box = drupal_get_form('search_form');
217 74f6bef0 Assos Assos
    $vars['search_box'] = '<div id="search-box" role="search">' . drupal_render($search_box) . '</div>';
218 85ad3d82 Assos Assos
  }
219
220 a08833bd Assos Assos
  // Test if this is a page manager page, we need this to set things like the page title in themes
221
  // want to control the page title, e.g. not show it on nodes.
222
  $vars['page_manager_get_current_page'] = FALSE;
223
  if (function_exists('page_manager_get_current_page')) {
224
    if (page_manager_get_current_page()) {
225
      $vars['page_manager_get_current_page'] = TRUE;
226
    }
227
  }
228
229 85ad3d82 Assos Assos
  // Process enabled Extensions
230 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
231 85ad3d82 Assos Assos
    // Generate page classes, in AT Core these are all Extensions
232 74f6bef0 Assos Assos
    if ($page_classes = at_generate_page_classes($vars, $theme_name)) {
233 85ad3d82 Assos Assos
      foreach ($page_classes as $class_name) {
234
        $vars['classes_array'][] = $class_name;
235
      }
236
    }
237
    // Process modify markup settings
238 a08833bd Assos Assos
    if (at_get_setting('enable_markup_overides', $theme_name) == 1) {
239 85ad3d82 Assos Assos
      // Remove the infernal feed icons
240 a08833bd Assos Assos
      if (at_get_setting('feed_icons_hide', $theme_name) == 1) {
241 85ad3d82 Assos Assos
        $vars['feed_icons'] = '';
242
      }
243 a08833bd Assos Assos
      // Remove local tasks
244
      if (at_get_setting('unset_local_tasks', $theme_name) == 1) {
245
        $vars['primary_local_tasks'] = '';
246
        $vars['secondary_local_tasks'] = '';
247
      }
248 85ad3d82 Assos Assos
    }
249
  }
250
251 74f6bef0 Assos Assos
  // Strip stupid contextual-links-region class.
252
  //$vars['classes_array'] = array_values(array_diff($vars['classes_array'], array('contextual-links-region')));
253 85ad3d82 Assos Assos
254
  // page attributes
255
  $vars['page_attributes_array']['id'][] = 'page';
256
  $vars['page_attributes_array']['class'] = $vars['classes_array'];
257
258
  // header attributes
259
  $vars['header_attributes_array']['id'][] = 'header';
260
  $vars['header_attributes_array']['class'][] = 'clearfix';
261
  $vars['header_attributes_array']['role'][] = 'banner';
262
263
  // branding attributes
264
  $vars['branding_attributes_array']['id'][] = 'branding';
265
  $vars['branding_attributes_array']['class'][] = 'branding-elements';
266
  $vars['branding_attributes_array']['class'][] = 'clearfix';
267
268 74f6bef0 Assos Assos
  // site name and slogan attributes (wrapper div)
269
  // hgroup maintains BC layer for pre 7.x-3.2 themes
270
  $vars['hgroup_attributes_array'] = array();
271
  if (!$vars['site_slogan'] && $vars['hide_site_name']) {
272
    $vars['hgroup_attributes_array']['class'][] = $vars['visibility'];
273
  }
274
  $vars['hgroup_attributes_array']['class'][] = 'h-group';
275 85ad3d82 Assos Assos
  $vars['hgroup_attributes_array']['id'][] = 'name-and-slogan';
276
277
  // site name attributes
278
  $vars['site_name_attributes_array']['id'][] = 'site-name';
279
280
  // site slogan attributes
281
  $vars['site_slogan_attributes_array']['id'][] = 'site-slogan';
282
283
  // main content header attributes
284
  $vars['content_header_attributes_array']['id'][] = 'main-content-header';
285
  $vars['content_header_attributes_array']['class'][] = 'clearfix';
286
287
  // footer attributes
288
  $vars['footer_attributes_array']['id'][] = 'footer';
289
  $vars['footer_attributes_array']['class'][] = 'clearfix';
290
  $vars['footer_attributes_array']['role'][] = 'contentinfo';
291
292
  // Attribution variable used in admin theme and some others
293 74f6bef0 Assos Assos
  $vars['attribution'] = '';
294 a08833bd Assos Assos
  if (at_get_setting('attribution_toggle', $theme_name) == 1) {
295 74f6bef0 Assos Assos
    $vars['attribution'] = "<small class=\"attribution\">Premium Drupal Theme by <a href=\"http://adaptivethemes.com\">Adaptivethemes.com</a></small>";
296
  }
297 85ad3d82 Assos Assos
298
  // Work around a perculier bug/feature(?) in Drupal 7 which incorrectly sets
299
  // the page title to "User account" for all three of these pages.
300 74f6bef0 Assos Assos
  $title = drupal_get_title();
301 a08833bd Assos Assos
  if (arg(0) == 'user' && $title == t('User account')) {
302
    if (arg(1) == 'login' || arg(1) == '') {
303 85ad3d82 Assos Assos
      drupal_set_title(t('User login'));
304
    }
305 a08833bd Assos Assos
    if (arg(1) == 'password') {
306 85ad3d82 Assos Assos
      drupal_set_title(t('Request new password'));
307
    }
308 a08833bd Assos Assos
    if (arg(1) == 'register') {
309 85ad3d82 Assos Assos
      drupal_set_title(t('Create new account'));
310
    }
311
  }
312
}
313
314
/**
315
 * Preprocess variables for region.tpl.php
316
 */
317
function adaptivetheme_preprocess_region(&$vars) {
318
  global $theme_key;
319
  $theme_name = $theme_key;
320
321
  $region = $vars['region'];
322
323
  // Add a "sidebar" class to sidebar regions
324 a08833bd Assos Assos
  if ($region == 'sidebar_first' || $region == 'sidebar_second') {
325 85ad3d82 Assos Assos
    $vars['classes_array'][] = 'sidebar';
326
    // Allow a region-specific template to override the region--sidebar suggestion.
327
    array_unshift($vars['theme_hook_suggestions'], 'region__sidebar');
328
  }
329
330
  // Float region block classes
331 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
332
    if (at_get_setting('enable_float_region_blocks', $theme_name) == 1) {
333 85ad3d82 Assos Assos
334
      // Make sure there is something set for the region, get the column count
335
      if ($float_blocks_regions_class = at_get_setting('float_block_' . $region)) {
336
337
        // Do nothing if its <none>
338
        if ($float_blocks_regions_class !== '<none>') {
339
340
          // Set a class for the number of columns selected, default to nothing
341
          $float_blocks_regions_class = isset($float_blocks_regions_class) ? check_plain($float_blocks_regions_class) : '';
342
          $vars['classes_array'][] = 'float-blocks-' . $float_blocks_regions_class;
343
344
          // Add the float direction class, default to left if the setting fails
345
          if ($float_block_direction_class = at_get_setting('float_block_direction_' . $region)) {
346
            $float_block_direction_class = isset($float_block_direction_class) ? check_plain($float_block_direction_class) : 'left';
347
            $vars['classes_array'][] = 'float-blocks-' . $float_block_direction_class;
348
          }
349
        }
350
      }
351
    }
352
  }
353
354
  // Add classes to conditional stack regions in Gpanel regions, in the Panels
355
  // layout plugins these are hard coded.
356
  $conditional_stack_regions = &drupal_static(__FUNCTION__, array());
357
  if (empty($conditional_stack_regions)) {
358
    $conditional_stack_regions = array(
359
      'three_25_25_50_top',
360
      'three_25_25_50_bottom',
361
      'three_25_50_25_top',
362
      'three_25_50_25_bottom',
363
      'three_50_25_25_top',
364
      'three_50_25_25_bottom',
365
      'three_33_top',
366
      'three_33_bottom',
367
      'two_50_top',
368
      'two_50_bottom',
369
      'two_33_66_top',
370
      'two_33_66_bottom',
371
      'two_66_33_top',
372
      'two_66_33_bottom',
373
      'two_brick_top',
374
      'two_brick_middle',
375
      'two_brick_bottom',
376
      'threecol_inset_left_top',
377
      'threecol_inset_left_bottom',
378
      'threecol_inset_right_top',
379
      'threecol_inset_right_bottom',
380
    );
381
  }
382
  if (in_array($region, $conditional_stack_regions)) {
383
    $vars['classes_array'][] = 'region-conditional-stack';
384
  }
385
}
386
387
/**
388
 * Preprocess variables for block.tpl.php
389
 */
390
function adaptivetheme_preprocess_block(&$vars) {
391
  global $theme_key;
392 74f6bef0 Assos Assos
  global $user;
393 85ad3d82 Assos Assos
  $theme_name = $theme_key;
394
395
  // Block subject, under certain conditions, is not set
396
  $vars['tag'] = 'div';
397
  $vars['title'] = '';
398
399
  if (isset($vars['block']->subject)) {
400
    if (!empty($vars['block']->subject)) {
401
      // Generate the wrapper element, if there's a title use section
402
      $vars['tag'] = 'section';
403
404
      // Use a $title variable instead of $block->subject
405
      $vars['title'] = $vars['block']->subject;
406
    }
407
    // subject can be set and empty, i.e. using <none>
408
    else {
409
      $vars['classes_array'][] = 'no-title';
410
    }
411
  }
412
  // sometimes subject is not set at all
413
  else {
414
    $vars['classes_array'][] = 'no-title';
415
  }
416
417
  // Search is never a section, its just a div
418 a08833bd Assos Assos
  if ($vars['block_html_id'] == 'block-search-form') {
419 85ad3d82 Assos Assos
    $vars['tag'] = 'div';
420
  }
421
422 74f6bef0 Assos Assos
  // Block inner attributes
423
  $vars['block_inner_attributes_array']['class'][] = 'block-inner';
424
  $vars['block_inner_attributes_array']['class'][] = 'clearfix';
425 85ad3d82 Assos Assos
426
  // Use nav element for menu blocks and provide a suggestion for all of them
427
  $nav_blocks = array('navigation', 'main-menu', 'management', 'user-menu');
428
  if (in_array($vars['block']->delta, $nav_blocks)) {
429
    $vars['tag'] = 'nav';
430
    array_unshift($vars['theme_hook_suggestions'], 'block__menu');
431
  }
432 74f6bef0 Assos Assos
433
  $nav_modules = array('superfish', 'nice_menus', 'menu_block', 'menu');
434 85ad3d82 Assos Assos
  if (in_array($vars['block']->module, $nav_modules)) {
435
    $vars['tag'] = 'nav';
436
    array_unshift($vars['theme_hook_suggestions'], 'block__menu');
437
  }
438
439
  // The menu bar region gets special treatment for the block template
440 a08833bd Assos Assos
  if ($vars['block']->region == 'menu_bar') {
441 74f6bef0 Assos Assos
    $vars['classes_array'][] = 'menu-wrapper';
442
    $vars['classes_array'][] = 'menu-bar-wrapper';
443
    $vars['classes_array'][] = 'clearfix';
444
    $vars['title_attributes_array']['class'][] = 'element-invisible';
445 85ad3d82 Assos Assos
  }
446
447
  // The menu bar region gets special treatment for the block template
448 a08833bd Assos Assos
  if (at_get_setting('enable_menu_toggle', $theme_name) == 1) {
449
    if (at_get_setting('menu_toggle_menu_bar', $theme_name) == 1) {
450
      if ($vars['block']->region == 'menu_bar') {
451 74f6bef0 Assos Assos
        $vars['classes_array'][] = 'at-menu-toggle';
452
      }
453
    }
454 a08833bd Assos Assos
    if (at_get_setting('menu_toggle_leaderboard', $theme_name) == 1 && $vars['block']->region == 'leaderboard') {
455 74f6bef0 Assos Assos
      $vars['classes_array'][] = 'at-menu-toggle';
456
      $vars['classes_array'][] = 'clearfix';
457
    }
458 a08833bd Assos Assos
    if (at_get_setting('menu_toggle_header', $theme_name) == 1 && $vars['block']->region == 'header') {
459 74f6bef0 Assos Assos
      $vars['classes_array'][] = 'at-menu-toggle';
460
      $vars['classes_array'][] = 'clearfix';
461
    }
462 85ad3d82 Assos Assos
  }
463
464
  // Add extra classes if required
465 a08833bd Assos Assos
  if (at_get_setting('extra_block_classes', $theme_name) == 1) {
466 85ad3d82 Assos Assos
467
    // Zebra
468
    $vars['classes_array'][] = $vars['block_zebra'];
469
470
    // Position?
471 a08833bd Assos Assos
    if ($vars['block_id'] == 1) {
472 85ad3d82 Assos Assos
      $vars['classes_array'][] = 'first';
473
    }
474
    if (isset($vars['block']->last_in_region)) {
475
      $vars['classes_array'][] = 'last';
476
    }
477
478
    // Count
479
    $vars['classes_array'][] = 'block-count-' . $vars['id'];
480
481
    // Region
482
    $vars['classes_array'][] = drupal_html_class('block-region-' . $vars['block']->region);
483
484
    // Delta
485
    $vars['classes_array'][] = drupal_html_class('block-' . $vars['block']->delta);
486
  }
487
488
  // Add classes to theme the horizontal block option
489 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
490
    if (at_get_setting('enable_markup_overides', $theme_name) == 1) {
491 74f6bef0 Assos Assos
      // Change the user menu title to the user name.
492 a08833bd Assos Assos
      if (at_get_setting('user_block_user_name', $theme_name) == 1) {
493 74f6bef0 Assos Assos
        if ($vars['block']->module == 'system' && $vars['block']->delta == 'user-menu') {
494
          if (user_is_logged_in()) {
495
            $vars['title'] = check_plain($user->name);
496
          }
497
        }
498
      }
499
      // Horizontal block classes.
500 a08833bd Assos Assos
      if (at_get_setting('horizontal_login_block', $theme_name) == 1 && $vars['block']->module == 'user' && $vars['block']->delta == 'login') {
501 85ad3d82 Assos Assos
        $vars['classes_array'][] = 'lb-h';
502
        $vars['title_attributes_array']['class'][] = 'element-invisible';
503
      }
504 a08833bd Assos Assos
      if (at_get_setting('slider_login_block', $theme_name) == 1 && $vars['block']->module == 'user' && $vars['block']->delta == 'login') {
505 85ad3d82 Assos Assos
        $vars['classes_array'][] = 'lb-s';
506
      }
507
    }
508
  }
509
510
  // Give our block titles and content some additional class
511
  $vars['title_attributes_array']['class'][] = 'block-title';
512 74f6bef0 Assos Assos
  $vars['content_attributes_array']['class'] = array('block-content', 'content');
513
514
  // Support aria-describedby
515
  if ($vars['block']->subject && !empty($vars['attributes_array']['role'])) {
516
    $vars['title_attributes_array']['id'] = drupal_html_id($vars['block']->subject);
517
    $vars['attributes_array']['aria-describedby'] = $vars['title_attributes_array']['id'];
518
  }
519 85ad3d82 Assos Assos
520
  // Add Aria Roles via attributes
521
  switch ($vars['block']->module) {
522
    case 'system':
523
      switch ($vars['block']->delta) {
524
        case 'main':
525
          // Note: the "main" role goes in the page.tpl, not here.
526
          break;
527
        case 'help':
528
        case 'powered-by':
529
          $vars['attributes_array']['role'] = 'complementary';
530
          break;
531
        default:
532
          // Any other "system" block is a menu block.
533
          $vars['attributes_array']['role'] = 'navigation';
534
          break;
535
      }
536
      break;
537
    case 'menu':
538
    case 'menu_block':
539
    case 'blog':
540
    case 'book':
541
    case 'comment':
542
    case 'forum':
543
    case 'shortcut':
544
    case 'statistics':
545
      $vars['attributes_array']['role'] = 'navigation';
546
      break;
547
    case 'search':
548
      $vars['attributes_array']['role'] = 'search';
549
      break;
550
    case 'help':
551
    case 'aggregator':
552
    case 'locale':
553
    case 'poll':
554
    case 'profile':
555
      $vars['attributes_array']['role'] = 'complementary';
556
      break;
557
    case 'node':
558
      switch ($vars['block']->delta) {
559
        case 'syndicate':
560
          $vars['attributes_array']['role'] = 'complementary';
561
          break;
562
        case 'recent':
563
          $vars['attributes_array']['role'] = 'navigation';
564
          break;
565
      }
566
      break;
567
    case 'user':
568
      switch ($vars['block']->delta) {
569
        case 'login':
570
          $vars['attributes_array']['role'] = 'form';
571
          break;
572
        case 'new':
573
        case 'online':
574
          $vars['attributes_array']['role'] = 'complementary';
575
          break;
576
      }
577
      break;
578
  }
579
}
580
581
/**
582
 * Preprocess variables for panels_pane.tpl.php
583
 */
584
function adaptivetheme_preprocess_panels_pane(&$vars) {
585
  // Top level wrapper
586
  $vars['tag'] = $vars['title'] ? 'section' : 'div';
587
588
  // Add the same classes as blocks
589
  if (empty($vars['title'])) {
590
    $vars['classes_array'][] = 'no-title';
591
  }
592
  $vars['classes_array'][] = 'block';
593
594
  // Use the attributes arrays to add classes.
595
  $vars['title_attributes_array']['class'][] = 'block-title';
596
  $vars['attributes_array']['class'] = $vars['classes_array'];
597
  $vars['content_attributes_array']['class'][] = 'block-content';
598
}
599
600
/**
601
 * Preprocess variables for field.tpl.php
602
 */
603
function adaptivetheme_preprocess_field(&$vars) {
604
  global $theme_key;
605
  $theme_name = $theme_key;
606
607
  $element = $vars['element'];
608
609
 // Set the top level element as either <section> (if the field label is showing),
610
 // or <div> if the field label is hidden.
611
  $vars['tag'] = 'section';
612
  if (isset($vars['label_hidden']) && $vars['label_hidden'] == TRUE) {
613
    $vars['tag'] = 'div';
614
  }
615
616
  $vars['field_view_mode'] = '';
617
  if (isset($element['#view_mode'])) {
618
    // add a view mode class to fields
619
    $vars['classes_array'][] = 'view-mode-' . $element['#view_mode'];
620
    // Set variable for view mode, appears to be not gettable in a template
621
    $vars['field_view_mode'] = $element['#view_mode'];
622
  }
623
624
  // Image fields
625 a08833bd Assos Assos
  if ($element['#field_type'] == 'image') {
626 85ad3d82 Assos Assos
627
    // Set some vars for image captioning, these always need to be initialized
628
    $vars['image_caption_teaser'] = FALSE;
629
    $vars['image_caption_full'] = FALSE;
630
631
    // Dont run anything if extensions or image settings are disabled
632 a08833bd Assos Assos
    if (at_get_setting('enable_extensions', $theme_name) == 1) {
633
      if (at_get_setting('enable_image_settings', $theme_name) == 1) {
634 85ad3d82 Assos Assos
635
        // Reduce number of images in teaser view mode to single image
636 a08833bd Assos Assos
        if (at_get_setting('image_teaser', $theme_name) == 1) {
637 85ad3d82 Assos Assos
          if ($element['#view_mode'] == 'teaser') {
638
            $item = reset($vars['items']);
639
            $vars['items'] = array($item);
640
          }
641
        }
642
643
        // Captions
644 a08833bd Assos Assos
        if (at_get_setting('image_caption_teaser', $theme_name) == 1) {
645 85ad3d82 Assos Assos
          $vars['image_caption_teaser'] = TRUE;
646
        }
647 a08833bd Assos Assos
        if (at_get_setting('image_caption_full', $theme_name) == 1) {
648 85ad3d82 Assos Assos
          $vars['image_caption_full'] = TRUE;
649
        }
650
      }
651
    }
652
  }
653
}
654
655
/**
656
 * Preprocess variables for node.tpl.php
657
 */
658
function adaptivetheme_preprocess_node(&$vars) {
659
  global $theme_key;
660
  $theme_name = $theme_key;
661
662
  // article class to attempt backwards compatibility
663
  $vars['classes_array'][] = 'article';
664
665
  // Extra classes if required
666 a08833bd Assos Assos
  if (at_get_setting('extra_article_classes', $theme_name) == 1) {
667 85ad3d82 Assos Assos
668
    // Zebra
669
    $vars['classes_array'][] = $vars['zebra'];
670
671
    // Langauge
672
    if (module_exists('translation')) {
673
      if ($vars['node']->language) {
674
        $vars['classes_array'][] = 'node-lang-' . $vars['node']->language;
675
      }
676
    }
677
678
    // User picture?
679 74f6bef0 Assos Assos
    // Should we all a check for the global settings here? SEE: https://drupal.org/node/2020687
680 a08833bd Assos Assos
    if (at_get_setting('toggle_node_user_picture', $theme_name) == 1) {
681 85ad3d82 Assos Assos
      if ($vars['display_submitted'] && !empty($vars['picture'])) {
682
        $vars['classes_array'][] = 'node-with-picture';
683
      }
684
    }
685
686
    // Class for each view mode, core assumes we only need to target teasers but neglects custom view modes or full
687
    if ($vars['view_mode'] !== 'teaser') {
688
      $vars['classes_array'][] = drupal_html_class('node-' . $vars['view_mode']);
689
    }
690
  }
691
692
  // Image alignment and caption classes
693 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
694
    if (at_get_setting('enable_image_settings', $theme_name) == 1) {
695 85ad3d82 Assos Assos
      if ($vars['view_mode'] !== 'teaser') {
696
        if ($image_caption_full = at_get_setting('image_caption_full', $theme_name)) {
697
          $vars['classes_array'][] = $image_caption_full;
698
        }
699
        if ($image_alignment = at_get_setting('image_alignment', $theme_name)) {
700
          $vars['classes_array'][] = $image_alignment;
701
        }
702
      }
703
      if ($vars['view_mode'] == 'teaser') {
704
        if ($image_caption_teaser = at_get_setting('image_caption_teaser', $theme_name)) {
705
          $vars['classes_array'][] = $image_caption_teaser;
706
        }
707
        if ($image_alignment_teaser = at_get_setting('image_alignment_teaser', $theme_name)) {
708
          $vars['classes_array'][] = $image_alignment_teaser;
709
        }
710
      }
711
    }
712
  }
713
714
  // ARIA Role
715
  $vars['attributes_array']['role'][] = 'article';
716
717
  // Classes and attributes
718
  $vars['title_attributes_array']['class'][] = 'node-title';
719
  $vars['content_attributes_array']['class'][] = 'node-content';
720
721
  // header, submitted and links wrappers have their own attributes
722
  $vars['header_attributes_array']['class'][] = 'node-header';
723
  $vars['footer_attributes_array']['class'][] = 'submitted';
724
  if ($vars['user_picture']) {
725
    $vars['footer_attributes_array']['class'][] = 'with-user-picture';
726
  }
727
  $vars['links_attributes_array']['class'][] = 'clearfix';
728
729
  //
730
  // AT Core builds additional time and date variables for use in templates
731
  //
732
  // datetime stamp formatted correctly to ISO8601
733
  $vars['datetime'] = format_date($vars['created'], 'custom', 'Y-m-d\TH:i:sO'); // PHP 'c' format is not proper ISO8601!
734
735
  // Publication date, formatted with time element
736 a08833bd Assos Assos
  $vars['publication_date'] = '<time datetime="' . $vars['datetime'] . '">' . $vars['date'] . '</time>';
737 85ad3d82 Assos Assos
738
  // Last update variables
739
  $vars['datetime_updated'] = format_date($vars['node']->changed, 'custom', 'Y-m-d\TH:i:sO');
740
  $vars['custom_date_and_time'] = date('jS F, Y - g:ia', $vars['node']->changed);
741
742
  // Last updated formatted in time element
743 a08833bd Assos Assos
  $vars['last_update'] = '<time datetime="' . $vars['datetime_updated'] . '">' . $vars['custom_date_and_time'] . '</time>';
744 85ad3d82 Assos Assos
745
  // Build the submitted variable used by default in node templates
746
  if (variable_get('node_submitted_' . $vars['node']->type, TRUE)) {
747
    $vars['submitted'] = t('Submitted by !username on !datetime',
748
      array(
749
        '!username' => $vars['name'],
750
        '!datetime' => $vars['publication_date'],
751
      )
752
    );
753
  }
754
  else {
755
    $vars['submitted'] = '';
756
  }
757
758
  // Unpublished?
759
  $vars['unpublished'] = ''; // Initialize for backwards compatibility
760
  if (!$vars['status']) {
761
    // Use the title prefix to render the unpublished message
762
    $vars['title_prefix']['unpublished']['#markup'] = '<p class="unpublished">' . t('Unpublished') . '</p>';
763
  }
764
765
  // Add nofollow to Book module print/export links
766
  if (isset($vars['content']['links']['book']['#links']['book_printer'])) {
767
    $vars['content']['links']['book']['#links']['book_printer']['attributes'] = array('rel' => array('nofollow'));
768
  }
769
}
770
771
/**
772
 * Preprocess variables for comment.tpl.php
773
 */
774
function adaptivetheme_preprocess_comment(&$vars) {
775
  global $theme_key;
776
  $theme_name = $theme_key;
777
778
  // Extra comment classes if required
779 a08833bd Assos Assos
  if (at_get_setting('extra_comment_classes', $theme_name) == 1) {
780 85ad3d82 Assos Assos
781
    // Zebra
782
    $vars['classes_array'][] = $vars['zebra'];
783
784
    // Position?
785 a08833bd Assos Assos
    if ($vars['id'] == 1) {
786 85ad3d82 Assos Assos
      $vars['classes_array'][] = 'first';
787
    }
788 a08833bd Assos Assos
    if ($vars['id'] == $vars['node']->comment_count) {
789 85ad3d82 Assos Assos
      $vars['classes_array'][] = 'last';
790
    }
791
792
    // Title hidden?
793 a08833bd Assos Assos
    if (at_get_setting('comments_hide_title', $theme_name) == 1) {
794 85ad3d82 Assos Assos
      $vars['classes_array'][] = 'comment-title-hidden';
795
    }
796
797
    // User picture?
798 74f6bef0 Assos Assos
    // Should we add a check for the global settings here? SEE: https://drupal.org/node/2020687
799 a08833bd Assos Assos
    if (at_get_setting('toggle_comment_user_picture', $theme_name) == 1) {
800 85ad3d82 Assos Assos
      if (!empty($vars['picture'])) {
801
        $vars['classes_array'][] = 'comment-with-picture';
802
      }
803
    }
804
805
    // Signature?
806
    if (!empty($vars['signature'])) {
807
      $vars['classes_array'][] = 'comment-with-signature';
808
    }
809
  }
810
811
  // Classes for comment title
812
  $vars['title_attributes_array']['class'][] = 'comment-title';
813
814
  // Title hidden?
815 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
816
    if (at_get_setting('enable_markup_overides', $theme_name) == 1) {
817
      if (at_get_setting('comments_hide_title', $theme_name) == 1) {
818 85ad3d82 Assos Assos
        $vars['title_attributes_array']['class'][] = 'element-invisible';
819
      }
820
    }
821
  }
822
823
  // Classes for comment content
824
  $vars['content_attributes_array']['class'][] = 'comment-content';
825
826
  // header, submitted and links wrappers have their own attributes
827
  $vars['header_attributes_array']['class'][] = 'comment-header';
828
  $vars['footer_attributes_array']['class'][] = 'submitted';
829
  if ($vars['picture']) {
830
    $vars['footer_attributes_array']['class'][] = 'with-user-picture';
831
  }
832
  $vars['links_attributes_array']['class'][] = 'clearfix';
833
834 74f6bef0 Assos Assos
  // Build the submitted by, permalink, title and time elements
835 85ad3d82 Assos Assos
  $uri = entity_uri('comment', $vars['comment']);
836
  $uri['options'] += array('attributes' => array('rel' => 'bookmark'));
837
  $vars['title'] = l($vars['comment']->subject, $uri['path'], $uri['options']);
838 74f6bef0 Assos Assos
839
  // Don't rebuild the permalink variable if Advanced Forum is enabled
840
  if (!module_exists('advanced_forum')) {
841
    $vars['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
842
  }
843
844
  $vars['created'] = '<span class="date-time">' . $vars['created'] . '</span>';
845
846 85ad3d82 Assos Assos
  $vars['datetime'] = format_date($vars['comment']->created, 'custom', 'Y-m-d\TH:i:s\Z'); // Generate the timestamp, PHP "c" format is wrong
847 74f6bef0 Assos Assos
848 85ad3d82 Assos Assos
  $vars['submitted'] = t('Submitted by !username on !datetime',
849
    array(
850
      '!username' => $vars['author'],
851 a08833bd Assos Assos
      '!datetime' => '<time datetime="' . $vars['datetime'] . '">' . $vars['created'] . '</time>',
852 85ad3d82 Assos Assos
    )
853
  );
854
855
  // Unpublished?
856
  $vars['unpublished'] = ''; // Initialize for backwards compatibility
857 a08833bd Assos Assos
  if ($vars['status'] == 'comment-unpublished') {
858 85ad3d82 Assos Assos
    // Use the title prefix to render the unpublished message
859
    $vars['title_prefix']['unpublished']['#markup'] = '<p class="unpublished">' . t('Unpublished') . '</p>';
860
  }
861
}
862
863
/**
864
 * Preprocess variables for the search block form.
865
 */
866
function adaptivetheme_preprocess_search_block_form(&$vars) {
867
  // Changes the search form to use the "search" input element attribute (HTML5)
868
  // We have to replace the string because FAPI don't know what type=search is, i.e.
869
  // no way we can do this in a form alter hook.
870
  $vars['search_form'] = str_replace('type="text"', 'type="search"', $vars['search_form']);
871
}
872
873
/**
874
 * Preprocess variables for aggregator-item.tpl.php
875
 */
876
function adaptivetheme_preprocess_aggregator_item(&$vars) {
877
  $item = $vars['item'];
878
  // We want the same highly accurate time stamp feature as nodes and comments
879
  $vars['datetime'] = format_date($item->timestamp, 'custom', 'Y-m-d\TH:i:sO');
880
  // Give our aggregator items some class
881
  $vars['classes_array'][] = 'feed-item clearfix';
882
  $vars['title_attributes_array']['class'][] = 'title feed-item-title';
883
  $vars['content_attributes_array']['class'][] = 'content feed-item-content';
884
}
885
886
/**
887
 * Preprocess variables for adaptivtheme_menubar()
888
 */
889
function adaptivetheme_preprocess_menubar(&$vars) {
890 74f6bef0 Assos Assos
  global $theme_key;
891
  $theme_name = $theme_key;
892 85ad3d82 Assos Assos
  $type = $vars['type'];
893 74f6bef0 Assos Assos
894
  // menu bar id
895 85ad3d82 Assos Assos
  $vars['menubar_id'] = $type . '-menu-bar';
896 74f6bef0 Assos Assos
  // Add classes to the main wrapper
897
  $vars['classes_array'] = array('nav', 'clearfix');
898
899
  // Classes for toggle menus
900 a08833bd Assos Assos
  if (at_get_setting('enable_menu_toggle', $theme_name) == 1) {
901
    if (at_get_setting('menu_toggle_main_menu', $theme_name) == 1 && $type == 'primary') {
902 74f6bef0 Assos Assos
      $vars['classes_array'][] = 'at-menu-toggle';
903
    }
904 a08833bd Assos Assos
    if (at_get_setting('menu_toggle_secondary_menu', $theme_name) == 1 && $type == 'secondary') {
905 74f6bef0 Assos Assos
      $vars['classes_array'][] = 'at-menu-toggle';
906
    }
907
  }
908
909
  // Add classes to the inner wrapper
910
  $vars['content_attributes_array']['class'][] = $type . '-menu-wrapper';
911
  $vars['content_attributes_array']['class'][] = 'menu-wrapper';
912
  $vars['content_attributes_array']['class'][] = 'clearfix';
913
  // Aria
914 85ad3d82 Assos Assos
  $vars['content_attributes_array']['role'][] = 'navigation';
915 74f6bef0 Assos Assos
  $vars['content_attributes_array']['aria-labelledby'][] = $type . '-menu';
916
917 85ad3d82 Assos Assos
  // Add suggstions per menu type
918
  $vars['theme_hook_suggestions'][] = 'menubar__' . $type;
919
}
920
921
/**
922
 * Preprocess variables for the username.
923
 */
924
function adaptivetheme_preprocess_username(&$vars) {
925
  global $theme_key;
926
  $theme_name = $theme_key;
927
  // Add rel=author for SEO and supporting search engines
928 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
929
    if (at_get_setting('enable_markup_overides', $theme_name) == 1) {
930
      if (at_get_setting('rel_author', $theme_name) == 1) {
931 85ad3d82 Assos Assos
        if (isset($vars['link_path'])) {
932
          $vars['link_attributes']['rel'][] = 'author';
933
        }
934
        else {
935
          $vars['attributes_array']['rel'][] = 'author';
936
        }
937
      }
938
    }
939
  }
940
}
941
942
/**
943
 * Preprocess variables for theme_image()
944
 */
945
function adaptivetheme_preprocess_image(&$vars) {
946
947
  // Initialize the variable if there isn't one
948
  if (!isset($vars['attributes']['class'])) {
949
    $vars['attributes']['class'] = array();
950
  }
951
952
  // Some modules set the style name even when its empty, such as User Badges
953
  // module, so initialize the class name variable with a "none" class
954
  $style_name_class = 'none';
955 74f6bef0 Assos Assos
956 85ad3d82 Assos Assos
  // If there really is a style name use it for the class
957
  if (isset($vars['style_name']) && !empty($vars['style_name'])) {
958
    $style_name_class = drupal_html_class($vars['style_name']);
959
  }
960
961 74f6bef0 Assos Assos
  // Check if the class attributes is an array. If we don't do this check and
962
  // the class attribute is string it can cause a fatal error.
963
  // See http://drupal.org/node/1722146 for an example
964 85ad3d82 Assos Assos
  if (is_array($vars['attributes']['class'])) {
965
    $vars['attributes']['class'][] = 'image-style-' . $style_name_class;
966
  }
967
}
968
969
/**
970
 * Preprocess variables for maintenance-page.tpl.php
971
 */
972
function adaptivetheme_preprocess_maintenance_page(&$vars) {
973
  global $theme_key;
974
  $theme_name = $theme_key;
975
976
  // Get the path to the directory where our CSS files are saved
977
  $path = variable_get('theme_' . $theme_name . '_files_directory');
978
979
  // Load Layout
980 74f6bef0 Assos Assos
  at_load_layout_css($path, $theme_name);
981 85ad3d82 Assos Assos
982
  // Load Responsive Styles.
983 a08833bd Assos Assos
  if (at_get_setting('disable_responsive_styles', $theme_name) == 0) {
984 74f6bef0 Assos Assos
    at_load_responsive_css($path, $theme_name);
985 85ad3d82 Assos Assos
  }
986
987
  // Load fonts and/or Custom CSS
988 a08833bd Assos Assos
  if (at_get_setting('enable_extensions', $theme_name) == 1) {
989 85ad3d82 Assos Assos
    // Fonts CSS
990 a08833bd Assos Assos
    if (at_get_setting('enable_font_settings', $theme_name) == 1) {
991 74f6bef0 Assos Assos
      at_load_fonts($path, $theme_name);
992 85ad3d82 Assos Assos
    }
993
    // Custom CSS
994 a08833bd Assos Assos
    if (at_get_setting('enable_custom_css', $theme_name) == 1) {
995 74f6bef0 Assos Assos
      at_load_custom_css($path, $theme_name);
996 85ad3d82 Assos Assos
    }
997
    // Load Extension Settings CSS
998 74f6bef0 Assos Assos
    at_load_extensions_css($theme_name);
999 85ad3d82 Assos Assos
  }
1000
1001 74f6bef0 Assos Assos
  // Load polyfills
1002
  $vars['polyfills'] = at_load_polyfills($theme_name, $vars);
1003 85ad3d82 Assos Assos
1004
  // Load the colors stylesheet for the active color scheme. This only works
1005
  // for maintenance mode, when there is a database error the default color
1006
  // scheme will be used.
1007
  if (module_exists('color')) {
1008
    $color_file = variable_get('color_' . $theme_name . '_stylesheets', NULL);
1009
    if (file_exists($color_file[0])) {
1010
      drupal_add_css($color_file[0], array(
1011
        'group' => CSS_THEME,
1012
        'weight' => 99,
1013
        )
1014
      );
1015
    }
1016
  }
1017
1018 74f6bef0 Assos Assos
  // Attribution variable used in admin theme and some others
1019
  $vars['attribution'] = '';
1020 a08833bd Assos Assos
  if (at_get_setting('attribution_toggle', $theme_name) == 1) {
1021 74f6bef0 Assos Assos
    $vars['attribution'] = "<small class=\"attribution\">Premium Drupal Theme by <a href=\"http://adaptivethemes.com\">Adaptivethemes.com</a></small>";
1022
  }
1023
}
1024
1025
/**
1026
 * Preprocess variables for user-profile.tpl.php
1027
 */
1028
function adaptivetheme_preprocess_user_profile(&$vars) {
1029
  $vars['classes_array'][] = 'profile';
1030
}
1031
1032
/**
1033
 * Preprocess variables for breadcrumbs
1034
 */
1035
function adaptivetheme_preprocess_breadcrumb(&$vars) {
1036
  // Add Google rich snippets to breadcrumbs using RDFa
1037 a08833bd Assos Assos
  if (module_exists('rdf') && !empty($vars['breadcrumb'])) {
1038 74f6bef0 Assos Assos
    $snippet_url = ' rel="v:url" ';
1039
    $snippet_title = ' property="v:title" ';
1040 a08833bd Assos Assos
1041 74f6bef0 Assos Assos
    foreach ($vars['breadcrumb'] as $key => $breadcrumb) {
1042
      preg_match_all('/<([\w]+)[^>]*>.*?<\/\\1>/', $breadcrumb, $matches);
1043
      if (count($matches[0]) > 0) {
1044
        $snippet = $snippet_title;
1045
        if ($matches[1][count($matches[1]) - 1] == 'a') {
1046
          $snippet = $snippet_url . $snippet_title;
1047
        }
1048
        $breadcrumb = substr_replace($breadcrumb, $snippet, strlen($matches[1][count($matches[1]) - 1]) + 1, 0);
1049
      }
1050
      else {
1051
        $breadcrumb = '<span ' . $snippet_title . '>' . $breadcrumb . '</span>';
1052
      }
1053
      $vars['breadcrumb'][$key] = '<span typeof="v:Breadcrumb">' . $breadcrumb . '</span>';
1054
    }
1055
  }
1056 85ad3d82 Assos Assos
}