Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Generate settings for the CSS exclude form.
6
 */
7
function at_core_css_exclude_form(&$form, $theme_name) {
8
  // We need some getters.
9
  include_once(drupal_get_path('theme', 'adaptivetheme') . '/inc/get.inc');
10

    
11
  // Get the relevent CSS file data for building the form.
12
  $css_data = at_get_css_files($theme_name);
13

    
14
  // regex pattern
15
  $pattern = '/[^a-zA-Z0-9-]+/';
16

    
17
  // -- DIE CSS DIE -- //
18
  $form['at']['cssexcludes'] = array(
19
    '#type' => 'fieldset',
20
    '#title' => t('Unset CSS'),
21
    '#weight' => 20,
22
  );
23
  $form['at']['cssexcludes']['die-css-die'] = array(
24
    '#type' => 'fieldset',
25
    '#title' => t('Unset CSS'),
26
    '#description' => t('<h2>Unset CSS</h2><p>Stylesheet names are cached, if some are not showing in this list you may need to clear the cache.</p><p>In for some reason (it happens) the CSS files you want to unset never show here you can explicitly declare them in your info file as "unset_css", see your sub-themes info file under "Stylesheets" for instructions.</p>'),
27
    '#attached' => array(
28
      'js' => array(drupal_get_path('theme', 'adaptivetheme') . '/scripts/check-all.js'),
29
    ),
30
  );
31

    
32
  // Core
33
  $core_defined = FALSE;
34
  $form['at']['cssexcludes']['die-css-die']['core-excludes'] = array(
35
    '#type' => 'fieldset',
36
    '#title' => t('Unset Core CSS'),
37
    '#description' => t('<h3>Unset Core Module CSS</h3>'),
38
  );
39
  foreach ($css_data as $key => $value) {
40
    if ($value['type'] == 'unset_core') {
41
      $core_defined = TRUE;
42
      $setting = 'unset_css_' . preg_replace($pattern, '_', $key);
43
      $title_parts = explode('/', $key);
44
      $title = array_pop($title_parts);
45
      $form['at']['cssexcludes']['die-css-die']['core-excludes'][$setting] = array(
46
        '#type' => 'checkbox',
47
        '#title' => t('<b>@title</b> <small>(@key)</small>', array('@title' => $title, '@key' => $key)),
48
        '#default_value' => at_get_setting($setting) ? at_get_setting($setting) : 0,
49
        '#attributes' => array('class' => array('drupal-core-css-file')),
50
        '#weight' => 0,
51
      );
52
    }
53
  }
54
  if ($core_defined === TRUE) {
55
    $form['at']['cssexcludes']['die-css-die']['core-excludes']['core_check_all'] = array(
56
      '#type' => 'checkbox',
57
      '#title' => t('<strong>Unset All</strong>'),
58
      '#default_value' => at_get_setting('core_check_all') ? at_get_setting('core_check_all') : 0,
59
      '#weight' => -1,
60
    );
61
  }
62
  if ($core_defined === FALSE) {
63
    $form['at']['cssexcludes']['die-css-die']['libraries-excludes']['nothing_core_defined'] = array(
64
      '#markup' => t('No core stylesheets to unset? Hmmm, something is not right here, try clearning the sites cache, otherwise you might need to <a href="!link" target="_blank">post an issue</a>.', array('!link' => 'http://drupal.org/project/issues/adaptivetheme')),
65
    );
66
  }
67

    
68
  // Contrib
69
  $contrib_defined = FALSE;
70
  $form['at']['cssexcludes']['die-css-die']['contrib-excludes'] = array(
71
    '#type' => 'fieldset',
72
    '#title' => t('Unset Contrib Module CSS'),
73
    '#description' => t('<h3>Unset Contrib Module CSS</h3>'),
74
  );
75
  foreach ($css_data as $key => $value) {
76
    if ($value['type'] == 'contrib') {
77
      $contrib_defined = TRUE;
78
      $setting = 'unset_css_' . preg_replace($pattern, '_', $key);
79
      $title_parts = explode('/', $key);
80
      $title = array_pop($title_parts);
81
      $form['at']['cssexcludes']['die-css-die']['contrib-excludes'][$setting] = array(
82
        '#type' => 'checkbox',
83
        '#title' => t('<b>@title</b> <small>(@key)</small>', array('@title' => $title, '@key' => $key)),
84
        '#default_value' => at_get_setting($setting) ? at_get_setting($setting) : 0,
85
        '#attributes' => array('class' => array('contrib-module-css-file')),
86
        '#weight' => 0,
87
      );
88
    }
89
  }
90
  if ($contrib_defined === TRUE) {
91
    $form['at']['cssexcludes']['die-css-die']['contrib-excludes']['contrib_check_all'] = array(
92
      '#type' => 'checkbox',
93
      '#title' => t('<strong>Unset All</strong>'),
94
      '#default_value' => at_get_setting('contrib_check_all') ? at_get_setting('contrib_check_all') : 0,
95
      '#weight' => -1,
96
    );
97
  }
98
  if ($contrib_defined === FALSE) {
99
    $form['at']['cssexcludes']['die-css-die']['libraries-excludes']['nothing_contrib_defined'] = array(
100
      '#markup' => t('No contrib module stylesheets to unset. If you think there should be, try clearing the sites cache. If they still do not show you may need to explicitly declare them in your sub-theme info file.'),
101
    );
102
  }
103

    
104
  // Libs
105
  $libraries_defined = FALSE;
106
  $form['at']['cssexcludes']['die-css-die']['libraries-excludes'] = array(
107
    '#type' => 'fieldset',
108
    '#title' => t('Unset Libraries CSS'),
109
    '#description' => t('<h3>Unset Libraries CSS</h3>'),
110
  );
111
  foreach ($css_data as $key => $value) {
112
    if ($value['type'] == 'library') {
113
      $libraries_defined = TRUE;
114
      $setting = 'unset_css_' . preg_replace($pattern, '_', $key);
115
      $title_parts = explode('/', $key);
116
      $title = array_pop($title_parts);
117
      $form['at']['cssexcludes']['die-css-die']['libraries-excludes'][$setting] = array(
118
        '#type' => 'checkbox',
119
        '#title' => t('<b>@title</b> <small>(@key)</small>', array('@title' => $title, '@key' => $key)),
120
        '#default_value' => at_get_setting($setting) ? at_get_setting($setting) : 0,
121
        '#attributes' => array('class' => array('library-css-file')),
122
        '#weight' => 0,
123
      );
124
    }
125
  }
126
  if ($libraries_defined === TRUE) {
127
    $form['at']['cssexcludes']['die-css-die']['libraries-excludes']['libraries_check_all'] = array(
128
      '#type' => 'checkbox',
129
      '#title' => t('<strong>Unset All</strong>'),
130
      '#default_value' => at_get_setting('libraries_check_all') ? at_get_setting('libraries_check_all') : 0,
131
      '#weight' => -1,
132
    );
133
  }
134
  if ($libraries_defined === FALSE) {
135
    $form['at']['cssexcludes']['die-css-die']['libraries-excludes']['nothing_libraries_defined'] = array(
136
      '#markup' => t('No libraries stylesheets to unset. If you think there should be, try clearing the sites cache. If they still do not show you may need to explicitly declare them in your sub-theme info file.'),
137
    );
138
  }
139

    
140
  // Explicit (user defined in their sub-themes info file)
141
  $user_defined = FALSE;
142
  $form['at']['cssexcludes']['die-css-die']['explicit-excludes'] = array(
143
    '#type' => 'fieldset',
144
    '#title' => t('My Unset CSS Files'),
145
    '#description' => t('<h3>My Unset CSS Files</h3>'),
146
  );
147
  foreach ($css_data as $key => $value) {
148
    if ($value['type'] == 'user_defined') {
149
      $user_defined = TRUE;
150
      $setting = 'unset_css_' . preg_replace($pattern, '_', $key);
151
      $title_parts = explode('/', $key);
152
      $title = array_pop($title_parts);
153
      $form['at']['cssexcludes']['die-css-die']['explicit-excludes'][$setting] = array(
154
        '#type' => 'checkbox',
155
        '#title' => t('<b>@title</b> <small>(@key)</small>', array('@title' => $title, '@key' => $key)),
156
        '#default_value' => at_get_setting($setting) ? at_get_setting($setting) : 0,
157
        '#attributes' => array('class' => array('user-defined-css-file')),
158
        '#weight' => 0,
159
      );
160
    }
161
  }
162
  if ($user_defined === TRUE) {
163
    $form['at']['cssexcludes']['die-css-die']['explicit-excludes']['explicit_check_all'] = array(
164
      '#type' => 'checkbox',
165
      '#title' => t('<strong>Unset All</strong>'),
166
      '#default_value' => at_get_setting('explicit_check_all') ? at_get_setting('explicit_check_all') : 0,
167
      '#weight' => -1,
168
    );
169
  }
170
  if ($user_defined === FALSE) {
171
    $form['at']['cssexcludes']['die-css-die']['explicit-excludes']['nothing_user_defined'] = array(
172
      '#markup' => t('No user defined stylesheets to unset. If you wish to define your own, see your sub-theme info file for details under the "Stylesheets" section.'),
173
    );
174
  }
175
}