advagg_css_compress.module

  1. nittany7 modules/contrib/advagg/advagg_css_compress/advagg_css_compress.module
  2. cis7 modules/contrib/advagg/advagg_css_compress/advagg_css_compress.module
  3. mooc7 modules/contrib/advagg/advagg_css_compress/advagg_css_compress.module

Advanced aggregation css compression module.

Functions

Constants

Namesort descending Description
ADVAGG_CSS_COMPRESSOR Default value for which css compression library to use. 0 is Disabled.
ADVAGG_CSS_INLINE_COMPRESSOR Default value to see what compressor to use. 0 is Disabled.
ADVAGG_CSS_INLINE_COMPRESS_IF_NOT_CACHEABLE Default value to if inline compression is used if page is not cacheable.

File

modules/contrib/advagg/advagg_css_compress/advagg_css_compress.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Advanced aggregation css compression module.
  5. *
  6. */
  7. /**
  8. * Default value for which css compression library to use. 0 is Disabled.
  9. */
  10. define('ADVAGG_CSS_COMPRESSOR', 2);
  11. /**
  12. * Default value to see what compressor to use. 0 is Disabled.
  13. */
  14. define('ADVAGG_CSS_INLINE_COMPRESSOR', 0);
  15. /**
  16. * Default value to if inline compression is used if page is not cacheable.
  17. */
  18. define('ADVAGG_CSS_INLINE_COMPRESS_IF_NOT_CACHEABLE', FALSE);
  19. /**
  20. * Implementation of hook_menu
  21. */
  22. function advagg_css_compress_menu() {
  23. $items = array();
  24. $file_path = drupal_get_path('module', 'advagg_css_compress');
  25. $config_path = advagg_admin_config_root_path();
  26. $items[$config_path . '/advagg/css-compress'] = array(
  27. 'title' => 'CSS Compression',
  28. 'description' => 'Adjust CSS Compression settings.',
  29. 'page callback' => 'drupal_get_form',
  30. 'page arguments' => array('advagg_css_compress_admin_settings_form'),
  31. 'type' => MENU_LOCAL_TASK,
  32. 'access arguments' => array('administer site configuration'),
  33. 'file path' => $file_path,
  34. 'file' => 'advagg_css_compress.admin.inc',
  35. 'weight' => 10,
  36. );
  37. return $items;
  38. }
  39. /**
  40. * Implement hook_advagg_current_hooks_hash_array_alter.
  41. */
  42. function advagg_css_compress_advagg_current_hooks_hash_array_alter(&$aggregate_settings) {
  43. $aggregate_settings['variables']['advagg_css_compressor'] = variable_get('advagg_css_compressor', ADVAGG_CSS_COMPRESSOR);
  44. }
  45. /**
  46. * Implement hook_advagg_modify_css_pre_render_alter().
  47. *
  48. * Used to compress inline css.
  49. */
  50. function advagg_css_compress_advagg_modify_css_pre_render_alter(&$children, &$elements) {
  51. // Get variables.
  52. $compressor = variable_get('advagg_css_inline_compressor', ADVAGG_CSS_INLINE_COMPRESSOR);
  53. // Do nothing if the compressor is disabled.
  54. if (empty($compressor)) {
  55. return;
  56. }
  57. // Do nothing if the page is not cacheable and inline compress if not
  58. // cacheable is not checked.
  59. if (!variable_get('advagg_css_inline_compress_if_not_cacheable', ADVAGG_CSS_INLINE_COMPRESS_IF_NOT_CACHEABLE) && !drupal_page_is_cacheable()) {
  60. return;
  61. }
  62. module_load_include('inc', 'advagg_css_compress', 'advagg_css_compress.advagg');
  63. if ($compressor == 2) {
  64. // Compress any inline CSS with YUI.
  65. foreach ($children as $key => &$values) {
  66. if (!empty($values['#value'])) {
  67. advagg_css_compress_yui_cssmin($values['#value']);
  68. }
  69. }
  70. }
  71. }