advagg_js_compress.admin.inc

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

Admin page callbacks for the advagg JS compression module.

Functions

Namesort descending Description
advagg_js_compress_admin_settings_form Form builder; Configure advagg settings.
advagg_js_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_js_compress/advagg_js_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_js_compress_admin_settings_form($form, $form_state) {
  13. drupal_set_title(t('AdvAgg: JS Compression'));
  14. $form = array();
  15. $description = '';
  16. $options = array(
  17. 0 => t('Disabled'),
  18. 1 => t('JSMin+'),
  19. // 2 => t('Packer'),
  20. );
  21. if (function_exists('jsmin')) {
  22. $options[3] = t('JSMin');
  23. $description .= t('JSMin is the C complied version and is about 25 times faster. Recommend using it.');
  24. }
  25. else {
  26. if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50310) {
  27. $link = 'http://www.ypass.net/software/php_jsmin/';
  28. }
  29. else {
  30. $link = 'https://github.com/sqmk/pecl-jsmin/';
  31. }
  32. $description .= t('You can use the much faster C version of JSMin by installing the <a href="@php_jsmin">JSMin PHP Extension</a> on this server.', array('@php_jsmin' => $link));
  33. }
  34. $form['advagg_js_compressor'] = array(
  35. '#type' => 'radios',
  36. '#title' => t('File Compression: Select a Compressor'),
  37. '#default_value' => variable_get('advagg_js_compressor', ADVAGG_JS_COMPRESSOR),
  38. '#options' => $options,
  39. '#description' => filter_xss($description),
  40. );
  41. $form['advagg_js_inline_compressor'] = array(
  42. '#type' => 'radios',
  43. '#title' => t('Inline Compression: Select a Compressor'),
  44. '#default_value' => variable_get('advagg_js_inline_compressor', ADVAGG_JS_INLINE_COMPRESSOR),
  45. '#options' => $options,
  46. '#description' => filter_xss($description),
  47. );
  48. $form['advagg_js_inline_compress_if_not_cacheable'] = array(
  49. '#type' => 'checkbox',
  50. '#title' => t('Inline Compression: Use even if this page is not cacheable'),
  51. '#default_value' => variable_get('advagg_js_inline_compress_if_not_cacheable', ADVAGG_JS_INLINE_COMPRESS_IF_NOT_CACHEABLE),
  52. '#description' => t('By checking this box, all Inline JavaScript will be compressed regardless of the state of <a href="@link">drupal_page_is_cacheable()</a>. If the C complied version of JSMin is enabled, this option should not slow down page generation that much; if you are using JSMin+ I recommend keeping this disabled.', array('@link' => 'http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_page_is_cacheable/7')),
  53. '#states' => array(
  54. 'disabled' => array(
  55. ':input[name="advagg_js_inline_compressor"]' => array('value' => "0"),
  56. ),
  57. ),
  58. );
  59. $form['advagg_js_compress_packer'] = array(
  60. '#type' => 'checkbox',
  61. '#title' => t('Use Packer on non GZip JS Aggregates'),
  62. '#default_value' => variable_get('advagg_js_compress_packer', ADVAGG_JS_COMPRESS_PACKER),
  63. '#description' => t('If enabled the non gzip version of JS files will be compressed using the JS Packer. Packer works similar to gzip, thus using packer on a gzipped file does not give a big improvement in terms of bytes transfered over the wire. WARNING: This has a high chance of breaking your JS. Only Enable on production after testing the non gzipped version locally.'),
  64. '#states' => array(
  65. 'disabled' => array(
  66. ':input[name="advagg_js_compressor"]' => array('value' => "0"),
  67. ),
  68. ),
  69. );
  70. $options[-1] = t('Default');
  71. ksort($options);
  72. $form['per_file_settings'] = array(
  73. '#type' => 'fieldset',
  74. '#title' => t('Per File Settings'),
  75. '#collapsible' => TRUE,
  76. '#collapsed' => TRUE,
  77. );
  78. // Get filename & filename_hash.
  79. $results = db_select('advagg_files', 'af')
  80. ->fields('af', array('filename'))
  81. ->condition('filetype', 'js')
  82. ->orderBy('af.filename', 'ASC')
  83. ->execute();
  84. $file_settings = variable_get('advagg_js_compressor_file_settings', array());
  85. foreach ($results as $row) {
  86. $dir = dirname($row->filename);
  87. if (!isset($form['per_file_settings'][$dir])) {
  88. $form['per_file_settings'][$dir] = array(
  89. '#type' => 'fieldset',
  90. '#title' => check_plain($dir),
  91. '#collapsible' => TRUE,
  92. '#collapsed' => TRUE,
  93. );
  94. }
  95. $form_api_filename = str_replace(array('/', '.'), array('__', '--'), $row->filename);
  96. $form['per_file_settings'][$dir]['advagg_js_compressor_file_settings_' . $form_api_filename] = array(
  97. '#type' => 'radios',
  98. '#title' => t('%filename: Select a Compressor', array('%filename' => $row->filename)),
  99. '#default_value' => isset($file_settings[$form_api_filename]) ? $file_settings[$form_api_filename] : ADVAGG_JS_COMPRESSOR_FILE_SETTINGS,
  100. '#options' => $options,
  101. );
  102. if ($form['per_file_settings'][$dir]['advagg_js_compressor_file_settings_' . $form_api_filename]['#default_value'] != ADVAGG_JS_COMPRESSOR_FILE_SETTINGS) {
  103. $form['per_file_settings'][$dir]['#collapsed'] = FALSE;
  104. $form['per_file_settings']['#collapsed'] = FALSE;
  105. }
  106. }
  107. // Clear the cache bins on submit.
  108. $form['#submit'][] = 'advagg_js_compress_admin_settings_form_submit';
  109. return system_settings_form($form);
  110. }
  111. // Submit callback.
  112. /**
  113. * Clear out the advagg cache bin when the save configuration button is pressed.
  114. *
  115. * Also remove default settings inside of the per_file_settings fieldgroup.
  116. */
  117. function advagg_js_compress_admin_settings_form_submit($form, &$form_state) {
  118. $cache_bins = advagg_flush_caches();
  119. foreach ($cache_bins as $bin) {
  120. cache_clear_all('*', $bin, TRUE);
  121. }
  122. // Get current defaults.
  123. $file_settings = variable_get('advagg_js_compressor_file_settings', array());
  124. // Save per file settings.
  125. $new_settings = array();
  126. foreach ($form_state['values'] as $key => $value) {
  127. // Skip if not advagg_js_compressor_file_settings
  128. if (strpos($key, 'advagg_js_compressor_file_settings_') === FALSE) {
  129. continue;
  130. }
  131. // Do not process default settings.
  132. if ($value == ADVAGG_JS_COMPRESSOR_FILE_SETTINGS) {
  133. unset($form_state['values'][$key]);
  134. continue;
  135. }
  136. $new_settings[substr($key, 35)] = $value;
  137. }
  138. if (!empty($new_settings) || !empty($file_settings)) {
  139. if (empty($new_settings)) {
  140. variable_del('advagg_js_compressor_file_settings');
  141. }
  142. else {
  143. variable_set('advagg_js_compressor_file_settings', $new_settings);
  144. }
  145. }
  146. }
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.