summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ventura2010-07-25 17:25:13 (GMT)
committer Joao Ventura2010-07-25 17:25:13 (GMT)
commit4129b144863ed80ec2eaebee864cbb5767821702 (patch)
tree1cf777208c91a0f12d6cdde3fa540bc98e748c67
parent39610ea7fab3a76bc3dfe450fd86f892544e0fbf (diff)
Fix #726082: Remove dependency on allow_url_fopen by converting all image URLs to local files
-rw-r--r--print_pdf/print_pdf.pages.inc34
1 files changed, 19 insertions, 15 deletions
diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc
index 5d02a2b..be44839 100644
--- a/print_pdf/print_pdf.pages.inc
+++ b/print_pdf/print_pdf.pages.inc
@@ -43,23 +43,27 @@ function print_pdf_controller() {
$print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']);
$print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']);
// And converted from private to public paths
+ switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
+ case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
+ case LANGUAGE_NEGOTIATION_PATH:
+ $lang = $language->language;
+ break;
+ default:
+ $lang = '';
+ break;
+ }
$file_downloads = variable_get('file_default_scheme', 'public');
if ($file_downloads == 'private') {
- switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
- case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
- case LANGUAGE_NEGOTIATION_PATH:
- $lang = $language->language;
- break;
- default:
- $lang = '';
- break;
- }
- $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files(/[^>]*?>)!is";
- $replacement = '$1file://' . realpath(file_directory_path()) . '$2';
- $print['content'] = preg_replace($pattern, $replacement, $print['content']);
- $print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
- $print['footer_message'] = preg_replace($pattern, $replacement, $print['footer_message']);
+ $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files/([^>]*?>)!is";
+ $replacement = '$1file://' . realpath(file_directory_path()) . '/$2';
}
+ else {
+ $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?([^>]*?>)!is";
+ $replacement = '$1file://'. realpath($_SERVER["DOCUMENT_ROOT"].base_path()) .'/$2';
+ }
+ $print['content'] = preg_replace($pattern, $replacement, $print['content']);
+ $print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
+ $print['footer_message'] = preg_replace($pattern, $replacement, $print['footer_message']);
// Send to printer option causes problems with PDF
$print['sendtoprinter'] = '';
@@ -290,7 +294,7 @@ function _print_pdf_tcpdf($print, $html, $filename) {
*/
function _print_pdf_wkhtmltopdf($print, $html, $filename) {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
- $print_pdf_paper_size = drupal_strtolower(variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT));
+ $print_pdf_paper_size = variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT);
$print_pdf_page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
$print_pdf_content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
$print_pdf_wkhtmltopdf_options = variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS);