View source
<?php
function css_gzip_install() {
$htaccess = file_directory_path() . '/css/.htaccess';
if (!file_exists($htaccess)) {
$csspath = file_create_path('css');
file_check_directory($csspath, FILE_CREATE_DIRECTORY);
file_save_data('', $htaccess, FILE_EXISTS_REPLACE);
}
}
function css_gzip_uninstall() {
$htaccess = file_directory_path() . '/css/.htaccess';
if (file_exists($htaccess)) {
file_delete($htaccess);
}
db_query("DELETE FROM {variable} WHERE name LIKE '%s_%%'", 'css_gzip');
cache_clear_all('variables', 'cache');
}
function css_gzip_disable() {
$htaccess = file_directory_path() . '/css/.htaccess';
if (file_exists($htaccess)) {
file_delete($htaccess);
}
}
function css_gzip_requirements($phase) {
$requirements = array();
$t = get_t();
$directory = file_directory_path();
$is_writable = is_dir($directory) && is_writable($directory) && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC;
switch ($phase) {
case 'runtime':
if (!$is_writable) {
$requirements['css_gzip'] = array(
'title' => $t('CSS Gzip'),
'description' => $t('Files directory is not writable AND/OR public download method is disabled'),
'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
'value' => $t('Server Configuration Error'),
);
}
else {
$requirements['css_gzip'] = array(
'title' => $t('CSS Gzip'),
'severity' => REQUIREMENT_OK,
'value' => $t('Files directory is writable and server is using public downloads'),
);
}
break;
}
return $requirements;
}
function css_gzip_update_6100() {
$ret = array();
$ret[] = update_sql("UPDATE {variable} SET name = 'css_gzip_htaccess_size' WHERE name = 'css_aggregator_gzip_htaccess_size'");
$ret[] = update_sql("UPDATE {variable} SET name = 'css_gzip' WHERE name = 'css_aggregator_gzip'");
$ret[] = update_sql("UPDATE {variable} SET name = 'css_gzip_no_htaccess' WHERE name = 'css_aggregator_gzip_no_htaccess'");
return $ret;
}