You are here

function views_pdf_plugin_display::options_form in Views PDF 7.2

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

Option form

Overrides views_plugin_display_page::options_form

File

plugins/views_pdf_plugin_display.inc, line 206
PDF display plugin.

Class

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

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  switch ($form_state['section']) {
    case 'pdf_page':
      $form['#title'] .= t('PDF Page Options');
      $form['default_page_format'] = array(
        '#type' => 'select',
        '#title' => t('Default Page Format'),
        '#required' => TRUE,
        '#options' => views_pdf_get_page_formats(),
        '#description' => t('This is the default page format. If you specifiy a different format in the template section, this settings will be override.'),
        '#default_value' => $this
          ->get_option('default_page_format'),
      );
      $form['default_page_format_custom'] = array(
        '#type' => 'textfield',
        '#title' => t('Custom Page Format'),
        '#description' => t('Here you can specifiy a custom page format. The schema is "[width]x[height]".'),
        '#default_value' => $this
          ->get_option('default_page_format_custom'),
      );
      $form['default_page_orientation'] = array(
        '#type' => 'radios',
        '#title' => t('Default Page Orientation'),
        '#required' => TRUE,
        '#options' => array(
          'P' => t('Portrait'),
          'L' => t('Landscape'),
        ),
        '#description' => t('This is the default page orientation.'),
        '#default_value' => $this
          ->get_option('default_page_orientation'),
      );
      $form['unit'] = array(
        '#type' => 'select',
        '#title' => t('Unit'),
        '#required' => TRUE,
        '#options' => array(
          'mm' => t('mm: Millimeter'),
          'pt' => t('pt: Point'),
          'cm' => t('cm: Centimeter'),
          'in' => t('in: Inch'),
        ),
        '#description' => t('This is the unit for the entered unit data. If you change this option all defined units were changed, but not converted.'),
        '#default_value' => $this
          ->get_option('unit'),
      );
      $form['margin_left'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin: Left'),
        '#required' => TRUE,
        '#default_value' => $this
          ->get_option('margin_left'),
      );
      $form['margin_right'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin: Right'),
        '#required' => TRUE,
        '#default_value' => $this
          ->get_option('margin_right'),
      );
      $form['margin_top'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin: Top'),
        '#required' => TRUE,
        '#default_value' => $this
          ->get_option('margin_top'),
      );
      $form['margin_bottom'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin: Bottom'),
        '#required' => TRUE,
        '#default_value' => $this
          ->get_option('margin_bottom'),
      );
      break;
    case 'pdf_fonts':
      $fonts = views_pdf_get_font_list();
      $font_styles = array(
        'b' => t('Bold'),
        'i' => t('Italic'),
        'u' => t('Underline'),
        'd' => t('Line through'),
        'o' => t('Overline'),
      );
      $align = array(
        'L' => t('Left'),
        'C' => t('Center'),
        'R' => t('Right'),
        'J' => t('Justify'),
      );
      $hyphenate = array(
        'none' => t('None'),
        'auto' => t('Detect automatically'),
      );
      $hyphenate = array_merge($hyphenate, views_pdf_get_hyphenations());
      $form['#title'] .= t('PDF Default Font Options');
      $form['description'] = array(
        '#prefix' => '<div class="description form-item">',
        '#suffix' => '</div>',
        '#value' => t('Here you specify a the default font settings for the document.'),
      );
      $form['default_font_size'] = array(
        '#type' => 'textfield',
        '#title' => t('Font Size'),
        '#size' => 10,
        '#default_value' => $this
          ->get_option('default_font_size'),
      );
      $form['default_font_family'] = array(
        '#type' => 'select',
        '#title' => t('Font Family'),
        '#options' => $fonts,
        '#size' => 5,
        '#default_value' => $this
          ->get_option('default_font_family'),
      );
      $form['default_font_style'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Font Style'),
        '#options' => $font_styles,
        '#default_value' => $this
          ->get_option('default_font_style'),
      );
      $form['default_text_align'] = array(
        '#type' => 'radios',
        '#title' => t('Text Alignment'),
        '#options' => $align,
        '#default_value' => $this
          ->get_option('default_text_align'),
      );
      $form['default_text_hyphenate'] = array(
        '#type' => 'select',
        '#title' => t('Text Hyphenation'),
        '#options' => $hyphenate,
        '#description' => t('If you want to use hyphenation, then you need to download from <a href="@url">ctan.org</a> your needed pattern set. Then upload it to the dir "hyphenate_patterns" in the TCPDF lib directory. Perhaps you need to create the dir first. If you select the automated detection, then we try to get the language of the current node and select an appropriate hyphenation pattern.', array(
          '@url' => 'http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/tex',
        )),
        '#default_value' => $this
          ->get_option('default_text_hyphenate'),
      );
      $form['default_font_color'] = array(
        '#type' => 'textfield',
        '#title' => t('Text Color'),
        '#description' => t('If a value is entered without a comma, it will be interpreted as a hexadecimal RGB color. Normal RGB can be used by separating the components by a comma. e.g 255,255,255 for white. A CMYK color can be entered in the same way as RGB. e.g. 0,100,0,0 for magenta.'),
        '#size' => 20,
        '#default_value' => $this
          ->get_option('default_font_color'),
      );
      break;
    case 'pdf_template':
      $form['#title'] .= t('PDF Templates');
      $templates = array_merge(array(
        t('-- None --'),
      ), views_pdf_get_pdf_templates());
      $form['leading_template'] = array(
        '#type' => 'select',
        '#options' => $templates,
        '#title' => t('Leading PDF Template'),
        '#required' => FALSE,
        '#description' => t('Here you specify a PDF file to be printed in front of every row.'),
        '#default_value' => $this
          ->get_option('leading_template'),
      );
      $form['template'] = array(
        '#type' => 'select',
        '#options' => $templates,
        '#title' => t('Template PDF'),
        '#description' => t('Here you specify a PDF file on which the content is printed. The first page of this document is used for the first page, in the target document. The second page is used for the second page in the target document and so on. If the target document has more that this template file, the last page of the template will be repeated. The leading document has no effect on the order of the pages.'),
        '#default_value' => $this
          ->get_option('template'),
      );
      $form['succeed_template'] = array(
        '#type' => 'select',
        '#options' => $templates,
        '#title' => t('Succeed PDF Template'),
        '#required' => FALSE,
        '#description' => t('Here you specify a PDF file to be printed after the main content.'),
        '#default_value' => $this
          ->get_option('succeed_template'),
      );
      $form['template_file'] = array(
        '#type' => 'file',
        '#title' => t('Upload New Template File'),
      );
      break;
    case 'displays':
      $form['#title'] .= t('Attach to');
      $displays = array();
      foreach ($this->view->display as $display_id => $display) {
        if (!empty($display->handler) && $display->handler
          ->accept_attachments()) {
          $displays[$display_id] = $display->display_title;
        }
      }
      $form['displays'] = array(
        '#type' => 'checkboxes',
        '#description' => t('The feed icon will be available only to the selected displays.'),
        '#options' => $displays,
        '#default_value' => $this
          ->get_option('displays'),
      );
      break;
    case 'css':
      $form['#title'] .= t('CSS File');
      $form['css_file'] = array(
        '#type' => 'textfield',
        '#description' => t('URL to a CSS file. This file is attached to all fields, rendered as HTML.'),
        '#default_value' => $this
          ->get_option('css_file'),
      );
      break;
  }
}