Projet

Général

Profil

Révision 74f6bef0

Ajouté par Assos Assos il y a plus de 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/themes/adaptivetheme/at_core/inc/preprocess.inc
10 10
 * Preprocess variables for all templates.
11 11
 */
12 12
function adaptivetheme_preprocess(&$vars) {
13
  // Provide a variable to all templates to test for a mobile context, this
14
  // requires the Browscap module and returns TRUE or FALSE.
15
  $vars['is_mobile'] = at_get_browser();
13
  // 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'];
16 19
}
17 20

  
18 21
/**
......
34 37
  $vars['doctype'] = '<!DOCTYPE html>' . "\n";
35 38
  $vars['rdf_profile'] = '';
36 39

  
37
  // Use a proper attributes array for the html attributes
40
  // 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/';
38 43
  $vars['html_attributes_array']['lang'][] = $language->language;
39 44
  $vars['html_attributes_array']['dir'][] = $language->dir;
40 45

  
......
51 56
  $path = variable_get('theme_' . $theme_name . '_files_directory');
52 57

  
53 58
  // Load Layout
54
  load_layout_css($path, $theme_name);
59
  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);
55 64

  
56 65
  // Load Responsive Styles.
57 66
  if (at_get_setting('disable_responsive_styles', $theme_name) === 0) {
58
    load_responsive_css($path, $theme_name);
67
    at_load_responsive_css($path, $theme_name);
59 68
  }
60 69

  
61
  // Load fonts and/or Custom CSS
70
  // Load fonts and/or Custom CSS and the menu toggle files
62 71
  if (at_get_setting('enable_extensions', $theme_name) === 1) {
63 72
    // Fonts CSS
64 73
    if (at_get_setting('enable_font_settings', $theme_name) === 1) {
65
      load_fonts($path, $theme_name);
74
      at_load_fonts($path, $theme_name);
66 75
    }
67 76
    // Custom CSS
68 77
    if (at_get_setting('enable_custom_css', $theme_name) === 1) {
69
      load_custom_css($path, $theme_name);
78
      at_load_custom_css($path, $theme_name);
79
    }
80
    // Load the menu toggle js and css files
81
    if (at_get_setting('enable_menu_toggle', $theme_name) === 1) {
82
      at_load_menu_toggle($path, $theme_name);
70 83
    }
71 84
    // Load Extension Settings CSS
72
    load_extensions_css($theme_name);
85
    at_load_extensions_css($theme_name);
73 86
  }
74 87

  
75 88
  // Load conditional stylesheets declared in the info file
76 89
  if (isset($info['ie_stylesheets'])) {
77
    load_subtheme_conditional_styles($theme_name);
90
    at_load_subtheme_conditional_styles($theme_name);
78 91
  }
79 92

  
80 93
  // Load specific subtheme scripts
81 94
  if (at_get_setting('load_onmediaqueryjs', $theme_name) === 1) {
82
    load_subtheme_script('scripts/media_queries.js', $theme_name, 'footer', '100');
95
    at_load_subtheme_script('scripts/media_queries.js', $theme_name, 'footer', '100');
83 96
  }
84 97

  
85
  // Build an array of polyfilling scripts
86
  $vars['polyfills_array'] = '';
87
  $vars['polyfills_array'] = load_polyfills($theme_name, $vars);
98
  // Load polyfills
99
  $vars['polyfills'] = at_load_polyfills($theme_name, $vars);
88 100

  
89
  // Set the skip link target id
101
  // Set the skip navigation target ID
90 102
  $vars['skip_link_target'] = '#main-content';
91 103
  if (at_get_setting('skip_link_target', $theme_name)) {
92 104
    $skip_link_target = at_get_setting('skip_link_target', $theme_name);
......
94 106
  }
95 107

  
96 108
  // Generate body classes
97
  if ($html_classes = generate_html_classes($vars, $theme_name)) {
109
  if ($html_classes = at_generate_html_classes($vars, $theme_name)) {
98 110
    foreach ($html_classes as $class_name) {
99 111
      $vars['classes_array'][] = $class_name;
100 112
    }
......
107 119
    include_once(drupal_get_path('theme', 'adaptivetheme') . '/inc/google.web.fonts.inc');
108 120
  }
109 121

  
110
  // Load debuggers if enabled. Panels page debugger is a menu item, see alter.inc
122
  // Load debuggers if enabled.
111 123
  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) {
112
    load_debuggers($theme_name);
124
    at_load_debuggers($theme_name);
113 125
  }
114 126
}
115 127

  
......
122 134

  
123 135
  // Set up logo element
124 136
  if (at_get_setting('toggle_logo', $theme_name) === 1) {
125
    $vars['site_logo'] = drupal_static('adaptivetheme_preprocess_page_site_logo');
137
    $vars['site_logo'] = &drupal_static('adaptivetheme_preprocess_page_site_logo');
126 138
    if (empty($vars['site_logo'])) {
127
      $logo_path = check_url($vars['logo']);
128
      $logo_alt = check_plain(variable_get('site_name', t('Site logo')));
129
      $logo_vars = array('path' => $logo_path, 'alt' => $logo_alt, 'attributes' => array('class' => 'site-logo'));
130
      $vars['logo_img'] = theme('image', $logo_vars);
131
      $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('attributes' => array('title' => t('Home page')), 'html' => TRUE)) : '';
139
      $logo_image_path = check_url($vars['logo']);
140
      $logo_image_alt = check_plain(variable_get('site_name', t('Home page')));
141
      $logo_image_vars = array('path' => $logo_image_path, 'alt' => $logo_image_alt, 'attributes' => array('class' => 'site-logo'));
142
      $vars['logo_img'] = theme('image', $logo_image_vars);
143
      if (at_get_setting('logo_title') == 1) {
144
        $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('attributes' => array('title' => $logo_image_alt), 'html' => TRUE)) : '';
145
      }
146
      else {
147
        $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('html' => TRUE)) : '';
148
      }
132 149
    }
133 150
    // Maintain backwards compatibility with 7.x-2.x sub-themes
134 151
    $vars['linked_site_logo'] = $vars['site_logo'];
......
160 177

  
161 178
  // Build a variable for the main menu
162 179
  if (isset($vars['main_menu'])) {
180
    $main_menu_title = at_get_setting('menu_button_link_text') ? at_get_setting('menu_button_link_text') : t('Main menu');
163 181
    $vars['primary_navigation'] = theme('links', array(
164 182
      'links' => $vars['main_menu'],
165 183
      'attributes' => array(
166 184
        'class' => array('menu', 'primary-menu', 'clearfix'),
167 185
       ),
168 186
      'heading' => array(
169
        'text' => t('Main menu'),
187
        'text'  => $main_menu_title,
170 188
        'level' => 'h2',
171 189
        'class' => array('element-invisible'),
190
        'id'    => array('primary-menu'),
172 191
      )
173 192
    ));
174 193
  }
......
181 200
        'class' => array('menu', 'secondary-menu', 'clearfix'),
182 201
      ),
183 202
      'heading' => array(
184
        'text' => t('Secondary navigation'),
203
        'text'  => t('Secondary menu'),
185 204
        'level' => 'h2',
186 205
        'class' => array('element-invisible'),
206
        'id'    => 'secondary-menu',
187 207
      )
188 208
    ));
189 209
  }
......
195 215
  // Add back the $search_box var to D7
196 216
  if (module_exists('search')) {
197 217
    $search_box = drupal_get_form('search_form');
198
    $vars['search_box'] = '<div id="search-box">' . drupal_render($search_box) . '</div>';
218
    $vars['search_box'] = '<div id="search-box" role="search">' . drupal_render($search_box) . '</div>';
199 219
  }
200 220

  
201 221
  // Process enabled Extensions
202 222
  if (at_get_setting('enable_extensions', $theme_name) === 1) {
203 223
    // Generate page classes, in AT Core these are all Extensions
204
    if ($page_classes = generate_page_classes($vars, $theme_name)) {
224
    if ($page_classes = at_generate_page_classes($vars, $theme_name)) {
205 225
      foreach ($page_classes as $class_name) {
206 226
        $vars['classes_array'][] = $class_name;
207 227
      }
......
215 235
    }
216 236
  }
217 237

  
218
  // Strip stupid contextual-links-region class, wtf?
219
  $vars['classes_array'] = array_values(array_diff($vars['classes_array'], array('contextual-links-region')));
238
  // Strip stupid contextual-links-region class.
239
  //$vars['classes_array'] = array_values(array_diff($vars['classes_array'], array('contextual-links-region')));
220 240

  
221 241
  // page attributes
222 242
  $vars['page_attributes_array']['id'][] = 'page';
......
227 247
  $vars['header_attributes_array']['class'][] = 'clearfix';
228 248
  $vars['header_attributes_array']['role'][] = 'banner';
229 249

  
230
  // hgroup attributes
231
  $vars['hgroup_attributes_array'] = array();
232
  if (!$vars['site_slogan'] && $vars['hide_site_name']) {
233
    $vars['hgroup_attributes_array']['class'][] = $vars['visibility'];
234
  }
235

  
236 250
  // branding attributes
237 251
  $vars['branding_attributes_array']['id'][] = 'branding';
238 252
  $vars['branding_attributes_array']['class'][] = 'branding-elements';
239 253
  $vars['branding_attributes_array']['class'][] = 'clearfix';
240 254

  
241
  // hgroup attributes
255
  // site name and slogan attributes (wrapper div)
256
  // hgroup maintains BC layer for pre 7.x-3.2 themes
257
  $vars['hgroup_attributes_array'] = array();
258
  if (!$vars['site_slogan'] && $vars['hide_site_name']) {
259
    $vars['hgroup_attributes_array']['class'][] = $vars['visibility'];
260
  }
261
  $vars['hgroup_attributes_array']['class'][] = 'h-group';
242 262
  $vars['hgroup_attributes_array']['id'][] = 'name-and-slogan';
243 263

  
244 264
  // site name attributes
......
257 277
  $vars['footer_attributes_array']['role'][] = 'contentinfo';
258 278

  
259 279
  // Attribution variable used in admin theme and some others
260
  $vars['attribution'] = "<small class=\"attribution\"><a href=\"http://adaptivethemes.com\">Premium Drupal Themes</a></small>";
280
  $vars['attribution'] = '';
281
  if (at_get_setting('attribution_toggle', $theme_name) === 1) {
282
    $vars['attribution'] = "<small class=\"attribution\">Premium Drupal Theme by <a href=\"http://adaptivethemes.com\">Adaptivethemes.com</a></small>";
283
  }
261 284

  
262 285
  // Work around a perculier bug/feature(?) in Drupal 7 which incorrectly sets
263 286
  // the page title to "User account" for all three of these pages.
264
  if (arg(0) === 'user') {
287
  $title = drupal_get_title();
288
  if (arg(0) === 'user' && $title == t('User account')) {
265 289
    if (arg(1) === 'login' || arg(1) == '') {
266 290
      drupal_set_title(t('User login'));
267 291
    }
......
352 376
 */
