advagg_css_compress.module

  1. cis7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  2. cle7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  3. ecd7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  4. elmsmedia7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  5. harmony7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  6. icor7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  7. meedjum_blog7 sites/all/modules/ulmus/advagg/advagg_css_compress/advagg_css_compress.module
  8. mooc7 sites/all/modules/ulmus/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_COMPRESSOR_FILE_SETTINGS Default value for per file compression settings.
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

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