You are here

public function sweaver_plugin_styles::sweaver_autosave in Sweaver 6

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

Autosave post.

File

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

Class

sweaver_plugin_styles

Code

public function sweaver_autosave() {

  // Prevent caching of JS output.
  $GLOBALS['conf']['cache'] = FALSE;

  // Prevent Devel from hi-jacking our output in any case.
  $GLOBALS['devel_shutdown'] = FALSE;

  // Load CTools object cache.
  ctools_include('object-cache');

  // Save current styling.
  $style = new stdClass();
  $style->style_id = 0;
  $style->style = t('Temporary');
  $style->css = $_POST['css'];
  $style->customcss = $_POST['customcss'];
  $style->palette = $_POST['palette'];

  // Get the themesettings if applicable and overwrite style id & style name.
  $sweaver = Sweaver::get_instance();
  $working_style = $sweaver
    ->get_current_style();
  if (isset($working_style->themesettings)) {
    $style->theme = $working_style->theme;
    $style->themesettings = $working_style->themesettings;
  }

  // Save to CTools object cache.
  ctools_object_cache_set('sweaver-styling', 'sweaver-styling', $style);

  // Set session variable.
  sweaver_session(TRUE, 'sweaver_temp');

  // Exit.
  exit(drupal_json(array(
    'error' => 0,
  )));
}