353 377
function adaptivetheme_preprocess_block(&$vars) {
354 378
  global $theme_key;
379
  global $user;
355 380
  $theme_name = $theme_key;
356 381

  
357 382
  // Block subject, under certain conditions, is not set
......
381 406
    $vars['tag'] = 'div';
382 407
  }
383 408

  
384
  // Initialize and populate the inner wrapper variables
385
  $vars['inner_prefix'] = '<div class="block-inner clearfix">';
386
  $vars['inner_suffix'] = '</div>';
409
  // Block inner attributes
410
  $vars['block_inner_attributes_array']['class'][] = 'block-inner';
411
  $vars['block_inner_attributes_array']['class'][] = 'clearfix';
387 412

  
388 413
  // Use nav element for menu blocks and provide a suggestion for all of them
389 414
  $nav_blocks = array('navigation', 'main-menu', 'management', 'user-menu');
......
391 416
    $vars['tag'] = 'nav';
392 417
    array_unshift($vars['theme_hook_suggestions'], 'block__menu');
393 418
  }
394
  $nav_modules = array('superfish', 'nice_menus', 'menu_block');
419

  
420
  $nav_modules = array('superfish', 'nice_menus', 'menu_block', 'menu');
395 421
  if (in_array($vars['block']->module, $nav_modules)) {
396 422
    $vars['tag'] = 'nav';
397 423
    array_unshift($vars['theme_hook_suggestions'], 'block__menu');
......
399 425

  
400 426
  // The menu bar region gets special treatment for the block template
401 427
  if ($vars['block']->region === 'menu_bar') {
402
    // They are always menu blocks, right?
403
    $vars['tag'] = 'nav';
428
    $vars['classes_array'][] = 'menu-wrapper';
429
    $vars['classes_array'][] = 'menu-bar-wrapper';
430
    $vars['classes_array'][] = 'clearfix';
431
    $vars['title_attributes_array']['class'][] = 'element-invisible';
404 432
  }
405 433

  
406 434
  // The menu bar region gets special treatment for the block template
407
  if ($vars['block']->region === 'menu_bar') {
408
    // Hide titles, very unlikey to want it show, ever
409
    $vars['title_attributes_array']['class'][] = 'element-invisible';
410
    $vars['classes_array'][] = 'menu-wrapper menu-bar-wrapper clearfix';
435
  if (at_get_setting('enable_menu_toggle', $theme_name) === 1) {
436
    if (at_get_setting('menu_toggle_menu_bar', $theme_name) === 1) {
437
      if ($vars['block']->region === 'menu_bar') {
438
        $vars['classes_array'][] = 'at-menu-toggle';
439
      }
440
    }
441
    if (at_get_setting('menu_toggle_leaderboard', $theme_name) === 1 && $vars['block']->region === 'leaderboard') {
442
      $vars['classes_array'][] = 'at-menu-toggle';
443
      $vars['classes_array'][] = 'clearfix';
444
    }
445
    if (at_get_setting('menu_toggle_header', $theme_name) === 1 && $vars['block']->region === 'header') {
446
      $vars['classes_array'][] = 'at-menu-toggle';
447
      $vars['classes_array'][] = 'clearfix';
448
    }
411 449
  }
412 450

  
413 451
  // Add extra classes if required
......
437 475
  // Add classes to theme the horizontal block option
438 476
  if (at_get_setting('enable_extensions', $theme_name) === 1) {
439 477
    if (at_get_setting('enable_markup_overides', $theme_name) === 1) {
478
      // Change the user menu title to the user name.
479
      if (at_get_setting('user_block_user_name', $theme_name) === 1) {
480
        if ($vars['block']->module == 'system' && $vars['block']->delta == 'user-menu') {
481
          if (user_is_logged_in()) {
482
            $vars['title'] = check_plain($user->name);
483
          }
484
        }
485
      }
486
      // Horizontal block classes.
440 487
      if (at_get_setting('horizontal_login_block', $theme_name) === 1 && $vars['block']->module === 'user' && $vars['block']->delta === 'login') {
441 488
        $vars['classes_array'][] = 'lb-h';
442 489
        $vars['title_attributes_array']['class'][] = 'element-invisible';
......
449 496

  
450 497
  // Give our block titles and content some additional class
451 498
  $vars['title_attributes_array']['class'][] = 'block-title';
452
  $vars['content_attributes_array']['class'][] = 'block-content';
453
  $vars['content_attributes_array']['class'][] = 'content';
499
  $vars['content_attributes_array']['class'] = array('block-content', 'content');
500

  
501
  // Support aria-describedby
502
  if ($vars['block']->subject && !empty($vars['attributes_array']['role'])) {
503
    $vars['title_attributes_array']['id'] = drupal_html_id($vars['block']->subject);
504
    $vars['attributes_array']['aria-describedby'] = $vars['title_attributes_array']['id'];
505
  }
454 506

  
455 507
  // Add Aria Roles via attributes
456 508
  switch ($vars['block']->module) {
......
611 663
    }
612 664

  
613 665
    // User picture?
666
    // Should we all a check for the global settings here? SEE: https://drupal.org/node/2020687
614 667
    if (at_get_setting('toggle_node_user_picture', $theme_name) === 1) {
615 668
      if ($vars['display_submitted'] && !empty($vars['picture'])) {
616 669
        $vars['classes_array'][] = 'node-with-picture';
......
651 704
  // Classes and attributes
652 705
  $vars['title_attributes_array']['class'][] = 'node-title';
653 706
  $vars['content_attributes_array']['class'][] = 'node-content';
654
  $vars['title_attributes_array']['rel'][] = 'nofollow';
655 707

  
656 708
  // header, submitted and links wrappers have their own attributes
657 709
  $vars['header_attributes_array']['class'][] = 'node-header';
......
730 782
    }
731 783

  
732 784
    // User picture?
785
    // Should we add a check for the global settings here? SEE: https://drupal.org/node/2020687
733 786
    if (at_get_setting('toggle_comment_user_picture', $theme_name) === 1) {
734 787
      if (!empty($vars['picture'])) {
735 788
        $vars['classes_array'][] = 'comment-with-picture';
......
765 818
  }
766 819
  $vars['links_attributes_array']['class'][] = 'clearfix';
767 820

  
768
  // Build the submitted by and time elements
821
  // Build the submitted by, permalink, title and time elements
769 822
  $uri = entity_uri('comment', $vars['comment']);
770 823
  $uri['options'] += array('attributes' => array('rel' => 'bookmark'));
771 824
  $vars['title'] = l($vars['comment']->subject, $uri['path'], $uri['options']);
772
  $vars['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']); // Permalinks are embedded in the time element, aka Wordpress
773
  $vars['created'] = '<span class="date-time permalink">' . l($vars['created'], $uri['path'], $uri['options']) . '</span>';
825

  
826
  // Don't rebuild the permalink variable if Advanced Forum is enabled
827
  if (!module_exists('advanced_forum')) {
828
    $vars['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
829
  }
830

  
831
  $vars['created'] = '<span class="date-time">' . $vars['created'] . '</span>';
832

  
774 833
  $vars['datetime'] = format_date($vars['comment']->created, 'custom', 'Y-m-d\TH:i:s\Z'); // Generate the timestamp, PHP "c" format is wrong
834

  
775 835
  $vars['submitted'] = t('Submitted by !username on !datetime',
776 836
    array(
777 837
      '!username' => $vars['author'],
......
814 874
 * Preprocess variables for adaptivtheme_menubar()
815 875
 */
816 876
function adaptivetheme_preprocess_menubar(&$vars) {
877
  global $theme_key;
878
  $theme_name = $theme_key;
817 879
  $type = $vars['type'];
880

  
881
  // menu bar id
818 882
  $vars['menubar_id'] = $type . '-menu-bar';
819
  $vars['classes_array'][] = 'nav clearfix';
883
  // Add classes to the main wrapper
884
  $vars['classes_array'] = array('nav', 'clearfix');
885

  
886
  // Classes for toggle menus
887
  if (at_get_setting('enable_menu_toggle', $theme_name) === 1) {
888
    if (at_get_setting('menu_toggle_main_menu', $theme_name) === 1 && $type === 'primary') {
889
      $vars['classes_array'][] = 'at-menu-toggle';
890
    }
891
    if (at_get_setting('menu_toggle_secondary_menu', $theme_name) === 1 && $type === 'secondary') {
892
      $vars['classes_array'][] = 'at-menu-toggle';
893
    }
894
  }
895

  
896
  // Add classes to the inner wrapper
897
  $vars['content_attributes_array']['class'][] = $type . '-menu-wrapper';
898
  $vars['content_attributes_array']['class'][] = 'menu-wrapper';
899
  $vars['content_attributes_array']['class'][] = 'clearfix';
900
  // Aria
820 901
  $vars['content_attributes_array']['role'][] = 'navigation';
821
  $vars['content_attributes_array']['class'][] = $type . '-menu-wrapper menu-wrapper clearfix';
902
  $vars['content_attributes_array']['aria-labelledby'][] = $type . '-menu';
903

  
822 904
  // Add suggstions per menu type
823 905
  $vars['theme_hook_suggestions'][] = 'menubar__' . $type;
824 906
}
......
857 939
  // Some modules set the style name even when its empty, such as User Badges
858 940
  // module, so initialize the class name variable with a "none" class
859 941
  $style_name_class = 'none';
860
  
942

  
861 943
  // If there really is a style name use it for the class
862 944
  if (isset($vars['style_name']) && !empty($vars['style_name'])) {
863 945
    $style_name_class = drupal_html_class($vars['style_name']);
864 946
  }
865 947

  
866
  // In the first instance we assume class attributes is an array, as it should be,
867
  // and add the image style class
948
  // Check if the class attributes is an array. If we don't do this check and
949
  // the class attribute is string it can cause a fatal error.
950
  // See http://drupal.org/node/1722146 for an example
868 951
  if (is_array($vars['attributes']['class'])) {
869 952
    $vars['attributes']['class'][] = 'image-style-' . $style_name_class;
870 953
  }
871
  else {
872
    // Else it's a string, workaround for Media module bug: http://drupal.org/node/1722146
873
    // and User Badges bug: http://drupal.org/node/1748394
874
    $vars['attributes']['class'] .= ' image-style-' . $style_name_class;
875
  }
876 954
}
877 955

  
878 956
/**
......
886 964
  $path = variable_get('theme_' . $theme_name . '_files_directory');
887 965

  
888 966
  // Load Layout
889
  load_layout_css($path, $theme_name);
967
  at_load_layout_css($path, $theme_name);
890 968

  
891 969
  // Load Responsive Styles.
892 970
  if (at_get_setting('disable_responsive_styles', $theme_name) === 0) {
893
    load_responsive_css($path, $theme_name);
971
    at_load_responsive_css($path, $theme_name);
894 972
  }
895 973

  
896 974
  // Load fonts and/or Custom CSS
897 975
  if (at_get_setting('enable_extensions', $theme_name) === 1) {
898 976
    // Fonts CSS
899 977
    if (at_get_setting('enable_font_settings', $theme_name) === 1) {
900
      load_fonts($path, $theme_name);
978
      at_load_fonts($path, $theme_name);
901 979
    }
902 980
    // Custom CSS
903 981
    if (at_get_setting('enable_custom_css', $theme_name) === 1) {
904
      load_custom_css($path, $theme_name);
982
      at_load_custom_css($path, $theme_name);
905 983
    }
906 984
    // Load Extension Settings CSS
907
    load_extensions_css($theme_name);
985
    at_load_extensions_css($theme_name);
908 986
  }
909 987

  
910
  // Build an array of polyfilling scripts
911
  $vars['polyfills_array'] = '';
912
  $vars['polyfills_array'] = load_polyfills($theme_name, $vars);
988
  // Load polyfills
989
  $vars['polyfills'] = at_load_polyfills($theme_name, $vars);
913 990

  
914 991
  // Load the colors stylesheet for the active color scheme. This only works
915 992
  // for maintenance mode, when there is a database error the default color
......
925 1002
    }
926 1003
  }
927 1004

  
928
  $vars['attribution'] = "<small id=\"attribution\"><a href=\"http://adaptivethemes.com\">Premium Drupal Themes</a></small>";
1005
  // Attribution variable used in admin theme and some others
1006
  $vars['attribution'] = '';
1007
  if (at_get_setting('attribution_toggle', $theme_name) === 1) {
1008
    $vars['attribution'] = "<small class=\"attribution\">Premium Drupal Theme by <a href=\"http://adaptivethemes.com\">Adaptivethemes.com</a></small>";
1009
  }
1010
}
1011

  
1012
/**
1013
 * Preprocess variables for user-profile.tpl.php
1014
 */
1015
function adaptivetheme_preprocess_user_profile(&$vars) {
1016
  $vars['classes_array'][] = 'profile';
1017
}
1018

  
1019
/**
1020
 * Preprocess variables for breadcrumbs
1021
 */
1022
function adaptivetheme_preprocess_breadcrumb(&$vars) {
1023
  // Add Google rich snippets to breadcrumbs using RDFa
1024
  if (module_exists('rdf')) {
1025
    $snippet_url = ' rel="v:url" ';
1026
    $snippet_title = ' property="v:title" ';
1027
    foreach ($vars['breadcrumb'] as $key => $breadcrumb) {
1028
      preg_match_all('/<([\w]+)[^>]*>.*?<\/\\1>/', $breadcrumb, $matches);
1029
      if (count($matches[0]) > 0) {
1030
        $snippet = $snippet_title;
1031
        if ($matches[1][count($matches[1]) - 1] == 'a') {
1032
          $snippet = $snippet_url . $snippet_title;
1033
        }
1034
        $breadcrumb = substr_replace($breadcrumb, $snippet, strlen($matches[1][count($matches[1]) - 1]) + 1, 0);
1035
      }
1036
      else {
1037
        $breadcrumb = '<span ' . $snippet_title . '>' . $breadcrumb . '</span>';
1038
      }
1039
      $vars['breadcrumb'][$key] = '<span typeof="v:Breadcrumb">' . $breadcrumb . '</span>';
1040
    }
1041
  }
929 1042
}

Formats disponibles : Unified diff