function cpn_save_file in Code per Node 7
Same name and namespace in other branches
- 6 cpn.module \cpn_save_file()
Saves CSS & JavaScript in the file system (but only if not empty).
4 calls to cpn_save_file()
- cpn_block_submit in ./
cpn.module - Block submit callback.
- cpn_node_insert in ./
cpn.module - Implements hook_node_insert().
- cpn_node_type_submit in ./
cpn.module - Node type submit callback.
- cpn_settings_submit in ./
cpn.admin.inc - Settings form - submit callback.
File
- ./
cpn.module, line 749 - Primary hook implementations.
Code
function cpn_save_file($data, $filename) {
if (!drupal_strlen(trim($data))) {
return FALSE;
}
$path = variable_get('cpn_path', 'public://cpn');
$full_path = $path . '/' . $filename;
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
$file_saved = file_unmanaged_save_data($data, $full_path, FILE_EXISTS_REPLACE);
// Integration with some other modules.
if ($file_saved) {
// AdvAgg - reload all the things.
if (module_exists('advagg')) {
module_load_include('inc', 'advagg', 'advagg.cache');
advagg_push_new_changes();
}
// Varnish - flush this one file.
if (module_exists('varnish')) {
varnish_expire_cache(array(
$full_path,
));
}
}
return $file_saved;
}