You are here

function _invoice_dompdf_include_lib in Invoice 7

Same name and namespace in other branches
  1. 6 invoice_helpers.inc \_invoice_dompdf_include_lib()

Helper function to include the dompdf library

1 call to _invoice_dompdf_include_lib()
invoice_view_pdf in ./invoice.module
Display the invoice in PDF format

File

./invoice_helpers.inc, line 710
Invoice module

Code

function _invoice_dompdf_include_lib() {
  $error = FALSE;
  $file = NULL;
  if (file_exists(DRUPAL_ROOT . '/sites/all/libraries/dompdf/dompdf_config.inc.php')) {
    $file = DRUPAL_ROOT . '/sites/all/libraries/dompdf/dompdf_config.inc.php';
  }
  elseif (file_exists(dirname(__FILE__) . '/../../libraries/dompdf/dompdf_config.inc.php')) {
    $file = dirname(__FILE__) . '/../../libraries/dompdf/dompdf_config.inc.php';
  }
  elseif (file_exists(dirname(__FILE__) . '/dompdf/dompdf_config.inc.php')) {

    // Backwards compatible
    $file = dirname(__FILE__) . '/dompdf/dompdf_config.inc.php';
  }
  else {
    drupal_set_message(t('The DOMPDF library could not be found!'), 'error');
    $error = TRUE;
  }
  if ($file !== NULL) {
    $content = file_get_contents($file);
    if (strpos($content, 'spl_autoload_register') !== false) {
      require_once $file;
    }
    else {
      drupal_set_message(t('Update your DOMPDF library, version 6 or higher is required!'), 'error');
      $error = TRUE;
    }
  }
  return $error;
}