advagg_css_compress.admin.inc

  1. cis7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  2. cle7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  3. ecd7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  4. elmsmedia7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  5. harmony7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  6. icor7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  7. meedjum_blog7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
  8. mooc7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc

Admin page callbacks for the advagg JS compression module.

Functions

Namesort descending Description
advagg_css_compress_admin_settings_form Form builder; Configure advagg settings.
advagg_css_compress_admin_settings_form_submit Clear out the advagg cache bin when the save configuration button is pressed.

File

sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Admin page callbacks for the advagg JS compression module.
  5. */
  6. /**
  7. * Form builder; Configure advagg settings.
  8. *
  9. * @ingroup forms
  10. * @see system_settings_form()
  11. */
  12. function advagg_css_compress_admin_settings_form($form, $form_state) {
  13. drupal_set_title(t('AdvAgg: CSS Compression Settings'));
  14. $form = array();
  15. $description = '';
  16. $options = array(
  17. 0 => t('Disabled'),
  18. 2 => t('YUI'),
  19. );
  20. $form['advagg_css_compressor'] = array(
  21. '#type' => 'radios',
  22. '#title' => t('File Compression: Select a Compressor'),
  23. '#default_value' => variable_get('advagg_css_compressor', ADVAGG_CSS_COMPRESSOR),
  24. '#options' => $options,
  25. '#description' => filter_xss($description),
  26. );
  27. $form['advagg_css_inline_compressor'] = array(
  28. '#type' => 'radios',
  29. '#title' => t('Inline Compression: Select a Compressor'),
  30. '#default_value' => variable_get('advagg_css_inline_compressor', ADVAGG_CSS_INLINE_COMPRESSOR),
  31. '#options' => $options,
  32. '#description' => filter_xss($description),
  33. );
  34. $form['advagg_css_inline_compress_if_not_cacheable'] = array(
  35. '#type' => 'checkbox',
  36. '#title' => t('Inline Compression: Use even if this page is not cacheable'),
  37. '#default_value' => variable_get('advagg_css_inline_compress_if_not_cacheable', ADVAGG_CSS_INLINE_COMPRESS_IF_NOT_CACHEABLE),
  38. '#description' => t('By checking this box, all Inline CSS will be compressed regardless of the state of <a href="@link">drupal_page_is_cacheable()</a>.', array('@link' => 'http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_page_is_cacheable/7')),
  39. '#states' => array(
  40. 'disabled' => array(
  41. ':input[name="advagg_css_inline_compressor"]' => array('value' => "0"),
  42. ),
  43. ),
  44. );
  45. $options[-1] = t('Default');
  46. ksort($options);
  47. $form['per_file_settings'] = array(
  48. '#type' => 'fieldset',
  49. '#title' => t('Per File Settings'),
  50. '#collapsible' => TRUE,
  51. '#collapsed' => TRUE,
  52. );
  53. // Get filename & filename_hash.
  54. $results = db_select('advagg_files', 'af')
  55. ->fields('af', array('filename'))
  56. ->condition('filetype', 'css')
  57. ->orderBy('af.filename', 'ASC')
  58. ->execute();
  59. $file_settings = variable_get('advagg_css_compressor_file_settings', array());
  60. foreach ($results as $row) {
  61. $dir = dirname($row->filename);
  62. if (!isset($form['per_file_settings'][$dir])) {
  63. $form['per_file_settings'][$dir] = array(
  64. '#type' => 'fieldset',
  65. '#title' => check_plain($dir),
  66. '#collapsible' => TRUE,
  67. '#collapsed' => TRUE,
  68. );
  69. }
  70. $form_api_filename = str_replace(array('/', '.'), array('__', '--'), $row->filename);
  71. $form['per_file_settings'][$dir]['advagg_css_compressor_file_settings_' . $form_api_filename] = array(
  72. '#type' => 'radios',
  73. '#title' => t('%filename: Select a Compressor', array('%filename' => $row->filename)),
  74. '#default_value' => isset($file_settings[$form_api_filename]) ? $file_settings[$form_api_filename] : ADVAGG_CSS_COMPRESSOR_FILE_SETTINGS,
  75. '#options' => $options,
  76. );
  77. if ($form['per_file_settings'][$dir]['advagg_css_compressor_file_settings_' . $form_api_filename]['#default_value'] != ADVAGG_CSS_COMPRESSOR_FILE_SETTINGS) {
  78. $form['per_file_settings'][$dir]['#collapsed'] = FALSE;
  79. $form['per_file_settings']['#collapsed'] = FALSE;
  80. }
  81. }
  82. // Clear the cache bins on submit.
  83. $form['#submit'][] = 'advagg_css_compress_admin_settings_form_submit';
  84. return system_settings_form($form);
  85. }
  86. // Submit callback.
  87. /**
  88. * Clear out the advagg cache bin when the save configuration button is pressed.
  89. *
  90. * Also remove default settings inside of the per_file_settings fieldgroup.
  91. */
  92. function advagg_css_compress_admin_settings_form_submit($form, &$form_state) {
  93. $cache_bins = advagg_flush_caches();
  94. foreach ($cache_bins as $bin) {
  95. cache_clear_all('*', $bin, TRUE);
  96. }
  97. // Get current defaults.
  98. $file_settings = variable_get('advagg_css_compressor_file_settings', array());
  99. // Save per file settings.
  100. $new_settings = array();
  101. foreach ($form_state['values'] as $key => $value) {
  102. // Skip if not advagg_css_compressor_file_settings
  103. if (strpos($key, 'advagg_css_compressor_file_settings_') === FALSE) {
  104. continue;
  105. }
  106. // Do not process default settings.
  107. if ($value == ADVAGG_CSS_COMPRESSOR_FILE_SETTINGS) {
  108. unset($form_state['values'][$key]);
  109. continue;
  110. }
  111. $new_settings[substr($key, 36)] = $value;
  112. }
  113. if (!empty($new_settings) || !empty($file_settings)) {
  114. if (empty($new_settings)) {
  115. variable_del('advagg_css_compressor_file_settings');
  116. }
  117. else {
  118. variable_set('advagg_css_compressor_file_settings', $new_settings);
  119. }
  120. }
  121. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.