function print_pdf_init in Printer, email and PDF versions 7.2
Same name and namespace in other branches
- 6 print_pdf/print_pdf.module \print_pdf_init()
- 7 print_pdf/print_pdf.module \print_pdf_init()
Implements hook_init().
File
- print_pdf/
print_pdf.module, line 58 - Displays Printer-friendly versions of Drupal pages.
Code
function print_pdf_init() {
if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$tool = explode('|', $print_pdf_pdf_tool);
$function = $tool[0] . '_pdf_tool_info';
$info = function_exists($function) ? $function() : array();
if (isset($info['public_dirs'])) {
foreach ($info['public_dirs'] as $dir) {
$directory = 'public://print_pdf/' . $tool[0] . '/' . $dir;
/** @var DrupalLocalStreamWrapper $wrapper */
$wrapper = file_stream_wrapper_get_instance_by_uri($directory);
$real_directory_path = $wrapper
->getDirectoryPath() . "/" . file_uri_target($directory);
$result = file_prepare_directory($real_directory_path, FILE_CREATE_DIRECTORY);
if (!$result) {
watchdog('print_pdf', 'Failed to create directory "%dir" for %tool.', array(
'%dir' => $directory,
'%tool' => $tool[0],
), WATCHDOG_CRITICAL);
}
}
}
}
if (variable_get('print_pdf_cache_enabled', PRINT_PDF_CACHE_ENABLED_DEFAULT)) {
$directory = print_pdf_cache_dir();
$wrapper = file_stream_wrapper_get_instance_by_uri($directory);
$real_directory_path = $wrapper
->getDirectoryPath() . "/" . file_uri_target($directory);
$result = file_prepare_directory($real_directory_path, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
if (!$result) {
watchdog('print_pdf', 'Failed to create directory "%dir" for print_pdf cache.', array(
'%dir' => $directory,
), WATCHDOG_CRITICAL);
}
}
}