You are here

class views_pdf_plugin_display in Views PDF 7.3

Same name and namespace in other branches
  1. 6 views_pdf_plugin_display.inc \views_pdf_plugin_display
  2. 7 views_pdf_plugin_display.inc \views_pdf_plugin_display
  3. 7.2 plugins/views_pdf_plugin_display.inc \views_pdf_plugin_display

This class contains all the functionality of the PDF display.

Hierarchy

Expanded class hierarchy of views_pdf_plugin_display

1 string reference to 'views_pdf_plugin_display'
views_pdf_views_plugins in ./views_pdf.views.inc
Implements hook_views_plugins().

File

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

View source
class views_pdf_plugin_display extends views_plugin_display_page {

  /**
   * Define the display type
   */
  function get_style_type() {
    return 'pdf';
  }

  /**
   * Disable the breadcrumb
   */
  function uses_breadcrumb() {
    return FALSE;
  }
  function has_path() {
    return TRUE;
  }

  /**
   * Render the display
   */
  function render() {

    // Generall document layout
    // Set default code
    $this->view->pdf
      ->SetFont('');

    // Render the first result row to generate tokens.
    // Only field-value tokens from the first row are usable.
    if ($result0 = reset($this->view->result)) {
      $this->view->style_plugin
        ->render_fields(array(
        $result0,
      ));
    }

    // Add leading pages
    $path = $this->view->pdf
      ->getTemplatePath($this
      ->get_option('leading_template'));
    $this->view->pdf
      ->addPdfDocument($path, 'leading');

    // Set the default background template
    $path = $this->view->pdf
      ->getTemplatePath($this
      ->get_option('template'));
    $this->view->pdf
      ->setDefaultPageTemplate($path, 'main');

    // Clear the leading/succeed flag.
    $this->view->pdf
      ->addPdfDocument();

    // Render the items
    $this->view->style_plugin
      ->render();

    // Add succeed pages
    $path = $this->view->pdf
      ->getTemplatePath($this
      ->get_option('succeed_template'));
    $this->view->pdf
      ->addPdfDocument($path, 'closing');
  }

  /**
   * Provide the preview. Because PDF cannot be embedded good in HTML, we do not
   * provide a preview.
   */
  function preview() {
    return t('The PDF display does not provide a preview.');
  }

