You are here

views_pdf.install in Views PDF 7

Install the views module

File

views_pdf.install
View source
<?php

/**
 * @file
 * Install the views module
 */

/**
 * Implements hook_requirements().
 */
function views_pdf_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();

  // Report Drupal version.
  if ($phase == 'runtime') {
    $path_tcpdf = views_pdf_get_library('tcpdf');
    $path_fpdi = views_pdf_get_library('fpdi');
    $requirements['views_pdf_tcpdf'] = array(
      'title' => $t('Views PDF - TCPDF'),
      'value' => $t('Not present'),
      'description' => $t('The TCPDF library is used for the Views PDF. Please download it and place it in this location: @location.', array(
        '@location' => $path_tcpdf,
      )),
      'severity' => REQUIREMENT_ERROR,
    );
    $requirements['views_pdf_fpdi'] = array(
      'title' => $t('Views PDF - FPDI'),
      'value' => $t('Not present'),
      'description' => $t('The FPDI library is used for the Views PDF. Please download it and place it in this location: @location.', array(
        '@location' => $path_fpdi,
      )),
      'severity' => REQUIREMENT_ERROR,
    );
    $requirements['views_pdf_fpdi_tpl'] = array(
      'title' => $t('Views PDF - FPDI Template File'),
      'value' => $t('Not present'),
      'description' => $t('The FPDI library requires to install the FPDI template file to incoporate with TCPDF. Please place the file in to this location: @location.', array(
        '@location' => $path_fpdi . '/fpdf_tpl.php',
      )),
      'severity' => REQUIREMENT_ERROR,
    );
    if (file_exists($path_tcpdf)) {
      $requirements['views_pdf_tcpdf']['severity'] = REQUIREMENT_OK;
      $requirements['views_pdf_tcpdf']['value'] = $t('Present');
      unset($requirements['views_pdf_tcpdf']['description']);
    }
    if (file_exists($path_fpdi)) {
      $requirements['views_pdf_fpdi']['severity'] = REQUIREMENT_OK;
      $requirements['views_pdf_fpdi']['value'] = $t('Present');
      unset($requirements['views_pdf_fpdi']['description']);
    }
    if (file_exists($path_fpdi . '/fpdf_tpl.php')) {
      $requirements['views_pdf_fpdi_tpl']['severity'] = REQUIREMENT_OK;
      $requirements['views_pdf_fpdi_tpl']['value'] = $t('Present');
      unset($requirements['views_pdf_fpdi_tpl']['description']);
    }
  }
  return $requirements;
}

/**
 * The previous update to version 7.x-1.6 contained a faulty views_pdf_update_7000() function that
 * created a faulty views display object for some pdf displays (i.e. pdf display with the default "Display a specified number of items | 10"  pager )
 * This resulted in a display_option['pager'] NULL array element, which broke the pdf display.
 *
 * This new update replaces the views_pdf_update_7000() function and fixes the faulty array element
 * It is recommended that users avoid 7.x-1.6 and update to 7.x-1.7 version
 */
function views_pdf_update_7101() {
  $views = views_get_all_views();
  foreach ($views as $key => $view) {
    foreach ($view->display as $key => $display) {
      if ($display->display_plugin == 'pdf') {
        if (isset($display->display_options['pager'])) {
          if (!isset($display->display_options['defaults']['pager'])) {
            $display->display_options['defaults']['pager'] = FALSE;
          }
          if (!isset($display->display_options['defaults']['pager_options'])) {
            $display->display_options['defaults']['pager_options'] = FALSE;
          }
        }
      }
    }
    views_save_view($view);
  }
}

Functions

Namesort descending Description
views_pdf_requirements Implements hook_requirements().
views_pdf_update_7101 The previous update to version 7.x-1.6 contained a faulty views_pdf_update_7000() function that created a faulty views display object for some pdf displays (i.e. pdf display with the default "Display a specified number of items | 10" pager…