You are here

function views_pdf_plugin_display::options_submit in Views PDF 7.2

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

Handles the storage of the options.

Overrides views_plugin_display_page::options_submit

File

plugins/views_pdf_plugin_display.inc, line 492
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':

      // 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.
      $destination = variable_get('views_pdf_template_stream', 'public://views_pdf_templates');
      if (file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
        $file = file_save_upload('template_file', array(), $destination);
        if (is_object($file)) {
          $file_name = basename($file->destination, '.pdf');
          $form_state['values']['template'] = $file_name;
          $file->status |= FILE_STATUS_PERMANENT;
          $file = file_save($file);
        }
      }
      $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']);
      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;
  }
}