  /**
   * This function executes the PDF display.
   */
  function execute($path_to_store_pdf = '', $destination = 'I') {

    // Defines external configuration for TCPDF library
    if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
      $tcpdf_path = drupal_realpath(views_pdf_get_library('tcpdf'));
      $cache_path = 'public://views_pdf_cache/';
      file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY);
      global $base_url;
      define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
      define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
      define('K_PATH_URL', $base_url);
      define('K_PATH_FONTS', $tcpdf_path . '/fonts/');
      define('K_PATH_CACHE', drupal_realpath($cache_path));
      define('K_PATH_IMAGES', '');
      define('K_BLANK_IMAGE', $tcpdf_path . '/images/_blank.png');
      define('K_CELL_HEIGHT_RATIO', 1.25);
      define('K_SMALL_RATIO', 2 / 3);
    }
    if ($this
      ->get_option('default_page_format') == 'custom') {
      if (preg_match('~([0-9\\.]+)x([0-9\\.]+)~', $this
        ->get_option('default_page_format_custom'), $result)) {
        $format[0] = $result[1];

        // width
        $format[1] = $result[2];

        // height
      }
      else {
        $format = 'A4';
      }
    }
    else {
      $format = $this
        ->get_option('default_page_format');
    }
    $orientation = $this
      ->get_option('default_page_orientation');

    // P or L
    $unit = $this
      ->get_option('unit');
    $this->view->pdf = views_pdf_get_new_pdf_instance($orientation, $unit, $format);

    // Set margins: top, left, right
    $this->view->pdf
      ->SetMargins($this
      ->get_option('margin_left'), $this
      ->get_option('margin_top'), $this
      ->get_option('margin_right'), TRUE);

    // Set auto page break: margin bottom:
    $this->view->pdf
      ->SetAutoPageBreak(TRUE, $this
      ->get_option('margin_bottom'));
    $this->view->pdf
      ->setDefaultFontSize($this
      ->get_option('default_font_size'));
    $this->view->pdf
      ->setDefaultFontFamily($this
      ->get_option('default_font_family'));
    $this->view->pdf
      ->setDefaultFontStyle($this
      ->get_option('default_font_style'));
    $this->view->pdf
      ->setDefaultTextAlign($this
      ->get_option('default_text_align'));
    $this->view->pdf
      ->setDefaultFontColor($this
      ->get_option('default_font_color'));
    $this->view->pdf
      ->setViewsHeaderFooter($this);
    $html = $this->view
      ->render($this->display->id);
    if (!empty($html)) {
      echo $html;
    }
    if (empty($path_to_store_pdf)) {
      $path_to_store_pdf = $this->view
        ->get_title();
      $this->view->pdf
        ->SetTitle($this->view
        ->get_title());
    }
    if (!preg_match('/\\.pdf$/', $path_to_store_pdf)) {
      $path_to_store_pdf .= '.pdf';
    }
    ob_clean();
    if ($destination == 'I') {
      echo $this->view->pdf
        ->Output($path_to_store_pdf, $destination);
      exit;
    }
    else {
      return $this->view->pdf
        ->Output($path_to_store_pdf, $destination);
    }
  }

  /**
   * This method defines the default sections and the appropriated values.
   *
   */
  function defaultable_sections($section = NULL) {
    if (in_array($section, array(
      'style_options',
      'style_plugin',
      'row_options',
      'row_plugin',
    ))) {
      return FALSE;
    }
    $sections = parent::defaultable_sections($section);

    // Tell views our sitename_title option belongs in the title section.
    if ($section == 'title') {
      $sections[] = 'sitename_title';
    }
    elseif (!$section) {
      $sections['title'][] = 'sitename_title';
    }
    return $sections;
  }

  /**
   * The option definition.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['displays'] = array(
      'default' => array(),
    );

    // Overrides for standard stuff:
    $options['style_plugin']['default'] = 'pdf_unformatted';
    $options['style_options']['default'] = array(
      'mission_description' => FALSE,
      'description' => '',
    );
    $options['sitename_title']['default'] = FALSE;
    $options['row_plugin']['default'] = 'pdf_fields';
    $options['defaults']['default']['style_plugin'] = FALSE;
    $options['defaults']['default']['style_options'] = FALSE;
    $options['defaults']['default']['row_plugin'] = FALSE;
    $options['defaults']['default']['row_options'] = FALSE;

    // New Options
    $options['default_page_format'] = array(
      'default' => 'A4',
    );
    $options['default_page_format_custom'] = array(
      'default' => '',
    );
    $options['default_page_orientation'] = array(
      'default' => 'P',
    );
    $options['unit'] = array(
      'default' => 'mm',
    );
    $options['margin_left'] = array(
      'default' => '15',
    );
    $options['margin_right'] = array(
      'default' => '15',
    );
    $options['margin_top'] = array(
      'default' => '15',
    );
    $options['margin_bottom'] = array(
      'default' => '15',
    );
    $options['leading_template'] = array(
      'default' => '',
    );
    $options['template'] = array(
      'default' => '',
    );
    $options['succeed_template'] = array(
      'default' => '',
    );
    $options['default_font_family'] = array(
      'default' => 'helvetica',
    );
    $options['default_font_style'] = array(
      'default' => array(),
    );
    $options['default_font_size'] = array(
      'default' => '11',
    );
    $options['default_text_align'] = array(
      'default' => 'L',
    );
    $options['default_font_color'] = array(
      'default' => '000000',
    );
    $options['default_text_hyphenate'] = array(
      'default' => 'none',
    );
    $options['header_margin'] = array(
      'default' => '1',
    );
    $options['header_font_family'] = array(
      'default' => 'helvetica',
    );
    $options['header_font_style'] = array(
      'default' => array(),
    );
    $options['header_font_size'] = array(
      'default' => '12',
    );
    $options['header_text_align'] = array(
      'default' => 'C',
    );
    $options['header_font_color'] = array(
      'default' => '000000',
    );
    $options['footer_spacing'] = array(
      'default' => '1',
    );
    $options['footer_font_family'] = array(
      'default' => 'helvetica',
    );
    $options['footer_font_style'] = array(
      'default' => array(),
    );
    $options['footer_font_size'] = array(
      'default' => '12',
    );
    $options['footer_text_align'] = array(
      'default' => 'C',
    );
    $options['footer_font_color'] = array(
      'default' => '000000',
    );
    $options['css_file'] = array(
      'default' => '',
    );
    return $options;
  }

  /**
   * Option form
   */
  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_header':
        $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'),
        );
        $form['#title'] .= t('PDF Header & Footer Options');
        $form['header'] = array(
          '#type' => 'fieldset',
          '#title' => t('Header options'),
          '#collapsed' => TRUE,
          '#collapsible' => TRUE,
        );
        $form['header']['header_margin'] = array(
          '#type' => 'textfield',
          '#title' => t('Top margin'),
          '#size' => 10,
          '#default_value' => $this
            ->get_option('header_margin'),
        );
        $form['header']['header_font_size'] = array(
          '#type' => 'textfield',
          '#title' => t('Font Size'),
          '#size' => 10,
          '#default_value' => $this
            ->get_option('header_font_size'),
        );
        $form['header']['header_font_family'] = array(
          '#type' => 'select',
          '#title' => t('Font Family'),
          '#options' => $fonts,
          '#size' => 5,
          '#default_value' => $this
            ->get_option('header_font_family'),
        );
        $form['header']['header_font_style'] = array(
          '#type' => 'checkboxes',
          '#title' => t('Font Style'),
          '#options' => $font_styles,
          '#default_value' => $this
            ->get_option('header_font_style'),
        );
        $form['header']['header_text_align'] = array(
          '#type' => 'radios',
          '#title' => t('Text Alignment'),
          '#options' => $align,
          '#default_value' => $this
            ->get_option('header_text_align'),
        );
        $form['header']['header_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('header_font_color'),
        );
        $form['footer'] = array(
          '#type' => 'fieldset',
          '#title' => t('Footer options'),
          '#collapsed' => TRUE,
          '#collapsible' => TRUE,
        );
        $form['footer']['footer_spacing'] = array(
          '#type' => 'textfield',
          '#title' => t('Bottom spacing'),
          '#size' => 10,
          '#default_value' => $this
            ->get_option('footer_spacing'),
        );
        $form['footer']['footer_font_size'] = array(
          '#type' => 'textfield',
          '#title' => t('Font Size'),
          '#size' => 10,
          '#default_value' => $this
            ->get_option('footer_font_size'),
        );
        $form['footer']['footer_font_family'] = array(
          '#type' => 'select',
          '#title' => t('Font Family'),
          '#options' => $fonts,
          '#size' => 5,
          '#default_value' => $this
            ->get_option('footer_font_family'),
        );
        $form['footer']['footer_font_style'] = array(
          '#type' => 'checkboxes',
          '#title' => t('Font Style'),
          '#options' => $font_styles,
          '#default_value' => $this
            ->get_option('footer_font_style'),
        );
        $form['footer']['footer_text_align'] = array(
          '#type' => 'radios',
          '#title' => t('Text Alignment'),
          '#options' => $align,
          '#default_value' => $this
            ->get_option('footer_text_align'),
        );
        $form['footer']['footer_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('footer_font_color'),
        );
        break;
      case 'pdf_template':
        $form['#title'] .= t('PDF Templates');
        $templates = array_merge(array(
          t('-- None --'),
        ), views_pdf_get_pdf_templates());
        $form['leading'] = array(
          '#type' => 'fieldset',
          '#title' => t('Leading PDF Template'),
        );
        $form['leading']['leading_template'] = array(
          '#type' => 'select',
          '#options' => $templates,
          '#required' => FALSE,
          '#description' => t('Here you specify a PDF file to be printed before the main content.'),
          '#default_value' => $this
            ->get_option('leading_template'),
        );
        $form['leading']['leading_header'] = array(
          '#type' => 'checkbox',
          '#title' => 'Print page headers on leading template',
          '#default_value' => $this
            ->get_option('leading_header'),
        );
        $form['leading']['leading_footer'] = array(
          '#type' => 'checkbox',
          '#title' => 'Print page footers on leading template',
          '#default_value' => $this
            ->get_option('leading_footer'),
        );
        $form['background'] = array(
          '#type' => 'fieldset',
          '#title' => t('Background PDF Template'),
        );
        $form['background']['template'] = array(
          '#type' => 'select',
          '#options' => $templates,
          '#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'] = array(
          '#type' => 'fieldset',
          '#title' => t('Trailing PDF Template'),
        );
        $form['succeed']['succeed_template'] = array(
          '#type' => 'select',
          '#options' => $templates,
          '#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['succeed']['succeed_header'] = array(
          '#type' => 'checkbox',
          '#title' => 'Print page headers on trailing template',
          '#default_value' => $this
            ->get_option('succeed_header'),
        );
        $form['succeed']['succeed_footer'] = array(
          '#type' => 'checkbox',
          '#title' => 'Print page footers on trailing template',
          '#default_value' => $this
            ->get_option('succeed_footer'),
        );
        $form['notes']['#markup'] = t('To manage template files and upload new ones, go to the <a href="@link">PDF Templates</a> tab on the main Views page.', array(
          '@link' => '/admin/structure/views/pdfs',
        ));
        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;
    }
  }

  /**
   * Provide a summary of the options.
   */
  function options_summary(&$categories, &$options) {
    parent::options_summary($categories, $options);
    $fonts = views_pdf_get_font_list();

    // Change Page title:
    $categories['page'] = array(
      'title' => t('PDF settings'),
      'column' => 'second',
      'build' => array(
        '#weight' => -10,
      ),
    );

    // Add for attach the display to others:
    $displays = array_filter($this
      ->get_option('displays'));
    if (count($displays) > 1) {
      $attach_to = t('Multiple displays');
    }
    elseif (count($displays) == 1) {
      $display = array_shift($displays);
      if (!empty($this->view->display[$display])) {
        $attach_to = check_plain($this->view->display[$display]->display_title);
      }
    }
    if (!isset($attach_to)) {
      $attach_to = t('None');
    }
    $options['displays'] = array(
      'category' => 'page',
      'title' => t('Attach to'),
      'value' => $attach_to,
    );

    // Add for pdf page settings
    $options['pdf_page'] = array(
      'category' => 'page',
      'title' => t('PDF Page Settings'),
      'value' => $this
        ->get_option('default_page_format'),
      'desc' => t('Define some PDF specific settings.'),
    );

    // Add for pdf font settings
    $options['pdf_fonts'] = array(
      'category' => 'page',
      'title' => t('PDF Fonts Settings'),
      'value' => t('!family at !size pt', array(
        '!family' => $fonts[$this
          ->get_option('default_font_family')],
        '!size' => $this
          ->get_option('default_font_size'),
      )),
      'desc' => t('Define some PDF specific settings.'),
    );

    // Add for pdf header/footer settings
    $options['pdf_header'] = array(
      'category' => 'page',
      'title' => t('PDF Header & Footer'),
      'value' => t('Settings'),
      'desc' => t('Define PDF settings for header & footer.'),
    );

    // add for pdf template settings
    if (!empty($this
      ->get_option('leading_template')) || !empty($this
      ->get_option('template')) || !empty($this
      ->get_option('succeed_template'))) {
      $isAnyTemplate = t('Yes');
    }
    else {
      $isAnyTemplate = t('No');
    }
    $options['pdf_template'] = array(
      'category' => 'page',
      'title' => t('PDF Template Settings'),
      'value' => $isAnyTemplate,
      'desc' => t('Define some PDF specific settings.'),
    );
    if ($this
      ->get_option('css_file') == '') {
      $css_file = t('None');
    }
    else {
      $css_file = $this
        ->get_option('css_file');
    }
    $options['css'] = array(
      'category' => 'page',
      'title' => t('CSS File'),
      'value' => $css_file,
      'desc' => t('Define a CSS file attached to all HTML output.'),
    );
  }

  /**
   * Handles the storage of the options.
   *
   */
  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_header':
        $this
          ->set_option('header_margin', $form_state['values']['header_margin']);
        $this
          ->set_option('header_font_size', $form_state['values']['header_font_size']);
        $this
          ->set_option('header_font_style', $form_state['values']['header_font_style']);
        $this
          ->set_option('header_font_family', $form_state['values']['header_font_family']);
        $this
          ->set_option('header_text_align', $form_state['values']['header_text_align']);
        $this
          ->set_option('header_font_color', $form_state['values']['header_font_color']);
        $this
          ->set_option('footer_spacing', $form_state['values']['footer_spacing']);
        $this
          ->set_option('footer_font_size', $form_state['values']['footer_font_size']);
        $this
          ->set_option('footer_font_style', $form_state['values']['footer_font_style']);
        $this
          ->set_option('footer_font_family', $form_state['values']['footer_font_family']);
        $this
          ->set_option('footer_text_align', $form_state['values']['footer_text_align']);
        $this
          ->set_option('footer_font_color', $form_state['values']['footer_font_color']);
        break;
      case 'pdf_template':
        $this
          ->set_option('leading_template', $form_state['values']['leading_template']);
        $this
          ->set_option('leading_header', $form_state['values']['leading_header']);
        $this
          ->set_option('leading_footer', $form_state['values']['leading_footer']);
        $this
          ->set_option('template', $form_state['values']['template']);
        $this
          ->set_option('succeed_template', $form_state['values']['succeed_template']);
        $this
          ->set_option('succeed_header', $form_state['values']['succeed_header']);
        $this
          ->set_option('succeed_footer', $form_state['values']['succeed_footer']);
        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;
    }
  }

  /**
   * Attach to another view.
   */
  function attach_to($display_id) {
    $displays = $this
      ->get_option('displays');
    if (empty($displays[$display_id])) {
      return;
    }

    // Defer to the feed style; it may put in meta information, and/or
    // attach a feed icon.
    $plugin = $this
      ->get_plugin();
    if ($plugin) {
      $clone = $this->view
        ->clone_view();
      $clone
        ->set_display($this->display->id);
      $clone
        ->build_title();
      $plugin
        ->attach_to($display_id, $this
        ->get_path(), $clone
        ->get_title());
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_object::$definition public property Handler's definition.
views_object::$options public property Except for displays, options for the object will be held here. 1
views_object::altered_option_definition function Collect this handler's option definition and alter them, ready for use.
views_object::construct public function Views handlers use a special construct function. 4
views_object::export_options public function
views_object::export_option_always public function Always exports the option, regardless of the default value.
views_object::options Deprecated public function Set default options on this object. 1
views_object::set_default_options public function Set default options.
views_object::set_definition public function Let the handler know what its full definition is.
views_object::unpack_options public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable public function Unpack a single option definition.
views_object::unpack_translatables public function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults public function
views_pdf_plugin_display::attach_to function Attach to another view. Overrides views_plugin_display::attach_to
views_pdf_plugin_display::defaultable_sections function This method defines the default sections and the appropriated values. Overrides views_plugin_display::defaultable_sections
views_pdf_plugin_display::execute function This function executes the PDF display. Overrides views_plugin_display_page::execute
views_pdf_plugin_display::get_style_type function Define the display type Overrides views_plugin_display::get_style_type
views_pdf_plugin_display::has_path function The page display has a path. Overrides views_plugin_display_page::has_path
views_pdf_plugin_display::options_form function Option form Overrides views_plugin_display_page::options_form
views_pdf_plugin_display::options_submit function Handles the storage of the options. Overrides views_plugin_display_page::options_submit
views_pdf_plugin_display::options_summary function Provide a summary of the options. Overrides views_plugin_display_page::options_summary
views_pdf_plugin_display::option_definition function The option definition. Overrides views_plugin_display_page::option_definition
views_pdf_plugin_display::preview function Provide the preview. Because PDF cannot be embedded good in HTML, we do not provide a preview. Overrides views_plugin_display::preview
views_pdf_plugin_display::render function Render the display Overrides views_plugin_display::render
views_pdf_plugin_display::uses_breadcrumb function Disable the breadcrumb Overrides views_plugin_display_page::uses_breadcrumb
views_plugin::$display public property The current used views display.
views_plugin::$plugin_name public property The plugin name of this plugin, for example table or full.
views_plugin::$plugin_type public property The plugin type of this plugin, for example style or query.
views_plugin::additional_theme_functions public function Provide a list of additional theme functions for the theme info page.
views_plugin::plugin_title public function Return the human readable name of the display.
views_plugin::summary_title public function Returns the summary of the settings in the display. 8
views_plugin::theme_functions public function Provide a full list of possible theme templates used by this style.
views_plugin_display::$extender public property Stores all available display extenders.
views_plugin_display::$handlers public property List of handlers for this display.
views_plugin_display::$view public property The top object of a view. Overrides views_plugin::$view
views_plugin_display::accept_attachments public function Can this display accept attachments?
views_plugin_display::access public function Determine if the user has access to this display of the view.
views_plugin_display::destroy public function Destructor. Overrides views_object::destroy
views_plugin_display::displays_exposed public function Determine if this display should display the exposed filters widgets. 1
views_plugin_display::export_handler public function Special method to export items that have handlers.
views_plugin_display::export_option public function Override of export_option() Overrides views_object::export_option
views_plugin_display::export_plugin public function Special handling for plugin export.
views_plugin_display::export_style public function Special handling for the style export.
views_plugin_display::format_themes public function Format a list of theme templates for output by the theme info helper.
views_plugin_display::get_arguments_tokens public function Returns to tokens for arguments.
views_plugin_display::get_field_labels public function List of fields for the current display with the associated relationship.
views_plugin_display::get_handler public function Get the handler object for a single handler.
views_plugin_display::get_handlers public function Get a full array of handlers for $type. This caches them.
views_plugin_display::get_link_display public function Check to see which display to use when creating links.
views_plugin_display::get_option public function Intelligently get an option either from this or default display.
views_plugin_display::get_path public function Return the base path to use for this display.
views_plugin_display::get_plugin public function Get the instance of a plugin, for example style or row.
views_plugin_display::get_special_blocks public function Provide the block system with any exposed widget blocks for this display.
views_plugin_display::get_url public function
views_plugin_display::hook_block_list public function If this display creates a block, implement one of these.
views_plugin_display::hook_menu public function If this display creates a page with a menu item, implement it here.
views_plugin_display::init public function 1
views_plugin_display::is_defaulted public function Determine if a given option is set to use the default or current display.
views_plugin_display::is_default_display public function If this display is the 'default' display which contains fallback settings. 1
views_plugin_display::is_identifier_unique public function Check if the provided identifier is unique.
views_plugin_display::options_override public function If override/revert was clicked, perform the proper toggle.
views_plugin_display::option_link public function Because forms may be split up into sections, this provides an easy URL to exactly the right section. Don't override this.
views_plugin_display::override_option public function Set an option and force it to be an override.
views_plugin_display::pre_execute public function Set up any variables on the view prior to execution.
views_plugin_display::query public function Inject anything into the query that the display handler needs. Overrides views_plugin::query
views_plugin_display::render_area public function
views_plugin_display::render_empty public function
views_plugin_display::render_filters public function Not all display plugins will support filtering.
views_plugin_display::render_footer public function Render the footer of the view.
views_plugin_display::render_header public function Render the header of the view.
views_plugin_display::render_more_link public function Render the 'more' link.
views_plugin_display::render_pager public function Not all display plugins will suppert pager rendering. 1
views_plugin_display::set_option public function Intelligently set an option either from this display or from the default display, if directed to do so.
views_plugin_display::set_override public function Flip the override setting for the given section.
views_plugin_display::unpack_handler public function Special method to unpack items that have handlers.
views_plugin_display::unpack_plugin public function Special handling for plugin unpacking.
views_plugin_display::unpack_style public function
views_plugin_display::uses_exposed public function Does this display uses exposed filters? 2
views_plugin_display::uses_exposed_form_in_block public function Check to see if the display can put the exposed form in a block.
views_plugin_display::uses_fields public function Determine if the display's style uses fields.
views_plugin_display::uses_link_display public function Check to see if the display has some need to link to another display. 1
views_plugin_display::use_ajax public function Does the display use AJAX?
views_plugin_display::use_group_by public function Does the display have groupby enabled?
views_plugin_display::use_more public function Does the display have a more link enabled?
views_plugin_display::use_more_always public function Should the enabled display more link be shown when no more items?
views_plugin_display::use_more_open_new_window public function Should the enabled display more link being opened in an new window?
views_plugin_display::use_more_text public function Does the display have custom link text?
views_plugin_display::use_pager public function Does the display have a pager enabled? 1
views_plugin_display::view_special_blocks public function Render any special blocks provided for this display.
views_plugin_display_page::execute_hook_menu public function Add this display's path information to Drupal's menu system.
views_plugin_display_page::get_argument_text public function Provide some helpful text for the arguments. Overrides views_plugin_display::get_argument_text
views_plugin_display_page::get_pager_text public function Provide some helpful text for pagers. Overrides views_plugin_display::get_pager_text
views_plugin_display_page::options_validate public function Validate the options form. Overrides views_plugin_display::options_validate
views_plugin_display_page::validate public function Make sure the display and all associated handlers are valid. Overrides views_plugin_display::validate