Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Generate form elments for the File Management settings.
6
 */
7
function at_core_filemanagement_form(&$form, $theme_name) {
8
  $file_settings_path = url('admin/config/media/file-system');
9
  $public_files = variable_get('file_public_path', conf_path() . '/files') . '/adaptivetheme/' . $theme_name . '_files/';
10
  $theme_directory = drupal_get_path('theme', $theme_name) . '/generated_files/';
11
  $css_mode = variable_get('preprocess_css', '') == 1 ? TRUE : FALSE;
12
  $js_mode = variable_get('preprocess_js', '') == 1 ? TRUE : FALSE;
13

    
14
  // File Management
15
  $form['at-settings']['file-management'] = array(
16
    '#type' => 'fieldset',
17
    '#title' => t('File Management'),
18
    '#description' => t('<h3>File Management Settings</h3><p>Set the path to generated files and configure CSS and JS aggregation optimizations. Please read the help descriptions carefully. </p>'),
19
  );
20

    
21
  // Path to generated files
22
  $form['at-settings']['file-management']['files-path'] = array(
23
    '#type' => 'fieldset',
24
    '#title' => t('Path to Generated Files'),
25
    '#description' => t('<h3>Path to Generated Files</h3>'),
26
  );
27
  $form['at-settings']['file-management']['files-path']['global_files_path'] = array(
28
    '#type' => 'select',
29
    '#title' => t('By default the generated files are saved in <a href="!file_settings_path" target="_blank">public files</a>. You can change this to your theme directory or a custom directory. These files include all the generated CSS files, the info file backup and color scheme backups if you are using the Color module. For more information see the docs on the <a href="!file_generation_system" target="_blank">file generation system</a>.', array('!file_settings_path' => $file_settings_path, '!file_generation_system' => 'http://adaptivethemes.com/documentation/file-generation-system')),
30
    '#default_value' => at_get_setting('global_files_path'),
31
    '#options' => array(
32
      'public_files' => t('Public files'),
33
      'theme_directory' => t('Theme directory'),
34
      'custom_path' => t('Custom path'),
35
    ),
36
  );
37
  // Message for public files
38
  $form['at-settings']['file-management']['files-path']['public_files_path'] = array(
39
    '#type' => 'fieldset',
40
    '#states' => array(
41
      'visible' => array('select[name="global_files_path"]' => array('value' => 'public_files')),
42
    ),
43
  );
44
  $form['at-settings']['file-management']['files-path']['public_files_path']['message'] = array(
45
    '#markup' => t('<div class="description">Files will be saved to: <code>@public_files</code></div>', array('@public_files' => $public_files)),
46
  );
47
  // message for theme dir
48
  $form['at-settings']['file-management']['files-path']['theme_directory_files_path'] = array(
49
    '#type' => 'fieldset',
50
    '#states' => array(
51
      'visible' => array('select[name="global_files_path"]' => array('value' => 'theme_directory')),
52
    ),
53
  );
54
  $form['at-settings']['file-management']['files-path']['theme_directory_files_path']['message'] = array(
55
    '#markup' => t('<div class="description">Files will be saved to: <code>@theme_directory</code></div>', array('@theme_directory' => $theme_directory)),
56
  );
57
  // Text field for custom path
58
  $form['at-settings']['file-management']['files-path']['custom_files_path'] = array(
59
    '#type' => 'textfield',
60
    '#title' => t('Enter the custom path:'),
61
    '#default_value' => at_get_setting('custom_files_path'),
62
    '#description' => t('This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web. Do not try to use something like <code>../css</code>, it will fail. Use someting like <code>sites/default/css</code>.'),
63
    '#states' => array(
64
      'visible' => array('select[name="global_files_path"]' => array('value' => 'custom_path')),
65
    ),
66
  );
67

    
68
  // Aggregation overrides, see http://drupal.org/node/1115026
69
  if ($css_mode == FALSE) {
70
    $css_mode_message = t('CSS aggregation is OFF. This settings will have no effect until CSS aggregation is turned ON.');
71
  }
72
  else {
73
    $css_mode_message = t('CSS aggregation is ON. This settings will take effect.');
74
  }
75
  if ($js_mode == FALSE) {
76
    $js_mode_message = t('JavaScript aggregation is OFF. This settings will have no effect until JavaScript aggregation is turned ON.');
77
  }
78
  else {
79
    $js_mode_message = t('JavaScript aggregation is ON. This settings will take effect.');
80
  }
81
  $form['at-settings']['file-management']['aggregation-overrides'] = array(
82
    '#type' => 'fieldset',
83
    '#title' => t('Combine Aggregated Files'),
84
    '#description' => t('<h3>Combine Aggregated Files <sup>(beta)</sup></h3><p>When CSS aggregation is on Drupal aggregates CSS and JS files by group. These settings will override this and create one CSS stylesheet per type and only one JavaScript file. This reduces HTTP requests and improves site performance. Note: this is beta and while well tested you should check your site carefully, both the style and behavior.</p><p>Warning: Internet Explorer cannot handle more than 4095 selectors in one stylesheet - combining CSS files using this setting could result in more than 4095 selectors. If you see probems such as no style in IE then turn this off.</p>'),
85
  );
86
  // Combine CSS
87
  $form['at-settings']['file-management']['aggregation-overrides']['combine_css_files'] = array(
88
    '#type' => 'checkbox',
89
    '#title'  => t('Combine CSS Files'),
90
    '#description' => t('<p>In AT you will normally get three media type CSS files after this is enabled and CSS aggregation is turned on - all, screen and only screen. If you are using a print stylesheet this will be seperate also. Browser specific stylesheets for Internet Explorer are ignored.</p><p>!css_mode_message</p>', array('!css_mode_message' => $css_mode_message)),
91
    '#default_value' => at_get_setting('combine_css_files'),
92
  );
93
  // Combine JS
94
  $form['at-settings']['file-management']['aggregation-overrides']['combine_js_files'] = array(
95
    '#type' => 'checkbox',
96
    '#title'  => t('Combine JS Files'),
97
    '#description' => t('<p>This will force all aggregated JavaScript files into one file.</p><p>!js_mode_message</p>', array('!js_mode_message' => $js_mode_message)),
98
    '#default_value' => at_get_setting('combine_js_files'),
99
  );
100
}