Commit f76a10f2 authored by jcnventura's avatar jcnventura

Expand the advanced link options by default (too many users couldn't see it)...

Expand the advanced link options by default (too many users couldn't see it) and move the book link inside the fieldset
Fix #391790: display CCK fields (and labels) better in PDFs generated with TCPDF
Try to fix #414910 by using a smaller default weight
Fix #404052: allow node tabs pages to display the links for system pages
Fix #405564: display the content corner links above the content
Try to use other functions to convert from UTF-8 to ISO-8859-1 for the PDF generation with dompdf
Add the install files to the .info file
parent aafb7e2d
/* $Id$ */
.print-link {
/* Use these for links above the content */
text-align: left;
/* Use these for links in a corner of the content */
/*
float:left;
*/
}
.print_html, .print_mail, .print_pdf {
margin-left: 0;
margin-right: 1em;
}
......
/* $Id$ */
.print-link {
/* Use these for links above the content */
display: block;
text-align: right;
/* Use these for links in a corner of the content */
/*
position:relative;
bottom: 0.5em;
float:right;
*/
}
.print_html, .print_mail, .print_pdf {
margin-left: 1em;
}
......
......@@ -183,7 +183,7 @@ function print_html_settings() {
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['adv_link']['print_html_show_link'] = array(
......@@ -259,7 +259,7 @@ function print_html_settings() {
$form['settings']['adv_link']['print_html_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
$form['settings']['print_html_book_link'] = array(
$form['settings']['adv_link']['print_html_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT),
......
......@@ -6,3 +6,4 @@ package = "Printer, e-mail and PDF versions"
files[] = print.module
files[] = print.admin.inc
files[] = print.pages.inc
files[] = print.install
......@@ -48,7 +48,7 @@ define('PRINT_TYPE_URLLIST_DEFAULT', 1);
define('PRINT_ALLOW_NORMAL_LINK', 1);
define('PRINT_ALLOW_BOOK_LINK', 2);
define('PRINT_TYPE_FIELDS_WEIGHT', 50);
define('PRINT_TYPE_FIELDS_WEIGHT', 30);
/**
* Implementation of hook_perm().
......@@ -239,8 +239,7 @@ function print_help($path, $arg) {
}
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_html_link_pos['link']) && empty($print_html_link_pos['corner']))) {
if (($path !== 'node/%') && !(empty($print_html_link_pos['link']) && empty($print_html_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -295,14 +294,15 @@ function print_node_view($node, $teaser) {
}
// Insert content corner links
$node->content['print_links'] = array(
'#markup' => "<span class='print-link'></span>",
'#weight' => -101,
);
if (($teaser === FALSE) && !empty($print_html_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_insert_link(NULL, $node);
if ($link) {
$node->content['print_link'] = array(
'#markup' => "<span class='print-link'>$link</span>",
'#weight' => -101,
);
$node->content['print_links']['#markup'] = preg_replace('!</span>$!', $link . '</span>', $node->content['print_links']['#markup']);
}
}
}
......@@ -349,7 +349,7 @@ function print_form_alter(&$form, $form_state, $form_id) {
'#title' => t('Printer, e-mail and PDF versions'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => function_exists('cck_extra_field_weight') ? cck_extra_field_weight($form['type']['#value'], 'print') : PRINT_TYPE_FIELDS_WEIGHT,
'#weight' => (function_exists('cck_extra_field_weight') && isset($form['type'])) ? cck_extra_field_weight($form['type']['#value'], 'print') : PRINT_TYPE_FIELDS_WEIGHT,
);
$form['print']['label'] = array(
......
......@@ -32,7 +32,7 @@ function print_mail_settings() {
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['adv_link']['print_mail_show_link'] = array(
......@@ -108,7 +108,7 @@ function print_mail_settings() {
$form['settings']['adv_link']['print_mail_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
$form['settings']['print_mail_book_link'] = array(
$form['settings']['adv_link']['print_mail_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT),
......
......@@ -7,3 +7,4 @@ package = "Printer, e-mail and PDF versions"
files[] = print_mail.module
files[] = print_mail.inc
files[] = print_mail.admin.inc
files[] = print_mail.install
......@@ -158,10 +158,7 @@ function print_mail_node_view($node, $teaser) {
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_mail_insert_link(NULL, $node);
if ($link) {
$node->content['print_mail_link'] = array(
'#markup' => "<span class='print-link'>$link</span>",
'#weight' => -102,
);
$node->content['print_links']['#markup'] = preg_replace('!</span>$!', $link . '</span>', $node->content['print_links']['#markup']);
}
}
}
......@@ -171,8 +168,7 @@ function print_mail_node_view($node, $teaser) {
*/
function print_mail_help($path, $arg) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_mail_link_pos['link']) && empty($print_mail_link_pos['corner']))) {
if (($path !== 'node/%') && !(empty($print_mail_link_pos['link']) && empty($print_mail_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......
......@@ -44,7 +44,7 @@ function print_pdf_settings() {
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['adv_link']['print_pdf_show_link'] = array(
......@@ -120,7 +120,7 @@ function print_pdf_settings() {
$form['settings']['adv_link']['print_pdf_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
$form['settings']['print_pdf_book_link'] = array(
$form['settings']['adv_link']['print_pdf_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT),
......
......@@ -7,3 +7,4 @@ package = "Printer, e-mail and PDF versions"
files[] = print_pdf.module
files[] = print_pdf.admin.inc
files[] = print_pdf.pages.inc
files[] = print_pdf.install
......@@ -198,10 +198,7 @@ function print_pdf_node_view($node, $teaser) {
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_pdf_insert_link(NULL, $node);
if ($link) {
$node->content['print_pdf_link'] = array(
'#markup' => "<span class='print-link'>$link</span>",
'#weight' => -103,
);
$node->content['print_links']['#markup'] = preg_replace('!</span>$!', $link . '</span>', $node->content['print_links']['#markup']);
}
}
}
......@@ -211,8 +208,7 @@ function print_pdf_node_view($node, $teaser) {
*/
function print_pdf_help($path, $arg) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_pdf_link_pos['link']) && empty($print_pdf_link_pos['corner']))) {
if (($path !== 'node/%') && !(empty($print_pdf_link_pos['link']) && empty($print_pdf_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......
......@@ -135,11 +135,21 @@ function _print_pdf_dompdf($print, $html, $filename) {
// dompdf can't handle footers cleanly, so disable the following
// $html = theme('print_pdf_dompdf_footer', $html);
// Convert from UTF-8 to ISO-8859-1 and then to HTML entities
$all_entities = get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES);
$special_entities = get_html_translation_table(HTML_SPECIALCHARS, ENT_NOQUOTES);
$no_tags = array_diff($all_entities, $special_entities);
$html = strtr(utf8_decode($html), $no_tags);
// Convert from UTF-8 to ISO 8859-1 and then to HTML entities
if (function_exists('utf8_decode')) {
$html = utf8_decode($html);
}
// iconv fails silently when it encounters something that it doesn't know, so don't use it
// else if (function_exists('iconv')) {
// $html = iconv('UTF-8', 'ISO-8859-1', $html);
// }
else if (function_exists('mb_convert_encoding')) {
$html = mb_convert_encoding($html, 'ISO-8859-1', 'UTF-8');
}
else if (function_exists('recode_string')) {
$html = recode_string('UTF-8..ISO_8859-1', $html);
}
$html = htmlspecialchars_decode(htmlentities($html, ENT_NOQUOTES, 'ISO-8859-1'), ENT_NOQUOTES);
//must get rid of tbody (dompdf goes into recursion)
$html = preg_replace('!<tbody[^>]*?>|</tbody>!i', '', $html);
......@@ -349,9 +359,18 @@ function theme_print_pdf_tcpdf_content(&$pdf, &$html, $font) {
$pattern = '!(?:<div class="print-(?:logo|site_name|breadcrumb|footer)">.*?</div>|<hr class="print-hr" />)!si';
$matches[1] = preg_replace($pattern, '', $matches[1]);
// Make CCK fields look better
$matches[1] = preg_replace('!(<div class="field.*?>)\s*!sm', '$1', $matches[1]);
$matches[1] = preg_replace('!(<div class="field.*?>.*?</div>)\s*!sm', '$1', $matches[1]);
$matches[1] = preg_replace('!<div( class="field-label.*?>.*?)</div>!sm', '<strong$1</strong>', $matches[1]);
// Since TCPDF's writeHTML is so bad with <p>, do everything possible to make it look nice
$matches[1] = preg_replace('!(<p>|<p\s*/>|</p>)!i', '<br />', $matches[1]);
$matches[1] = str_replace(array('<div', 'div>'), array('<span', 'span><br />'), $matches[1]);
do {
$prev = $matches[1];
$matches[1] = preg_replace('!(</span>)<br />(\s*?</span><br />)!s', '$1$2', $matches[1]);
} while ($prev != $matches[1]);
$pdf->writeHTML($matches[1]);
......
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