public function sweaver_plugin_styles::sweaver_export_file in Sweaver 7
Same name and namespace in other branches
- 6 plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc \sweaver_plugin_styles::sweaver_export_file()
Export css to file.
1 call to sweaver_plugin_styles::sweaver_export_file()
- sweaver_plugin_styles::sweaver_form_submit in plugins/
sweaver_plugin_styles/ sweaver_plugin_styles.inc - Frontend form submit.
File
- plugins/
sweaver_plugin_styles/ sweaver_plugin_styles.inc, line 453 - Styles plugin.
Class
Code
public function sweaver_export_file($css, $style, $type = 'draft') {
$css = str_replace('<style type="text/css">', '', $css);
$css = str_replace('</style>', '', $css);
$filename = 'sweaver_' . $style->theme . '_' . $style->style_id . '_' . $type . '.css';
// Create the css within the files folder.
$sweaver_directory = 'public://sweaver';
file_prepare_directory($sweaver_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$file = $sweaver_directory . '/' . $filename;
if (!($fp = fopen($file, 'w'))) {
sweaver_session(t('The css file could not be created.'));
}
else {
// Clean the css before writing it.
$css = $this
->sweaver_ctools_css_filter($css, FALSE);
fwrite($fp, $css);
}
@fclose($fp);
}