You are here

function advagg_css_compress_requirements in Advanced CSS/JS Aggregation 7.2

Same name and namespace in other branches
  1. 6 advagg_css_compress/advagg_css_compress.install \advagg_css_compress_requirements()
  2. 7 advagg_css_compress/advagg_css_compress.install \advagg_css_compress_requirements()

Implements hook_requirements().

File

advagg_css_compress/advagg_css_compress.install, line 16
Handles AdvAgg CSS compress installation and upgrade tasks.

Code

function advagg_css_compress_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();

  // If not at runtime, return here.
  if ($phase !== 'runtime') {
    return $requirements;
  }

  // Make sure a compressor is being used.
  if (variable_get('advagg_css_compressor', ADVAGG_CSS_COMPRESSOR) == 0 && variable_get('advagg_css_compress_inline', ADVAGG_CSS_COMPRESS_INLINE) == 0) {

    // Check all files.
    $file_settings = variable_get('advagg_css_compressor_file_settings', array());
    $compression_used = FALSE;
    foreach ($file_settings as $setting) {
      if (!empty($setting)) {
        $compression_used = TRUE;
        break;
      }
    }
    if (!$compression_used) {
      $config_path = advagg_admin_config_root_path();
      $requirements['advagg_css_compress_not_on'] = array(
        'title' => $t('AdvAgg CSS Compressor'),
        'severity' => REQUIREMENT_WARNING,
        'value' => $t('AdvAgg CSS Compression is disabled.'),
        'description' => $t('Go to the <a href="@settings">advagg css compress settings page</a> and select a compressor, or go to the <a href="@modules">modules page</a> and disable the "AdvAgg Compress CSS" module.', array(
          '@settings' => url($config_path . '/advagg/css-compress'),
          '@modules' => url('admin/modules', array(
            'fragment' => 'edit-modules-advanced-cssjs-aggregation',
          )),
        )),
      );
    }
  }

  // Check version.
  $lib_name = 'YUI-CSS-compressor-PHP-port';
  $module_name = 'advagg_css_compress';
  list($description, $info) = advagg_get_version_description($lib_name, $module_name);
  if (!empty($description)) {
    $requirements["{$module_name}_{$lib_name}_updates"] = array(
      'title' => $t('@module_name', array(
        '@module_name' => $info['name'],
      )),
      'severity' => REQUIREMENT_WARNING,
      'value' => $t('The @name library needs to be updated.', array(
        '@name' => $lib_name,
      )),
      'description' => $description,
    );
  }
  return $requirements;
}