You are here

public function sweaver_plugin_styles::sweaver_delete_style in Sweaver 7

Same name and namespace in other branches
  1. 6 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 509
Styles plugin.

Class

sweaver_plugin_styles

Code

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

  // Remove files tied to theme.
  $dir = 'public://sweaver';
  $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_unmanaged_delete($file->uri);
  }
}