You are here

function _print_pdf_tools in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 5.4 print_pdf/print_pdf.admin.inc \_print_pdf_tools()
  2. 5.3 print_pdf/print_pdf.admin.inc \_print_pdf_tools()
  3. 7 print_pdf/print_pdf.admin.inc \_print_pdf_tools()
  4. 5.x print_pdf/print_pdf.admin.inc \_print_pdf_tools()

Auxiliary function to locate suitable PDF generation tools

Return value

array of filenames with the include-able PHP file of the located tools

1 call to _print_pdf_tools()
print_pdf_settings in print_pdf/print_pdf.admin.inc
Menu callback for the PDF version module settings form.

File

print_pdf/print_pdf.admin.inc, line 284
Contains the administrative functions of the PDF version module.

Code

function _print_pdf_tools() {
  $tools = array_keys(file_scan_directory(drupal_get_path('module', 'print'), '^dompdf_config.inc.php$'));
  $tools = array_merge($tools, array_keys(file_scan_directory(drupal_get_path('module', 'print'), '^tcpdf.php$')));
  $tools = array_merge($tools, array_keys(file_scan_directory(drupal_get_path('module', 'print'), '^wkhtmltopdf')));
  $tools = array_merge($tools, array_keys(file_scan_directory(PRINT_PDF_LIB_PATH, '^dompdf_config.inc.php$')));
  $tools = array_merge($tools, array_keys(file_scan_directory(PRINT_PDF_LIB_PATH, '^tcpdf.php$')));
  $tools = array_merge($tools, array_keys(file_scan_directory(PRINT_PDF_LIB_PATH, '^wkhtmltopdf')));
  if (module_exists('libraries')) {
    $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('dompdf'), '^dompdf_config.inc.php$')));
    $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('tcpdf'), '^tcpdf.php$')));
    $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('wkhtmltopdf'), '^wkhtmltopdf')));
  }
  $num_tools = count($tools);
  if ($num_tools == 0) {
    variable_set('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
    return -1;
  }
  else {

    // Instead of array_combine(), use this to maintain PHP4 compatibility
    $tools2 = array();
    foreach ($tools as $key => $val) {
      $tools2[$val] = $val;
    }
    return $tools2;
  }
}