Projet

Général

Profil

Paste
Télécharger (3,09 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / inc / forms / settings.headings.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Generate form elments for the Headings Styles settings.
6
 */
7
function at_core_headings_form(&$form) {
8
  // Title styles
9
  $form['at']['titles'] = array(
10
    '#type' => 'fieldset',
11
    '#title' => t('Title Styles'),
12
    '#description' => t('<h3>Title Styles</h3><p>Add extra styles to headings. Text shadows only work for CSS3 capable browsers such as Firefox, Safari, IE9 etc.</p>'),
13
    '#weight' => -100,
14
  );
15

    
16
  // Array of valid title types
17
  $headings_valid_types = array(
18
    'site_name',
19
    'site_slogan',
20
    'page_title',
21
    'node_title',
22
    'block_title',
23
    'comment_title',
24
  );
25

    
26
  // Get the fonts list
27
  $form_elements = font_elements();
28

    
29
  foreach ($form_elements as $key => $value) {
30

    
31
    $heading = $key;
32

    
33
    if (in_array($heading, $headings_valid_types)) {
34

    
35
      $element = $value['element'];  // e.g. "ptf" (page_title_font), this is used to set array keys and eventually body classes
36
      $setting = $heading; // use the key for these settings, it doesnt have "font" in it
37
      $container = $value['setting'];  // the theme setting used to retrieve the font values, e.g. "site_name_font"
38

    
39
      $setting_container = str_replace('_', '-', $container) . '-style'; // a nicer string for fielset classes
40
      $title = str_replace('_', ' ', drupal_ucfirst($heading)); // use the key for titles, it doesnt have "font" in it
41

    
42
      // Set easy reusable variables
43
      $setting_case       = $setting . '_case';
44
      $setting_weight     = $setting . '_weight';
45
      $setting_alignment  = $setting . '_alignment';
46
      $setting_shadow     = $setting . '_shadow';
47

    
48
      // Fieldset wrapper for each title
49
      $form['at']['titles']['' . $setting_container . '']  = array(
50
        '#type' => 'fieldset',
51
        '#title' => t($title),
52
        '#description' => t("<strong>$title</strong>"),
53
        '#attributes' => array('class' => array('headings-styles-wrapper')),
54
      );
55

    
56
      // Case
57
      $form['at']['titles']['' . $setting_container . '']['' . $setting_case . ''] = array(
58
        '#type' => 'select',
59
        '#title' => t('Case'),
60
        '#default_value' => at_get_setting($setting_case),
61
        '#options' => font_style_options('case', $element),
62
      );
63

    
64
      // Weight
65
      $form['at']['titles']['' . $setting_container . '']['' . $setting_weight . ''] = array(
66
        '#type' => 'select',
67
        '#title' => t('Weight'),
68
        '#default_value' => at_get_setting($setting_weight),
69
        '#options' => font_style_options('weight', $element),
70
      );
71

    
72
      // Alignment
73
      $form['at']['titles']['' . $setting_container . '']['' . $setting_alignment . ''] = array(
74
        '#type' => 'select',
75
        '#title' => t('Alignment'),
76
        '#default_value' => at_get_setting($setting_alignment),
77
        '#options' => font_style_options('alignment', $element),
78
      );
79

    
80
      // Text shadow
81
      $form['at']['titles']['' . $setting_container . '']['' . $setting_shadow . ''] = array(
82
        '#type' => 'select',
83
        '#title' => t('Shadow'),
84
        '#default_value' => at_get_setting($setting_shadow),
85
        '#options' => font_style_options('shadow', $element),
86
      );
87
    }
88
  }
89
}