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/alter.inc
15 15
  // charset utf-8
16 16
  $head_elements['system_meta_content_type']['#attributes'] = array('charset' => 'utf-8');
17 17

  
18
  // Metatags for mobile
19
  // X-UA-Compatible
20
  if (at_get_setting('chrome_edge', $theme_name) === 1) {
21
    $head_elements['adaptivetheme_meta_x_ua_compatible'] = array(
18
  // IE Document Mode
19
  if ($adaptivetheme_meta_ie_document_mode = at_get_setting('adaptivetheme_meta_ie_document_mode', $theme_name)) {
20
    $head_elements['adaptivetheme_meta_ie_document_mode'] = array(
22 21
      '#type' => 'html_tag',
23 22
      '#tag' => 'meta',
24 23
      '#attributes' => array(
25 24
        'http-equiv' => "X-UA-Compatible",
26
        'content' => "IE=edge, chrome=1",
25
        'content' => $adaptivetheme_meta_ie_document_mode,
27 26
      ),
28
      '#weight' => 1,
27
      '#weight' => -999, // 1 less than the charset
29 28
    );
30 29
  }
31 30

  
32 31
  // cleartype
33
  if (at_get_setting('clear_type', $theme_name) === 1) {
34
    $head_elements['adaptivetheme_meta_cleartype'] = array(
32
  if (at_get_setting('adaptivetheme_meta_clear_type', $theme_name) === 1) {
33
    $head_elements['adaptivetheme_meta_clear_type'] = array(
35 34
      '#type' => 'html_tag',
36 35
      '#tag' => 'meta',
37 36
      '#attributes' => array(
38 37
        'http-equiv' => "cleartype",
39 38
        'content' => "on",
40 39
      ),
41
      '#weight' => 2,
40
      '#weight' => -998,
42 41
    );
43 42
  }
44 43

  
......
54 53
          'name' => 'viewport',
55 54
          'content' => check_plain($adaptivetheme_meta_viewport),
56 55
        ),
57
        '#weight' => 3,
56
        '#weight' => 1,
58 57
      );
59 58
    }
60 59

  
......
67 66
          'name' => "MobileOptimized",
68 67
          'content' => check_plain($adaptivetheme_meta_mobileoptimized),
69 68
        ),
70
        '#weight' => 4,
69
        '#weight' => 2,
71 70
      );
72 71
    }
73 72

  
......
80 79
          'name' => "HandheldFriendly",
81 80
          'content' => check_plain($adaptivetheme_meta_handheldfriendly),
82 81
        ),
83
        '#weight' => 5,
82
        '#weight' => 3,
84 83
      );
85 84
    }
86 85

  
87 86
    // apple-mobile-web-app-capable
88 87
    if ($adaptivetheme_meta_apple_mobile_web_app_capable = at_get_setting('adaptivetheme_meta_apple_mobile_web_app_capable', $theme_name)) {
89
    $head_elements['adaptivetheme_meta_apple_mobile_web_app_capable'] = array(
90
      '#type' => 'html_tag',
91
      '#tag' => 'meta',
92
      '#attributes' => array(
93
        'name' => "apple-mobile-web-app-capable",
94
        'content' => check_plain($adaptivetheme_meta_apple_mobile_web_app_capable),
95
      ),
96
      '#weight' => 6,
88
      $head_elements['adaptivetheme_meta_apple_mobile_web_app_capable'] = array(
89
        '#type' => 'html_tag',
90
        '#tag' => 'meta',
91
        '#attributes' => array(
92
          'name' => "apple-mobile-web-app-capable",
93
          'content' => check_plain($adaptivetheme_meta_apple_mobile_web_app_capable),
94
        ),
95
        '#weight' => 4,
97 96
      );
98 97
    }
99 98
  }
......
101 100
  // Apple touch icons - low, medium and high (see the Apple docs on touch icons)
