You are here

function print_pdf_init in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 7.2 print_pdf/print_pdf.module \print_pdf_init()
  2. 7 print_pdf/print_pdf.module \print_pdf_init()

Implementation of hook_init().

File

print_pdf/print_pdf.module, line 86
Displays Printer-friendly versions of Drupal pages.

Code

function print_pdf_init() {
  if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
    $pdf_dirs = array();
    $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
    if (basename($print_pdf_pdf_tool) == 'dompdf_config.inc.php') {
      $pdf_dirs[] = PRINT_PDF_DOMPDF_CACHE_DIR_DEFAULT . '/fonts';
    }
    elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') {
      foreach (array(
        'cache',
        'images',
      ) as $dir) {
        $pdf_dirs[] = PRINT_PDF_TCPDF_CACHE_DIR_DEFAULT . '/' . $dir;
      }
    }
    if (!empty($pdf_dirs)) {
      foreach ($pdf_dirs as $pdf_dir) {
        $directory = file_directory_path() . '/' . $pdf_dir;
        if (!is_dir($directory)) {
          $dir_tmp = '';
          foreach (explode('/', $pdf_dir) as $dir) {
            $dir_tmp .= $dir . '/';
            $directory = file_directory_path() . '/' . $dir_tmp;
            file_check_directory($directory, FILE_CREATE_DIRECTORY);
          }
        }
      }
    }
  }
}