You are here

function views_pdf_plugin_display::options_submit in Views PDF 6

Same name and namespace in other branches
  1. 7.3 views_pdf_plugin_display.inc \views_pdf_plugin_display::options_submit()
  2. 7 views_pdf_plugin_display.inc \views_pdf_plugin_display::options_submit()
  3. 7.2 plugins/views_pdf_plugin_display.inc \views_pdf_plugin_display::options_submit()

Handles the storage of the options.

File

./views_pdf_plugin_display.inc, line 476
PDF display plugin.

Class

views_pdf_plugin_display
This class contains all the functionality of the PDF display.

Code

function options_submit(&$form, &$form_state) {

  // It is very important to call the parent function here:
  parent::options_submit($form, $form_state);
  switch ($form_state['section']) {
    case 'pdf_page':
      $this
        ->set_option('default_page_format', $form_state['values']['default_page_format']);
      $this
        ->set_option('default_page_format_custom', $form_state['values']['default_page_format_custom']);
      $this
        ->set_option('default_page_orientation', $form_state['values']['default_page_orientation']);
      $this
        ->set_option('unit', $form_state['values']['unit']);
      $this
        ->set_option('margin_left', $form_state['values']['margin_left']);
      $this
        ->set_option('margin_right', $form_state['values']['margin_right']);
      $this
        ->set_option('margin_top', $form_state['values']['margin_top']);
      $this
        ->set_option('margin_bottom', $form_state['values']['margin_bottom']);
      break;
    case 'pdf_fonts':
      $this
        ->set_option('default_font_size', $form_state['values']['default_font_size']);
      $this
        ->set_option('default_font_style', $form_state['values']['default_font_style']);
      $this
        ->set_option('default_font_family', $form_state['values']['default_font_family']);
      $this
        ->set_option('default_text_align', $form_state['values']['default_text_align']);
      $this
        ->set_option('default_font_color', $form_state['values']['default_font_color']);
      break;
    case 'pdf_template':
      $this
        ->set_option('leading_template', $form_state['values']['leading_template']);
      $this
        ->set_option('template', $form_state['values']['template']);
      $this
        ->set_option('succeed_template', $form_state['values']['succeed_template']);

      // Save new file:
      // Note: The jQuery update is required to use Ajax for file upload. With
      // default Drupal jQuery it will not work.
      // For upload with Ajax a iFrame is open and upload in it, because
      // normal forms are not allowed to handle directly.
      $files_path = file_directory_path();
      $template_dir = variable_get('views_pdf_template_path', 'views_pdf_templates');
      $dir = $files_path . '/' . $template_dir;
      if (!is_dir($dir)) {
        @mkdir($dir);
        @chmod($dir, 0775);
      }
      if (is_writable($dir)) {
        $template_path = file_create_path($dir);
        $file = file_save_upload('template_file', array(), $template_path);
        if (is_object($file)) {
          file_set_status(&$file, FILE_STATUS_PERMANENT);
        }
      }
      break;
    case 'displays':
      $this
        ->set_option($form_state['section'], $form_state['values'][$form_state['section']]);
      break;
    case 'css':
      $this
        ->set_option('css_file', $form_state['values']['css_file']);
      break;
  }
}