102 101
  if (at_get_setting('enable_apple_touch_icons') === 1) {
103 102
    $path_to_theme = drupal_get_path('theme', $theme_name);
104
    // low
105
    $apple_touch_icon_path_l = check_plain(at_get_setting('apple_touch_icon_path_l', $theme_name));
106
    if (!empty($apple_touch_icon_path_l)) {
107
      $l = $path_to_theme . '/' . $apple_touch_icon_path_l;
108
      $touch_icon_l = file_create_url($l);
103

  
104
    $rel = 'apple-touch-icon';
105
    if (at_get_setting('enable_apple_touch_icon_precomposed') === 1) {
106
      $rel = 'apple-touch-icon-precomposed';
107
    }
108

  
109
    // Apple default icon and Nokia shortcut icon.
110
    $icon_path_default = check_plain(at_get_setting('icon_path_default', $theme_name));
111
    if (!empty($icon_path_default)) {
112
      $default_icon_path = $path_to_theme . '/' . $icon_path_default;
113
      $default_icon_url = file_create_url($default_icon_path);
109 114
      $head_elements['adaptivetheme_touch_icon_nokia'] = array(
110 115
        '#type' => 'html_tag',
111 116
        '#tag' => 'link',
112 117
        '#weight' => -97,
113 118
        '#attributes' => array(
114
          'href' => $touch_icon_l,
119
          'href' => $default_icon_url,
115 120
          'rel' => "shortcut icon",
116 121
        ),
117 122
      );
118
      $head_elements['adaptivetheme_touch_icon_low'] = array(
123
      $head_elements['adaptivetheme_touch_icon_default'] = array(
119 124
        '#type' => 'html_tag',
120 125
        '#tag' => 'link',
121 126
        '#weight' => -98,
122 127
        '#attributes' => array(
123
          'href' => $touch_icon_l,
124
          'rel' => "apple-touch-icon-precomposed",
128
          'href' => $default_icon_url,
129
          'rel' => $rel,
125 130
        ),
126 131
      );
127 132
    }
128
    // medium
129
    $apple_touch_icon_path_m = check_plain(at_get_setting('apple_touch_icon_path_m', $theme_name));
130
    if (!empty($apple_touch_icon_path_m)) {
131
      $m = $path_to_theme . '/' . $apple_touch_icon_path_m;
132
      $touch_icon_m = file_create_url($m);
133
      $head_elements['adaptivetheme_touch_icon_medium'] = array(
133
    // iPad (standard display).
134
    $apple_touch_icon_path_ipad = check_plain(at_get_setting('apple_touch_icon_path_ipad', $theme_name));
135
    if (!empty($apple_touch_icon_path_ipad)) {
136
      $ipad_icon_path = $path_to_theme . '/' . $apple_touch_icon_path_ipad;
137
      $ipad_icon_url = file_create_url($ipad_icon_path);
138
      $head_elements['adaptivetheme_touch_icon_ipad'] = array(
134 139
        '#type' => 'html_tag',
135 140
        '#tag' => 'link',
136 141
        '#weight' => -99,
137 142
        '#attributes' => array(
138
          'href' => $touch_icon_m,
139
          'rel' => "apple-touch-icon-precomposed",
140
          'sizes' => "72x72",
143
          'href' => $ipad_icon_url,
144
          'rel' => $rel,
145
          'sizes' => "76x76",
141 146
        ),
142 147
      );
143 148
    }
144
    // high
145
    $apple_touch_icon_path_h = check_plain(at_get_setting('apple_touch_icon_path_h', $theme_name));
146
    if (!empty($apple_touch_icon_path_h)) {
147
      $h = $path_to_theme . '/' . $apple_touch_icon_path_h;
148
      $touch_icon_h = file_create_url($h);
149
      $head_elements['adaptivetheme_touch_icon_high'] = array(
149
    // iPhone retina.
150
    $apple_touch_icon_path_iphone_retina = check_plain(at_get_setting('apple_touch_icon_path_iphone_retina', $theme_name));
151
    if (!empty($apple_touch_icon_path_iphone_retina)) {
152
      $iphone_retina_icon_path = $path_to_theme . '/' . $apple_touch_icon_path_iphone_retina;
153
      $iphone_retina_icon_url = file_create_url($iphone_retina_icon_path);
154
      $head_elements['adaptivetheme_touch_icon_iphone_retina'] = array(
150 155
        '#type' => 'html_tag',
151 156
        '#tag' => 'link',
152 157
        '#weight' => -100,
153 158
        '#attributes' => array(
154
          'href' => $touch_icon_h,
155
          'rel' => "apple-touch-icon-precomposed",
156
          'sizes' => "114x114",
159
          'href' => $iphone_retina_icon_url,
160
          'rel' => $rel,
161
          'sizes' => "120x120",
162
        ),
163
      );
164
    }
165
    // iPad retina.
166
    $apple_touch_icon_path_ipad_retina = check_plain(at_get_setting('apple_touch_icon_path_ipad_retina', $theme_name));
167
    if (!empty($apple_touch_icon_path_ipad_retina)) {
168
      $ipad_retina_icon_path = $path_to_theme . '/' . $apple_touch_icon_path_ipad_retina;
169
      $ipad_retina_icon_url = file_create_url($ipad_retina_icon_path);
170
      $head_elements['adaptivetheme_touch_icon_ipad_retina'] = array(
171
        '#type' => 'html_tag',
172
        '#tag' => 'link',
173
        '#weight' => -100,
174
        '#attributes' => array(
175
          'href' => $ipad_retina_icon_url,
176
          'rel' => $rel,
177
          'sizes' => "152x152",
157 178
        ),
158 179
      );
159 180
    }
......
164 185
 * hook_js_alter()
165 186
 */
166 187
function adaptivetheme_js_alter(&$javascript) {
188
  global $theme_key;
189

  
167 190
  // Use our own vesion of vertical-tabs.js for better error handling
168 191
  // @see http://drupal.org/node/607752
169 192
  if (isset($javascript['misc/vertical-tabs.js'])) {
170 193
    $file = drupal_get_path('theme', 'adaptivetheme') . '/scripts/vertical-tabs.js';
171 194
    $javascript['misc/vertical-tabs.js'] = drupal_js_defaults($file);
172 195
  }
196

  
197
  // Combine JS files into one per type, this is a bit mad and
198
  // we probably shouldn't encourage such things :)
199
  if (at_get_setting('combine_js_files', $theme_key) === 1) {
200
    uasort($javascript, 'drupal_sort_css_js');
201
    $weight = 0;
202
    foreach ($javascript as $name => $script) {
203
      $javascript[$name]['group'] = -100;
204
      $javascript[$name]['weight'] = ++$weight;
205
      $javascript[$name]['every_page'] = 1;
206
    }
207
  }
173 208
}
174 209

  
175 210
/**
......
222 257
      }
223 258
    }
224 259
  }
260

  
261
  // Combine CSS files into one per type, this is not perfect
262
  if (at_get_setting('combine_css_files', $theme_key) === 1) {
263
    uasort($css, 'drupal_sort_css_js');
264
    $print = array();
265
    $weight = 0;
266
    foreach ($css as $name => $style) {
267
      // Leave  the conditional stylesheets untouched
268
      if ($css[$name]['browsers']['!IE']) {
269
        $css[$name]['group'] = 0;
270
        $css[$name]['weight'] = $weight++;
271
        $css[$name]['every_page'] = TRUE;
272
      }
273
      if ($css[$name]['media'] == 'print') {
274
        $print[$name] = $css[$name];
275
        unset($css[$name]);
276
      }
277
    }
278
    $css = array_merge($css, $print);
279
  }
225 280
}
226 281

  
227 282
/**
......
231 286
  global $theme_key;
232 287
  $theme_name = $theme_key;
233 288

  
234
  // Is this a mobile context?
235
  $page['is_mobile'] = at_get_browser();
236

  
237 289
  // Get the menu item
238 290
  $menu_item = menu_get_item();
239 291

  
......
264 316
    $block_regions = system_region_list($GLOBALS['theme'], REGIONS_VISIBLE);
265 317
  }
266 318

  
319
  // Setup the detection environment
320
  $detection = variable_get('at_detection', 0);
321
  if ($detection == 1) {
322
    $browscap_detect = variable_get('at_browscap_detect', 0);
323
    $mobile_detect = variable_get('at_mobile_detect', 0);
324
    $browser = at_get_browser();
325
    $page['is_mobile'] = $browser['is_mobile'];
326
    $page['is_tablet'] = $browser['is_tablet'];
327
  }
328
  else {
329
    $page['is_mobile'] = FALSE;
330
    $page['is_tablet'] = FALSE;
331
  }
332

  
267 333
  // Look in each visible region for blocks
268 334
  foreach ($block_regions as $region => $name) {
269 335
    if (!empty($page[$region])) {
......
275 341
      }
276 342

  
277 343
      if ($blocks) {
278
        
344

  
279 345
        // Set a bool for the last class for blocks feature
280 346
        $page[$region][$blocks[0]]['#block']->last_in_region = TRUE;
281 347

  
......
284 350
        if (at_get_setting('enable_extensions', $theme_name) === 1) {
285 351
          if (at_get_setting('enable_context_regions') === 1) {
286 352

  
287
            if ($page['is_mobile'] == TRUE && $region !== 'content') {
288

  
289
              // Get the target region if set, check blocks can move and its not set to unset
290
              if (($target_region = at_get_setting('move_' . $region)) && ($target_region !== 'do_not_move') && (at_get_setting('unset_' . $region) !== 1)) {
291

  
292
                // Sanitize possible vector
293
                $target_region = check_plain($target_region);
294

  
295
                // Initialize the classes array
296
                $classes = array();
297

  
298
                // Move each block
299
                foreach ($blocks as $block) {
300

  
301
                  // If the $target_region is empty the region markup does not print
302
                  // so we need to generate it manually. This is bad because it
303
                  // cannot account for region specific template suggestions and
304
                  // Adaptivethemes own region prefix and suffix wrappers.
305
                  if (empty($page[$target_region])) {
306
                    $classes[] = 'region';
307
                    $classes[] = 'region-' . $target_region;
308
                    if ($target_region == 'sidebar_first' || $target_region == 'sidebar_second') {
309
                      $classes[] = 'sidebar';
310
                    }
311
                    $classes = implode(' ', $classes);
312
                    $page[$target_region]['#prefix'] = '<div class="' .  $classes . '"><div class="region-inner clearfix">';
313
                    $page[$target_region]['#suffix'] = '</div></div>';
314
                  }
315

  
316
                  // Move the blocks to the target region
317
                  $page[$target_region][$block] = $page[$region][$block];
318

  
319
                  // Unset the original block
320
                  unset($page[$region][$block]);
353
            // UNSET
354
            if (at_get_setting('unset_' . $region) === 1) {
355
              if (at_get_setting('unset_options_' . $region) == 'unset_smalltouch') {
356
                if ($page['is_mobile'] === TRUE && $page['is_tablet'] === FALSE) {
357
                  unset($page[$region]);
358
                }
359
              }
360
              else {
361
                // this is the all option
362
                if ($page['is_mobile'] === TRUE) {
363
                  unset($page[$region]);
321 364
                }
322

  
323
                // Unset the region, all blocks are now moved
324
                unset($page[$region]);
325 365
              }
366
            }
326 367

  
327
              // Unset unwanted regions in mobile
328
              if (at_get_setting('unset_' . $region) === 1) {
329
                unset($page[$region]);
368
            // MOVE
369
            if (at_get_setting('move_region_' . $region) === 1) {
370
              if (at_get_setting('move_options_' . $region) == 'move_smalltouch') {
371
                if ($page['is_mobile'] === TRUE && $page['is_tablet'] === FALSE) {
372
                  $page = at_move_regions($page, $region, $blocks);
373
                }
374
              }
375
              else {
376
                // this is the all option
377
                if ($page['is_mobile'] === TRUE) {
378
                  $page = at_move_regions($page, $region, $blocks);
379
                }
330 380
              }
331 381
            }
332 382
          }
......
345 395
      }
346 396
    }
347 397
  }
398

  
399
  //kpr($page);
400
}
401

  
402
// Abstrat move regions processing
403
function at_move_regions($page, $region, $blocks) {
404
  // Get the target region if set, check blocks can move and its not set to unset
405
  if (($target_region = at_get_setting('move_' . $region)) && ($target_region !== 'do_not_move') && (at_get_setting('unset_' . $region) !== 1)) {
406

  
407
    // Sanitize possible vector
408
    $target_region = check_plain($target_region);
409

  
410
    // Initialize the classes array
411
    $classes = array();
412

  
413
    // Move each block
414
    foreach ($blocks as $block) {
415

  
416
      // If the $target_region is empty the region markup does not print
417
      // so we need to generate it manually. This is bad because it
418
      // cannot account for region specific template suggestions and
419
      // Adaptivethemes own region prefix and suffix wrappers.
420
      if (empty($page[$target_region])) {
421
        $classes[] = 'region';
422
        $classes[] = 'region-' . str_replace('_', '-', $target_region);
423
        if ($target_region == 'sidebar_first' || $target_region == 'sidebar_second') {
424
          $classes[] = 'sidebar';
425
        }
426
        $classes = implode(' ', $classes);
427
        $page[$target_region]['#prefix'] = '<div class="' .  $classes . '"><div class="region-inner clearfix">';
428
        $page[$target_region]['#suffix'] = '</div></div>';
429
      }
430

  
431
      // Move the blocks to the target region
432
      $page[$target_region][$block] = $page[$region][$block];
433

  
434
      // Unset the original block
435
      unset($page[$region][$block]);
436
    }
437

  
438
    // Unset the region, all blocks are now moved
439
    unset($page[$region]);
440
  }
441

  
442
  return $page;
348 443
}
349 444

  
350 445
/**
......
368 463
  // The problem with Drupals standard Advanced search form is that each
369 464
  // criterion group is wrapped in a DIV, whereas it should be a fieldset with
370 465
  // a legend, this is better semantics and improves accessibility by
371
  // logically grouping field items.
466
  // logically grouping field items. We make this optional via a theme setting,
467
  // beacuse some people bitched that it broke some modules that require
468
  // crappy markup.
372 469
  if (at_get_setting('adv_search_extra_fieldsets') === 1) {
373 470
    if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
374 471
      // Keyword boxes:
......
515 612
}
516 613

  
517 614
/**
518
 * Output for the debug panels test.
615
 * Output for the debug panels test. This is pretty sucky because its
616
 * hard coded and therefor does not include any custom Panels layout
617
 * plugins you might include in a subtheme, bad eh?
519 618
 */
520 619
function at_debug_panels() {
521 620
  $output = <<<EOF

Formats disponibles : Unified diff