You are here

public function sweaver_plugin_styles::sweaver_delete_style in Sweaver 6

Same name and namespace in other branches
  1. 7 plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc \sweaver_plugin_styles::sweaver_delete_style()

Delete a complete style.

2 calls to sweaver_plugin_styles::sweaver_delete_style()
sweaver_plugin_styles::sweaver_form_submit in plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc
Frontend form submit.
sweaver_plugin_styles::sweaver_style_confirm_form_delete_submit in plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc
Submit callback, delete style.

File

plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc, line 472
Styles plugin.

Class

sweaver_plugin_styles

Code

public function sweaver_delete_style($style) {
  db_query("DELETE FROM {sweaver_style} WHERE style_id = %d", $style->style_id);
  db_query("DELETE FROM {sweaver_style_draft} WHERE style_id = %d", $style->style_id);
  $draft = file_directory_path() . '/sweaver/sweaver_' . $style->theme . '_' . $style->style_id . '_draft.css';
  $live = file_directory_path() . '/sweaver/sweaver_' . $style->theme . '_' . $style->style_id . '_live.css';
  file_delete($draft);
  file_delete($live);

  // Remove files tied to theme.
  $dir = file_directory_path() . '/sweaver';

  // Get files with id.
  $mask = '(.*)' . $style->theme . '_' . $style->style_id . '_(.*)';
  $files = file_scan_directory($dir, $mask);

  // Get temp files.
  $mask = '(.*)' . $style->theme . '_temp_(.*)';
  $files += file_scan_directory($dir, $mask);
  foreach ($files as $key => $file) {
    file_delete($file->filename);
  }
}