Commit d54079c6 authored by jcnventura's avatar jcnventura

Better fix for #371388: handle tbody tags with attributes

Fix #375892: Don't validate mail send form when pressing cancel
Improved Turkish translation by drupalhizmetleri
Document print_[format].tpl better in the README.txt
parent d0729d47
......@@ -19,7 +19,9 @@ queue at Drupal.org.
dompdf support:
The dompdf tool produces results that are more faithful to the HTML
printer-friendly page.
printer-friendly page. Unicode is not supported (only ISO-8859-1).
This tool is not supported and there are several known bugs that result
from its incomplete implementation.
1. Download dompdf from http://sourceforge.net/projects/dompdf/
2. Extract the contents of the downloaded package into the print module
......@@ -34,7 +36,9 @@ dompdf support:
TCPDF support:
TCPDF seems to be more actively developed than dompdf, but it's support
for CSS is considerably worse. This module requires TCPDF >= 4.0.000.
for CSS is considerably worse. Unicode is supported (use of Unicode fonts
result in HUGE files). Page header and footer are supported. This module
requires TCPDF >= 4.0.000.
1. Download TCPDF from http://sourceforge.net/projects/tcpdf/
2. Extract the contents of the downloaded package into the print module
......
......@@ -14,6 +14,11 @@ A link is inserted in the each node (configurable in the content type
settings), that opens a version of the page with no sidebars, search boxes,
navigation pages, etc.
INSTALLATION
------------
Follow the instructions in the provided INSTALL.txt file.
CONFIGURATION
-------------
......@@ -54,6 +59,9 @@ print.tpl.php or the css/print.css files.
7. print.tpl.php in the theme directory
8. print.tpl.php in the module directory (supplied by the module)
format is either html, mail or pdf, and type is Drupal's node type (e.g.
page, story, etc.)
API
---
......
......@@ -162,6 +162,9 @@ function theme_print_mail_form($form) {
* @ingroup forms
*/
function print_mail_form_validate($form, &$form_state) {
if (array_key_exists('cancel', $form['#post'])) {
return;
}
$from_addr = trim($form_state['values']['fld_from_addr']);
$test = user_validate_mail($from_addr);
if ($test) {
......@@ -219,51 +222,53 @@ function print_mail_form_validate($form, &$form_state) {
* @ingroup forms
*/
function print_mail_form_submit($form, &$form_state) {
if (!empty($form_state['values']['fld_from_name'])) {
$from = '"'. $form_state['values']['fld_from_name'] .'" <'. $form_state['values']['fld_from_addr'] .'>';
}
else {
$from = $form_state['values']['fld_from_addr'];
}
$to = $form_state['values']['txt_to_addrs'];
$cid = isset($form_state['values']['cid']) ? $form_state['values']['cid'] : NULL;
$print_mail_text_message = variable_get('print_mail_text_message', t('Message from sender'));
$sender_message = $print_mail_text_message .':<br /><br /><em>'. nl2br($form_state['values']['txt_message']) .'</em>';
$print = print_controller($form_state['values']['path'], $cid, PRINT_MAIL_FORMAT, $form_state['values']['chk_teaser'], $sender_message);
// Spaces in img URLs must be replaced with %20
$pattern = '!<(img\s[^>]*?)>!is';
$print['content'] = preg_replace_callback($pattern, '_print_mail_encode_urls', $print['content']);
if ($print !== FALSE) {
$params = array();
$params['subject'] = $form_state['values']['fld_subject'];
$node = $print['node'];
ob_start();
include_once(DRUPAL_ROOT .'/'. _print_get_template(PRINT_MAIL_FORMAT, $print['type']));
$params['body'] = ob_get_contents();
ob_end_clean();
$ret = drupal_mail('print_mail', 'sendpage', $to, language_default(), $params, $from, TRUE);
if ($ret['result']) {
flood_register_event('print_mail');
watchdog('print_mail', '%name [%from] sent %page to [%to]', array('%name' => $form_state['values']['fld_from_name'], '%from' => $form_state['values']['fld_from_addr'], '%page' => $form_state['values']['path'], '%to' => $to));
$site_name = variable_get('site_name', t('us'));
$print_mail_text_confirmation = variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.'));
drupal_set_message(t($print_mail_text_confirmation, array('!site' => $site_name)));
$nodepath = drupal_get_normal_path($form_state['values']['path']);
db_update('print_mail_page_counter')
->fields(array(
'sentcount' => 1,
'sent_timestamp' => REQUEST_TIME,
))
->condition('path', $nodepath, '=')
->expression('sentcount', 'sentcount + :inc', array(':inc' => count(split(',', $to))))
->execute();
if (!array_key_exists('cancel', $form_state['values'])) {
if (!empty($form_state['values']['fld_from_name'])) {
$from = '"'. $form_state['values']['fld_from_name'] .'" <'. $form_state['values']['fld_from_addr'] .'>';
}
else {
$from = $form_state['values']['fld_from_addr'];
}
$to = $form_state['values']['txt_to_addrs'];
$cid = isset($form_state['values']['cid']) ? $form_state['values']['cid'] : NULL;
$print_mail_text_message = variable_get('print_mail_text_message', t('Message from sender'));
$sender_message = $print_mail_text_message .':<br /><br /><em>'. nl2br($form_state['values']['txt_message']) .'</em>';
$print = print_controller($form_state['values']['path'], $cid, PRINT_MAIL_FORMAT, $form_state['values']['chk_teaser'], $sender_message);
// Spaces in img URLs must be replaced with %20
$pattern = '!<(img\s[^>]*?)>!is';
$print['content'] = preg_replace_callback($pattern, '_print_mail_encode_urls', $print['content']);
if ($print !== FALSE) {
$params = array();
$params['subject'] = $form_state['values']['fld_subject'];
$node = $print['node'];
ob_start();
include_once(DRUPAL_ROOT .'/'. _print_get_template(PRINT_MAIL_FORMAT, $print['type']));
$params['body'] = ob_get_contents();
ob_end_clean();
$ret = drupal_mail('print_mail', 'sendpage', $to, language_default(), $params, $from, TRUE);
if ($ret['result']) {
flood_register_event('print_mail');
watchdog('print_mail', '%name [%from] sent %page to [%to]', array('%name' => $form_state['values']['fld_from_name'], '%from' => $form_state['values']['fld_from_addr'], '%page' => $form_state['values']['path'], '%to' => $to));
$site_name = variable_get('site_name', t('us'));
$print_mail_text_confirmation = variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.'));
drupal_set_message(t($print_mail_text_confirmation, array('!site' => $site_name)));
$nodepath = drupal_get_normal_path($form_state['values']['path']);
db_update('print_mail_page_counter')
->fields(array(
'sentcount' => 1,
'sent_timestamp' => REQUEST_TIME,
))
->condition('path', $nodepath, '=')
->expression('sentcount', 'sentcount + :inc', array(':inc' => count(split(',', $to))))
->execute();
}
}
}
......
......@@ -129,7 +129,7 @@ function _print_pdf_dompdf($print, $html, $filename) {
$html = strtr(utf8_decode($html), $no_tags);
//must get rid of tbody (dompdf goes into recursion)
$html = preg_replace('!<tbody>|</tbody>!', '', $html);
$html = preg_replace('!<tbody[^>]*?>|</tbody>!i', '', $html);
$dompdf->load_html($html);
......
This diff is collapsed.
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