You are here

sheetnode_phpexcel.install in Sheetnode 6

File

modules/sheetnode_phpexcel/sheetnode_phpexcel.install
View source
<?php

/**
 * Implementation of hook_requirements().
 */
function sheetnode_phpexcel_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {

    // PHPExcel library.
    $dir = rtrim(variable_get('sheetnode_phpexcel_library_path', ''), '/');
    $satisfied = is_dir($dir) && is_file($dir . '/Classes/PHPExcel.php');
    if ($satisfied) {
      $version = PHPExcel_Calculation_Functions::VERSION();
    }
    $requirements['sheetnode_phpexcel_library'] = array(
      'title' => $t('PHPExcel library'),
      'value' => $satisfied ? $version : $t('PHPExcel NOT found at !dir.', array(
        '!dir' => !empty($dir) ? $dir : $t('[empty path]'),
      )),
      'severity' => $satisfied ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );

    // TCPDF library.
    $dir = rtrim(variable_get('sheetnode_phpexcel_pdf_renderer_path', ''), '/');
    $satisfied = is_dir($dir) && is_file($dir . '/tcpdf.php');
    if ($satisfied) {
      require_once $dir . '/tcpdf.php';
      $tcPDF = new TCPDF();
      if (method_exists($tcPDF, 'getTCPDFVersion')) {
        $version = 'TCPDF ' . $tcPDF
          ->getTCPDFVersion();
      }
      else {
        $version = 'TCPDF ' . $t("(version unknown)");
      }
    }
    $requirements['sheetnode_phpexcel_pdf_renderer'] = array(
      'title' => $t('TCPDF library'),
      'value' => $satisfied ? $version : $t('TCPDF NOT found at !dir.', array(
        '!dir' => !empty($dir) ? $dir : $t('[empty path]'),
      )),
      'severity' => $satisfied ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

/**
 * Implementation of hook_uninstall().
 */
function sheetnode_phpexcel_uninstall() {
  variable_del('sheetnode_phpexcel_library_path');
  variable_del('sheetnode_phpexcel_export_links');
  variable_del('sheetnode_phpexcel_pdf_renderer_path');
}

Functions