Only in print-attachment: print-attachment.patch
diff -urp print/print_mail/print_mail.inc print-attachment/print_mail/print_mail.inc
--- print/print_mail/print_mail.inc 2009-10-03 12:52:10.000000000 -0400
+++ print-attachment/print_mail/print_mail.inc 2009-11-28 09:37:10.918375000 -0500
@@ -44,7 +44,8 @@ function print_mail_form($form_state) {
}
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
$title = _print_get_title($path);
-
+ $link = $GLOBALS['base_url'] . '/' . $path;
+
if (count($form_state['post']) == 0) {
$nodepath = drupal_get_normal_path($path);
db_query("UPDATE {print_mail_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
@@ -57,6 +58,8 @@ function print_mail_form($form_state) {
$form['path'] = array('#type' => 'value', '#value' => $path);
$form['cid'] = array('#type' => 'value', '#value' => $cid);
+ $form['link'] = array('#type' => 'value', '#value' => $link);
+ $form['title'] = array('#type' => 'value', '#value' => $title);
$form['fld_from_addr'] = array(
'#type' => 'textfield',
@@ -83,8 +86,19 @@ function print_mail_form($form_state) {
$form['fld_title'] = array(
'#type' => 'item',
'#title' => t('Page to be sent'),
- '#value' => l($title, $path, array('attributes' => array('title' => t('View page')))),
+ '#value' => l($title, $link, array('attributes' => array('title' => t('View page')))),
);
+ $form['fld_send_option'] = array (
+ '#type' => 'select',
+ '#title' => t('Send page as'),
+ '#default_value' => 'plain-attachment',
+ '#options' => array(
+ 'sendlink' => 'Link',
+ 'sendpage' => 'Inline HTML',
+ 'inline-attachment' => 'Inline HTML with Attachment',
+ 'plain-attachment' => 'Plain Text with Attachment',
+ ),
+ );
$form['txt_message'] = array(
'#type' => 'textarea',
'#title' => t('Your message'),
@@ -155,6 +169,7 @@ function theme_print_mail_form($form) {
case 'txt_to_addrs':
case 'fld_subject':
case 'fld_title':
+ case 'fld_send_option':
$tmp = str_replace('
' . l($params['title'], $params['link']);
+
+ // Send HTML-only version if MIME library not present
+ if (!include_once('Mail/mime.php')) {
+ $message['body'] = $sendlink_html;
+ $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
+ return;
+ }
+ case 'plain-attachment':
+ case 'inline-attachment':
+ // Include MIME library
+ include_once('Mail/mime.php');
+
+ // Configure new MIME object
+ $mime = new Mail_mime("\n");
+ $mime_params['html_encoding'] = '7bit';
+
+ // Pass message contents into MIME object
+ switch ($params['send_option']) {
+ case 'sendlink':
+ $mime->setTXTBody($sendlink_plain);
+ $mime->setHTMLBody($sendlink_html);
+ break;
+ case 'inline-attachment':
+ $mime->setHTMLBody($params['body']);
+ case 'plain-attachment':
+ $mime->setTXTBody($params['message']);
+ $mime->addAttachment($params['body'],'text/html','Attachment.html',false);
+ break;
+ }
+
+ // Store MIME message output in message array
+ $message['body'] = $mime->get($mime_params);
+ $message['headers'] = $mime->headers($message['headers']);
+
+ // Strip special characters from Content-Type header
+ // Required to prevent mime_header_encode() from disrupting Content-Type header
+ $message['headers']['Content-Type'] = preg_replace('/[^\x20-\x7E]/','', $message['headers']['Content-Type']);
+ break;
}
}