Commit 7d62e7c4 authored by jcnventura's avatar jcnventura

Re-engineer the variables to no longer use the #tree hierarchy

parent 20aa7020
This diff is collapsed.
......@@ -10,7 +10,8 @@
* Implementation of hook_install().
*/
function print_install() {
drupal_set_message(t("Printer-friendly Page settings are available under !link",
$t = get_t();
drupal_set_message($t('Printer-friendly Page settings are available under !link',
array( '!link' => l('Administer > Site configuration > Printer-friendly Pages ', 'admin/settings/print' ) )
));
}
......@@ -20,12 +21,77 @@ function print_install() {
*/
function print_uninstall() {
variable_del('print_settings');
variable_del('print_display_comment');
variable_del('print_sourceurl_settings');
variable_del('print_html_settings');
variable_del('print_robot_settings');
variable_del('print_logo_url');
variable_del('print_css');
variable_del('print_urls');
variable_del('print_comments');
variable_del('print_newwindow');
variable_del('print_sourceurl_enabled');
variable_del('print_sourceurl_date');
variable_del('print_sourceurl_forcenode');
variable_del('print_html_show_link');
variable_del('print_html_node_link_visibility');
variable_del('print_html_node_link_pages');
variable_del('print_html_link_class');
variable_del('print_html_sys_link_visibility');
variable_del('print_html_sys_link_pages');
variable_del('print_html_book_link');
variable_del('print_html_new_window');
variable_del('print_html_sendtoprinter');
variable_del('print_robots_noindex');
variable_del('print_robots_nofollow');
variable_del('print_robots_noarchive');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
while ($variable = db_fetch_object($settings)) {
variable_del($variable->name);
}
}
/**
* Update to version 6.x-1.0
*/
function print_update_6000() {
global $conf;
$ret = array();
if (isset($conf['print_settings'])) {
$print_settings = variable_get('print_settings', '');
variable_set('print_logo_url', $print_settings['logo_url']);
variable_set('print_css', $print_settings['css']);
variable_set('print_urls', $print_settings['urls']);
variable_set('print_comments', $print_settings['comments']);
variable_set('print_newwindow', $print_settings['newwindow']);
variable_del('print_settings');
}
if (isset($conf['print_sourceurl_settings'])) {
$print_sourceurl_settings = variable_get('print_sourceurl_settings', '');
variable_set('print_sourceurl_enabled', $print_sourceurl_settings['enabled']);
variable_set('print_sourceurl_date', $print_sourceurl_settings['date']);
variable_set('print_sourceurl_forcenode', $print_sourceurl_settings['forcenode']);
variable_del('print_sourceurl_settings');
}
if (isset($conf['print_html_settings'])) {
$print_html_settings = variable_get('print_html_settings', '');
variable_set('print_html_show_link', $print_html_settings['show_link']);
variable_set('print_html_node_link_visibility', $print_html_settings['node_link_visibility']);
variable_set('print_html_node_link_pages', $print_html_settings['node_link_pages']);
variable_set('print_html_link_class', $print_html_settings['link_class']);
variable_set('print_html_sys_link_visibility', $print_html_settings['sys_link_visibility']);
variable_set('print_html_sys_link_pages', $print_html_settings['sys_link_pages']);
variable_set('print_html_book_link', $print_html_settings['book_link']);
variable_set('print_html_new_window', $print_html_settings['new_window']);
variable_set('print_html_sendtoprinter', $print_html_settings['sendtoprinter']);
variable_del('print_html_settings');
}
if (isset($conf['print_robot_settings'])) {
$print_robot_settings = variable_get('print_robot_settings', '');
variable_set('print_robots_noindex', $print_robot_settings['noindex']);
variable_set('print_robots_nofollow', $print_robot_settings['nofollow']);
variable_set('print_robots_noarchive', $print_robot_settings['noarchive']);
variable_del('print_robot_settings');
}
return $ret;
}
This diff is collapsed.
This diff is collapsed.
......@@ -17,26 +17,26 @@ function print_pdf_controller() {
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? $_GET['comment'] : NULL;
$print_pdf_settings = variable_get('print_pdf_settings', print_pdf_settings_default());
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$print = print_controller($path, $cid);
// Img elements must be set to absolute
$pattern = "@<(img\s[^>]*?)>@is";
$print["content"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["content"]);
$print["logo"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["logo"]);
$print["footer_message"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["footer_message"]);
$pattern = '!<(img\s[^>]*?)>!is';
$print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']);
$print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']);
$print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']);
$node = $print["node"];
$node = $print['node'];
ob_start();
include_once(_print_get_template("pdf", $print["type"]));
include_once(_print_get_template('pdf', $print['type']));
$html = ob_get_contents();
ob_end_clean();
if (basename($print_pdf_settings['pdf_tool']) == "dompdf_config.inc.php") {
_print_pdf_dompdf($print, $html, $path .".pdf");
if (basename($print_pdf_pdf_tool) == 'dompdf_config.inc.php') {
_print_pdf_dompdf($print, $html, $path .'.pdf');
}
elseif (basename($print_pdf_settings['pdf_tool']) == "tcpdf.php") {
_print_pdf_tcpdf($print, $html, $path .".pdf");
elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') {
_print_pdf_tcpdf($print, $html, $path .'.pdf');
}
else {
return drupal_not_found();
......@@ -44,8 +44,11 @@ function print_pdf_controller() {
}
function _print_pdf_dompdf($print, $html, $filename) {
$print_pdf_settings = variable_get('print_pdf_settings', print_pdf_settings_default());
require_once($print_pdf_settings['pdf_tool']);
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_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);
require_once($print_pdf_pdf_tool);
$url_array = parse_url($print['url']);
......@@ -56,49 +59,52 @@ function _print_pdf_dompdf($print, $html, $filename) {
$dompdf = new DOMPDF();
$dompdf->set_base_path($path);
$dompdf->set_host($host);
$dompdf->set_paper(strtolower($print_pdf_settings['paper_size']), $print_pdf_settings['page_orientation']);
$dompdf->set_paper(strtolower($print_pdf_paper_size), $print_pdf_page_orientation);
$dompdf->set_protocol($protocol);
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream($filename, array("Attachment" => ($print_pdf_settings['content_disposition'] == 2)));
$dompdf->stream($filename, array('Attachment' => ($print_pdf_content_disposition == 2)));
}
function _print_pdf_tcpdf($print, $html, $filename) {
global $base_url;
$print_pdf_settings = variable_get('print_pdf_settings', print_pdf_settings_default());
define("K_TCPDF_EXTERNAL_CONFIG", TRUE);
define("K_PATH_MAIN", realpath(dirname($print_pdf_settings['pdf_tool'])) ."/");
define("K_PATH_URL", $base_url ."/". dirname($print_pdf_settings['pdf_tool']) ."/");
define("K_PATH_FONTS", K_PATH_MAIN ."fonts/");
define("K_PATH_CACHE", K_PATH_MAIN ."cache/");
define("K_PATH_IMAGES", K_PATH_MAIN ."images/");
define("K_BLANK_IMAGE", K_PATH_IMAGES ."_blank.png");
define("K_CELL_HEIGHT_RATIO", 1.25);
define("K_SMALL_RATIO", 2/3);
require_once($print_pdf_settings['pdf_tool']);
$font_name = "dejavusans";
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_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);
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
define('K_PATH_MAIN', realpath(dirname($print_pdf_pdf_tool)) .'/');
define('K_PATH_URL', $base_url .'/'. dirname($print_pdf_pdf_tool) .'/');
define('K_PATH_FONTS', K_PATH_MAIN .'fonts/');
define('K_PATH_CACHE', K_PATH_MAIN .'cache/');
define('K_PATH_IMAGES', K_PATH_MAIN .'images/');
define('K_BLANK_IMAGE', K_PATH_IMAGES .'_blank.png');
define('K_CELL_HEIGHT_RATIO', 1.25);
define('K_SMALL_RATIO', 2/3);
require_once($print_pdf_pdf_tool);
$font_name = 'dejavusans';
$font_size = 10;
$orientation = strtoupper($print_pdf_settings['page_orientation']{0});
$orientation = strtoupper($print_pdf_page_orientation{0});
// create new PDF document
$pdf = new TCPDF($orientation , "mm", $print_pdf_settings['paper_size'], TRUE);
$pdf = new TCPDF($orientation , 'mm', $print_pdf_paper_size, TRUE);
// set document information
$pdf->SetAuthor(strip_tags($print["submitted"]));
$pdf->SetCreator(variable_get("site_name", "Drupal"));
$pdf->SetTitle($print["title"]);
$keys = implode(" ", explode("\n", trim(strip_tags($print["taxonomy"]))));
$pdf->SetAuthor(strip_tags($print['submitted']));
$pdf->SetCreator(variable_get('site_name', 'Drupal'));
$pdf->SetTitle($print['title']);
$keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
$pdf->SetKeywords($keys);
$pdf->setPDFVersion("1.6");
$pdf->setPDFVersion('1.6');
// set header data
$pdf->SetHeaderData("", 0, $print["title"], strip_tags($print["site_name"]));
$pdf->SetHeaderData('', 0, $print['title'], strip_tags($print['site_name']));
// set header and footer fonts
$pdf->setHeaderFont(Array($font_name, '', $font_size));
......@@ -121,24 +127,24 @@ function _print_pdf_tcpdf($print, $html, $filename) {
// add a page
$pdf->AddPage();
preg_match("/<body>(.*)<\/body>/sim", $html, $matches);
$matches[1] = preg_replace("/.*?(<[^<]*?print-content.*?>)/sim", "$1", $matches[1]);
preg_match('!<body>(.*)</body>!sim', $html, $matches);
$matches[1] = preg_replace('/.*?(<[^<]*?print-content.*?>)/sim', '$1', $matches[1]);
$pdf->SetFont($font_name, 'B', $font_size * 1.3);
$pdf->writeHTML($print["title"]);
$pdf->writeHTML($print['title']);
if ($print["submitted"]) {
if ($print['submitted']) {
$pdf->Ln(2);
$pdf->SetFont($font_name, 'B', $font_size);
$pdf->writeHTML($print["submitted"]);
$pdf->writeHTML($print['submitted']);
$pdf->SetFont($font_name, '', $font_size);
$pdf->writeHTML($print["created"]);
$pdf->writeHTML($print['created']);
}
$pdf->SetFont($font_name, '', $font_size);
$pdf->writeHTML($matches[1]);
//Close and output PDF document
$output_dest = ($print_pdf_settings['content_disposition'] == 2) ? 'D' : 'I';
$output_dest = ($print_pdf_content_disposition == 2) ? 'D' : 'I';
$pdf->Output($filename, $output_dest);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $print["language"] ?>" xml:lang="<?php print $print["language"] ?>">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $print['language'] ?>" xml:lang="<?php print $print['language'] ?>">
<head>
<title><?php print $print["title"] ?></title>
<?php print $print["head"] ?>
<?php print $print["scripts"] ?>
<?php print $print["robots_meta"] ?>
<?php print $print["base_href"] ?>
<?php print $print["favicon"] ?>
<?php print $print["css"] ?>
<title><?php print $print['title'] ?></title>
<?php print $print['head'] ?>
<?php print $print['scripts'] ?>
<?php print $print['robots_meta'] ?>
<?php print $print['base_href'] ?>
<?php print $print['favicon'] ?>
<?php print $print['css'] ?>
</head>
<body<?php print $print["sendtoprinter"] ?>>
<?php if (!empty($print["message"])) print '<div class="print-message">'. $print["message"] .'</div><p />' ?>
<div><?php print $print["logo"] ?></div>
<div class="print-site_name"><?php print $print["site_name"] ?></div>
<body<?php print $print['sendtoprinter'] ?>>
<?php if (!empty($print['message'])) print '<div class="print-message">'. $print['message'] .'</div><p />' ?>
<div><?php print $print['logo'] ?></div>
<div class="print-site_name"><?php print $print['site_name'] ?></div>
<p />
<div class="print-breadcrumb"><?php print $print["breadcrumb"] ?></div>
<div class="print-breadcrumb"><?php print $print['breadcrumb'] ?></div>
<hr class="print-hr" />
<h1 class="print-title"><?php print $print["title"] ?></h1>
<div class="print-submitted"><?php print $print["submitted"] ?></div>
<div class="print-created"><?php print $print["created"] ?></div>
<h1 class="print-title"><?php print $print['title'] ?></h1>
<div class="print-submitted"><?php print $print['submitted'] ?></div>
<div class="print-created"><?php print $print['created'] ?></div>
<p />
<div class="print-content"><?php print $print["content"] ?></div>
<div class="print-taxonomy"><?php print $print["taxonomy"] ?></div>
<div class="print-footer"><?php print $print["footer_message"] ?></div>
<div class="print-content"><?php print $print['content'] ?></div>
<div class="print-taxonomy"><?php print $print['taxonomy'] ?></div>
<div class="print-footer"><?php print $print['footer_message'] ?></div>
<hr class="print-hr" />
<div class="print-source_url"><?php print $print["source_url"] ?></div>
<div class="print-links"><?php print $print["pfp_links"] ?></div>
<div class="print-source_url"><?php print $print['source_url'] ?></div>
<div class="print-links"><?php print $print['pfp_links'] ?></div>
</body>
</html>
......@@ -15,77 +15,74 @@
* @ingroup forms
*/
function print_mail_settings() {
$print_mail_settings = variable_get('print_mail_settings', print_mail_settings_default());
$form['print_mail_settings'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
);
$form['print_mail_settings']['show_link'] = array(
$form['print_mail_show_link'] = array(
'#type' => 'radios',
'#title' => t('Send by e-mail link'),
'#default_value' => $print_mail_settings['show_link'],
'#options' => array(t("None (Disabled)"), t("Text only"), t("Icon only"), t("Icon and Text")),
'#description' => t("Enable or disable the send by e-mail link for each node. Even if the link is disabled, you can still send a node by e-mail by going to printmail/nid where nid is the numeric id of the node."),
'#default_value' => variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT),
'#options' => array(t('None (Disabled)'), t('Text only'), t('Icon only'), t('Icon and Text')),
'#description' => t('Enable or disable the send by e-mail link for each node. Even if the link is disabled, you can still send a node by e-mail by going to printmail/nid where nid is the numeric id of the node.'),
);
$form['print_mail_settings']['node_link_visibility'] = array(
$form['print_mail_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => $print_mail_settings['node_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_settings']['node_link_pages'] = array(
$form['print_mail_node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => $print_mail_settings['node_link_pages'],
'#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_settings']['link_class'] = array(
$form['print_mail_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => $print_mail_settings['link_class'],
'#default_value' => variable_get('print_mail_link_class', PRINT_MAIL_LINK_CLASS_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
'#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_settings']['sys_link_visibility'] = array(
$form['print_mail_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => $print_mail_settings['sys_link_visibility'],
'#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_settings']['sys_link_pages'] = array(
$form['print_mail_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => $print_mail_settings['sys_link_pages'],
'#default_value' => variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t("Setting this option will add a send by-email link on pages created by Drupal or the enabled modules.") .'<br />'.
'#description' => t('Setting this option will add a send by-email link on pages created by Drupal or the enabled modules.') .'<br />'.
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_settings']['book_link'] = array(
$form['print_mail_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link in book nodes'),
'#default_value' => $print_mail_settings['book_link'],
'#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_settings']['teaser_default'] = array(
$form['print_mail_teaser_default'] = array(
'#type' => 'checkbox',
'#title' => t('Send only the teaser'),
'#default_value' => $print_mail_settings['teaser_default'],
'#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_settings']['teaser_choice'] = array(
$form['print_mail_teaser_choice'] = array(
'#type' => 'checkbox',
'#title' => t('Enable teaser/full mode choice'),
'#default_value' => $print_mail_settings['teaser_choice'],
'#default_value' => variable_get('print_mail_teaser_choice', PRINT_MAIL_TEASER_CHOICE_DEFAULT),
'#description' => t('If checked, the user will be able to choose between sending the full content or only the teaser at send time.'),
);
......
......@@ -18,13 +18,14 @@ require_once(drupal_get_path('module', 'print') .'/print.pages.inc');
*/
function print_mail_form($form_state) {
global $user;
$print_mail_settings = variable_get('print_mail_settings', print_mail_settings_default());
$print_mail_teaser_default = variable_get('print_mail_teaser_default', PRINT_MAIL_TEASER_DEFAULT_DEFAULT);
$print_mail_teaser_choice = variable_get('print_mail_teaser_choice', PRINT_MAIL_TEASER_CHOICE_DEFAULT);
$form = array();
// Remove the printmail/ prefix
$path = substr($_GET['q'], strpos($_GET['q'], '/')+1);
if (is_numeric($path)) {
$path = "node/". $path;
$path = 'node/'. $path;
}
$cid = isset($_GET['comment']) ? $_GET['comment'] : NULL;
$form['path'] = array('#type' => 'value', '#value' => $path);
......@@ -58,15 +59,15 @@ function print_mail_form($form_state) {
'#rows' => 6,
);
if ($print_mail_settings['teaser_choice']) {
if ($print_mail_teaser_choice) {
$form['chk_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Send only the teaser'),
'#default_value' => $print_mail_settings['teaser_default'],
'#default_value' => $print_mail_teaser_default,
);
}
else {
$form['chk_teaser'] = array('#type' => 'value', '#value' => $print_mail_settings['teaser_default']);
$form['chk_teaser'] = array('#type' => 'value', '#value' => $print_mail_teaser_default);
}
$form['btn_submit'] = array(
......@@ -142,7 +143,7 @@ function print_mail_form_validate($form, &$form_state) {
if (preg_match('/(.*?) <(.*)>/s', $address, $matches)) {
// Address is of the type User Name <user@domain.tld>
$test = user_validate_mail($matches[2]);
$to_array[$key] = trim($matches[1]) ." <". $matches[2] .">";
$to_array[$key] = trim($matches[1]) .' <'. $matches[2] .'>';
}
else {
// Address must be user@domain.tld
......@@ -155,18 +156,18 @@ function print_mail_form_validate($form, &$form_state) {
// In all fields, prevent insertion of custom headers
foreach ($form_state['values'] as $key => $string) {
if ( (substr($key, 0, 4) == "fld_") && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE)) ) {
if ( (substr($key, 0, 4) == 'fld_') && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE)) ) {
form_set_error($key, 'Found invalid character');
}
}
$subject = trim($form_state['values']['fld_subject']);
if (empty($subject)) {
form_set_error('fld_subject', t("You must enter a subject."));
form_set_error('fld_subject', t('You must enter a subject.'));
}
$message = trim($form_state['values']['txt_message']);
if (empty($message)) {
form_set_error('txt_message', t("You must enter a message."));
form_set_error('txt_message', t('You must enter a message.'));
}
$form_state['values']['fld_from_addr'] = $from_addr;
......@@ -185,7 +186,7 @@ function print_mail_form_validate($form, &$form_state) {
function print_mail_form_submit($form, &$form_state) {
global $language;
$from = $form_state['values']['fld_from_name'] ." <". $form_state['values']['fld_from_addr'] .">";
$from = $form_state['values']['fld_from_name'] .' <'. $form_state['values']['fld_from_addr'] .'>';
$to = $form_state['values']['txt_to_addrs'];
$params = array();
$params['subject'] = $form_state['values']['fld_subject'];
......@@ -213,14 +214,14 @@ function print_mail_mail($key, &$message, $params) {
$print = print_controller($params['path'], $params['cid'], $params['teaser'], $sender_message);
// Img elements must be set to absolute
// $pattern = "@<(img\s[^>]*?)>@is";
// $print["content"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["content"]);
// $print["logo"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["logo"]);
// $print["footer_message"] = preg_replace_callback($pattern, "_print_rewrite_urls", $print["footer_message"]);
// $pattern = '!<(img\s[^>]*?)>!is';
// $print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']);
// $print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']);
// $print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']);
$node = $print["node"];
$node = $print['node'];
ob_start();
include_once(_print_get_template("mail", $print["type"]));
include_once(_print_get_template('mail', $print['type']));
$html = ob_get_contents();
ob_end_clean();
......
......@@ -11,8 +11,40 @@
*/
function print_mail_uninstall() {
variable_del('print_mail_settings');
variable_del('print_mail_show_link');
variable_del('print_mail_node_link_visibility');
variable_del('print_mail_node_link_pages');
variable_del('print_mail_link_class');
variable_del('print_mail_sys_link_visibility');
variable_del('print_mail_sys_link_pages');
variable_del('print_mail_book_link');
variable_del('print_mail_teaser_default');
variable_del('print_mail_teaser_choice');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
while ($variable = db_fetch_object($settings)) {
variable_del($variable->name);
}
}
/**
* Update to version 6.x-1.0
*/
function print_mail_update_6000() {
global $conf;
$ret = array();
if (isset($conf['print_mail_settings'])) {
$print_mail_settings = variable_get('print_mail_settings', '');
variable_set('print_mail_show_link', $print_mail_settings['show_link']);
variable_set('print_mail_node_link_visibility', $print_mail_settings['node_link_visibility']);
variable_set('print_mail_node_link_pages', $print_mail_settings['node_link_pages']);
variable_set('print_mail_link_class', $print_mail_settings['link_class']);
variable_set('print_mail_sys_link_visibility', $print_mail_settings['sys_link_visibility']);
variable_set('print_mail_sys_link_pages', $print_mail_settings['sys_link_pages']);
variable_set('print_mail_book_link', $print_mail_settings['book_link']);
variable_set('print_mail_teaser_default', $print_mail_settings['teaser_default']);
variable_set('print_mail_teaser_choice', $print_mail_settings['teaser_choice']);
variable_del('print_mail_settings');
}
return $ret;
}
......@@ -6,23 +6,17 @@
* Display printer-friendly versions of Drupal pages
*/
define("PRINTMAIL_PATH", "printmail");
/**
* Default values of the print_mail_settings variable
*/
function print_mail_settings_default() {
return array('show_link' => 1,
'node_link_visibility' => 0,
'node_link_pages' => '',
'link_class' => 'print-mail',
'sys_link_visibility' => 1,
'sys_link_pages' => '<front>',
'book_link' => 1,
'teaser_default' => 1,
'teaser_choice' => 1,
);
}
define('PRINTMAIL_PATH', 'printmail');
define('PRINT_MAIL_SHOW_LINK_DEFAULT', 1);
define('PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT', 0);
define('PRINT_MAIL_NODE_LINK_PAGES_DEFAULT', '');
define('PRINT_MAIL_LINK_CLASS_DEFAULT', 'print-mail');
define('PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT', 1);
define('PRINT_MAIL_SYS_LINK_PAGES_DEFAULT', '<front>');
define('PRINT_MAIL_BOOK_LINK_DEFAULT', 1);
define('PRINT_MAIL_TEASER_DEFAULT_DEFAULT', 1);
define('PRINT_MAIL_TEASER_CHOICE_DEFAULT', 1);
//*******************************************************************
// Drupal Hooks
......@@ -74,13 +68,16 @@ function print_mail_menu() {
* Implementation of hook_link().
*/
function print_mail_link($type, $node = NULL, $teaser = FALSE) {
$print_mail_settings = variable_get('print_mail_settings', print_mail_settings_default());
$print_mail_book_link = variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT);
$print_mail_show_link = variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT);
$print_mail_node_link_visibility = variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT);
$print_mail_node_link_pages = variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT);
static $print_mail_display_comment = FALSE;
if (($print_mail_display_comment == FALSE) && (isset($node->type))) {
$node_type = $node->type;
$print_mail_display_comment = variable_get('print_mail_display_comment_'. $node->type, 0);
$print_mail_display = variable_get('print_mail_display_'. $node->type, 1);
$print_mail_display_comment = variable_get('print_mail_display_comment_'. $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$print_mail_display = variable_get('print_mail_display_'. $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
}
else {
$node_type = '';
......@@ -91,10 +88,10 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
$format = theme('print_mail_format_link');
// Show book link
if (($print_mail_settings['book_link']) && user_access('access printer-friendly version') &&
if (($print_mail_book_link) && user_access('access printer-friendly version') &&
(($node_type == 'book') || isset($node->book))) {
$links['book_mail'] = array('href' => PRINTMAIL_PATH ."/book/export/html/". $node->nid,
$links['book_mail'] = array('href' => PRINTMAIL_PATH .'/book/export/html/'. $node->nid,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -104,9 +101,9 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
}
// No link is shown for several motives...
elseif (($node_type != 'book') && (!isset($node->book)) &&
($print_mail_settings['show_link']) && user_access('access print') &&
!(($print_mail_settings['node_link_visibility']) xor
(drupal_match_path("node/". $node->nid, $print_mail_settings['node_link_pages']))) &&
($print_mail_show_link) && user_access('access print') &&
!(($print_mail_node_link_visibility) xor
(drupal_match_path('node/'. $node->nid, $print_mail_node_link_pages))) &&
(($type == 'comment' && $print_mail_display_comment) ||