Same filename in other branches
Handles AdvAgg CSS compress installation and upgrade tasks.
Fichier
-
advagg_css_compress/
advagg_css_compress.install
View source
<?php
/**
* @file
* Handles AdvAgg CSS compress installation and upgrade tasks.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Implements hook_requirements().
*/
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;
}
/**
* Upgrade AdvAgg CSS Compress versions (6.x-1.x and 7.x-1.x) to 7.x-2.x.
*/
function advagg_css_compress_update_7200(&$sandbox) {
// Bail if old DB Table does not exist.
if (!db_table_exists('cache_advagg_css_compress_inline')) {
return t('Nothing needed to happen in AdvAgg CSS Compress.');
}
// Remove all old advagg css compress variables.
db_delete('variable')->condition('name', 'advagg_css%compress%', 'LIKE')
->execute();
// Remove old schema.
db_drop_table('cache_advagg_css_compress_inline');
return t('Upgraded AdvAgg CSS Compress to 7.x-2.x.');
}
/**
* Change variable names so they are prefixed with the modules name.
*/
function advagg_css_compress_update_7201(&$sandbox) {
// Rename advagg_css_inline_compressor to advagg_css_compress_inline.
$old = variable_get('advagg_css_inline_compressor', NULL);
if (!is_null($old)) {
variable_del('advagg_css_inline_compressor');
}
if ($old !== ADVAGG_CSS_COMPRESS_INLINE) {
variable_set('advagg_css_compress_inline', $old);
}
// Rename advagg_css_inline_compress_if_not_cacheable to
// advagg_css_compress_inline_if_not_cacheable.
$old = variable_get('advagg_css_inline_compress_if_not_cacheable', NULL);
if (!is_null($old)) {
variable_del('advagg_css_inline_compress_if_not_cacheable');
}
if ($old !== ADVAGG_CSS_COMPRESS_INLINE_IF_NOT_CACHEABLE) {
variable_set('advagg_css_compress_inline_if_not_cacheable', $old);
}
}
/**
* Remove unused variables from the variable table.
*/
function advagg_css_compress_update_7202(&$sandbox) {
// Remove all old advagg css compress variables.
db_delete('variable')->condition('name', 'advagg_css_compressor_file_settings_%', 'LIKE')
->execute();
}
/**
* @} End of "addtogroup hooks".
*/
Functions
Titre | Deprecated | Résumé |
---|---|---|
advagg_css_compress_requirements | Implements hook_requirements(). | |
advagg_css_compress_update_7200 | Upgrade AdvAgg CSS Compress versions (6.x-1.x and 7.x-1.x) to 7.x-2.x. | |
advagg_css_compress_update_7201 | Change variable names so they are prefixed with the modules name. | |
advagg_css_compress_update_7202 | Remove unused variables from the variable table. |