Commit ee8a10b8 authored by jcnventura's avatar jcnventura

Fix #288064: Large books sometimes resulted in blank PDFs

Fix #261338: Enable selection of none, theme or user-defined logo. Added also capability to upload logo directly from the settings form.
Fix PDF bug that prevented correct PDF generation introduced in the last patch.
Move the setting form elements back to the defined fieldsets.
parent 6f6bfb3e
This diff is collapsed.
......@@ -11,6 +11,7 @@
define('PRINT_PATH', 'print');
define('PRINT_LOGO_OPTIONS_DEFAULT', 1);
define('PRINT_LOGO_URL_DEFAULT', '');
define('PRINT_CSS_DEFAULT', '');
define('PRINT_URLS_DEFAULT', 1);
......
......@@ -132,6 +132,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
// print module settings
$print_css = variable_get('print_css', PRINT_CSS_DEFAULT);
$print_urls = variable_get('print_urls', PRINT_URLS_DEFAULT);
$print_logo_options = variable_get('print_logo_options', PRINT_LOGO_OPTIONS_DEFAULT);
$print_logo_url = variable_get('print_logo_url', PRINT_LOGO_URL_DEFAULT);
$print_html_sendtoprinter = variable_get('print_html_sendtoprinter', PRINT_HTML_SENDTOPRINTER_DEFAULT);
$print_sourceurl_enabled = variable_get('print_sourceurl_enabled', PRINT_SOURCEURL_ENABLED_DEFAULT);
......@@ -187,7 +188,17 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$print['sendtoprinter'] = $print_html_sendtoprinter ? ' onload="window.print();"' : '';
$logo_url = !empty($print_logo_url) ? strip_tags($print_logo_url) : theme_get_setting('logo');
switch ($print_logo_options) {
case 0: // none
$logo_url = 0;
break;
case 1: // theme's
$logo_url = theme_get_setting('logo');
break;
case 2: // user-specifed
$logo_url = strip_tags($print_logo_url);
break;
}
$print['logo'] = $logo_url ? "<img class='print-logo' src='$logo_url' alt='' />\n" : '';
$published_site = variable_get('site_name', 0);
......
......@@ -102,7 +102,6 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
$pdf->SetKeywords($keys);
$pdf->setPDFVersion('1.6');
$pdf->setUserRights();
// set header data
$pdf->SetHeaderData('', 0, $print['title'], strip_tags($print['site_name']));
......@@ -132,7 +131,7 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$pdf->AddPage();
preg_match('!<body>(.*)</body>!sim', $html, $matches);
$matches[1] = preg_replace('/.*?(<[^<]*?print-content.*?>)/sim', '$1', $matches[1]);
$matches[1] = strstr($matches[1], '<div class="print-content">');
$pdf->SetFont($font_name, 'B', $font_size * 1.3);
$pdf->writeHTML($print['title']);
......
......@@ -19,7 +19,7 @@ function print_mail_settings() {
'#type' => 'fieldset',
);
$form['print_mail_link_pos'] = array(
$form['print_mail_settings']['print_mail_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('Send by e-mail link'),
'#default_value' => variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT)),
......@@ -27,7 +27,7 @@ function print_mail_settings() {
'#description' => t('Choose the location of the link(s) to the send by e-mail page. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still send a node by e-mail by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTMAIL_PATH)),
);
$form['print_mail_show_link'] = array(
$form['print_mail_settings']['print_mail_show_link'] = array(
'#type' => 'radios',
'#title' => t('Link style'),
'#default_value' => variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT),
......@@ -35,21 +35,21 @@ function print_mail_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['print_mail_node_link_visibility'] = array(
$form['print_mail_settings']['print_mail_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_mail_node_link_pages'] = array(
$form['print_mail_settings']['print_mail_node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_mail_link_class'] = array(
$form['print_mail_settings']['print_mail_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => variable_get('print_mail_link_class', PRINT_MAIL_LINK_CLASS_DEFAULT),
......@@ -58,14 +58,14 @@ function print_mail_settings() {
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['print_mail_sys_link_visibility'] = array(
$form['print_mail_settings']['print_mail_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => variable_get('print_mail_sys_link_visibility', PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_mail_sys_link_pages'] = array(
$form['print_mail_settings']['print_mail_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
......@@ -73,21 +73,21 @@ function print_mail_settings() {
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_mail_book_link'] = array(
$form['print_mail_settings']['print_mail_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link in book nodes'),
'#default_value' => variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT),
'#description' => t('Activate this to add a send by e-mail link in book nodes. Requires the (core) book module.'),
);
$form['print_mail_teaser_default'] = array(
$form['print_mail_settings']['print_mail_teaser_default'] = array(
'#type' => 'checkbox',
'#title' => t('Send only the teaser'),
'#default_value' => variable_get('print_mail_teaser_default', PRINT_MAIL_TEASER_DEFAULT_DEFAULT),
'#description' => t("If selected, the default choice will be to send only the node's teaser instead of the full content."),
);
$form['print_mail_teaser_choice'] = array(
$form['print_mail_settings']['print_mail_teaser_choice'] = array(
'#type' => 'checkbox',
'#title' => t('Enable teaser/full mode choice'),
'#default_value' => variable_get('print_mail_teaser_choice', PRINT_MAIL_TEASER_CHOICE_DEFAULT),
......
......@@ -23,7 +23,7 @@ function print_pdf_settings() {
'#type' => 'fieldset',
);
$form['print_pdf_pdf_tool'] = array(
$form['print_pdf_settings']['print_pdf_pdf_tool'] = array(
'#type' => 'radios',
'#title' => t('PDF generation tool'),
'#options' => $pdf_tools,
......@@ -32,7 +32,7 @@ function print_pdf_settings() {
'#required' => TRUE,
);
$form['print_pdf_link_pos'] = array(
$form['print_pdf_settings']['print_pdf_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('PDF version link'),
'#default_value' => variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT)),
......@@ -40,7 +40,7 @@ function print_pdf_settings() {
'#description' => t('Choose the location of the link(s) to the PDF version. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still view the PDF version of a node by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTPDF_PATH)),
);
$form['print_pdf_show_link'] = array(
$form['print_pdf_settings']['print_pdf_show_link'] = array(
'#type' => 'radios',
'#title' => t('Link style'),
'#default_value' => variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT),
......@@ -48,21 +48,21 @@ function print_pdf_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['print_pdf_node_link_visibility'] = array(
$form['print_pdf_settings']['print_pdf_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_pdf_node_link_pages'] = array(
$form['print_pdf_settings']['print_pdf_node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_pdf_link_class'] = array(
$form['print_pdf_settings']['print_pdf_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => variable_get('print_pdf_link_class', PRINT_PDF_LINK_CLASS_DEFAULT),
......@@ -71,14 +71,14 @@ function print_pdf_settings() {
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['print_pdf_sys_link_visibility'] = array(
$form['print_pdf_settings']['print_pdf_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => variable_get('print_pdf_sys_link_visibility', PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_pdf_sys_link_pages'] = array(
$form['print_pdf_settings']['print_pdf_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
......@@ -86,14 +86,14 @@ function print_pdf_settings() {
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_pdf_book_link'] = array(
$form['print_pdf_settings']['print_pdf_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link in book nodes'),
'#default_value' => variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT),
'#description' => t('Activate this to add a PDF version link in book nodes. Requires the (core) book module.'),
);
$form['print_pdf_content_disposition'] = array(
$form['print_pdf_settings']['print_pdf_content_disposition'] = array(
'#type' => 'radios',
'#title' => t('Open PDF in'),
'#options' => array(t('Same browser window'), t('New browser window'), t('Save dialog')),
......@@ -101,7 +101,7 @@ function print_pdf_settings() {
'#description' => t("Select the desired method for opening the PDF in the user's browser."),
);
$form['print_pdf_paper_size'] = array(
$form['print_pdf_settings']['print_pdf_paper_size'] = array(
'#type' => 'select',
'#title' => t('Paper size'),
'#options' => array('4A0' => '4A0', '2A0' => '2A0', 'A0' => 'A0',
......@@ -123,7 +123,7 @@ function print_pdf_settings() {
'#description' => t('Choose the paper size of the generated PDF.'),
);
$form['print_pdf_page_orientation'] = array(
$form['print_pdf_settings']['print_pdf_page_orientation'] = array(
'#type' => 'select',
'#title' => t('Page orientation'),
'#options' => array('portrait' => t('Portrait'), 'landscape' => t('Landscape')),
......@@ -132,7 +132,7 @@ function print_pdf_settings() {
);
}
else {
$form['print_pdf_settings'] = array(
$form['print_pdf_settings']['print_pdf_settings'] = array(
'#type' => 'markup',
'#value' => '<p>'. t("No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") .'</p>',
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment