summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ventura2008-11-07 00:27:40 (GMT)
committer Joao Ventura2008-11-07 00:27:40 (GMT)
commitc64555f459cf6b58da61e71cfbe6cd972c949b07 (patch)
tree07388d98f180cd1cca161cc0e0bd014d338e45cb
parent2314cdc503bc1c576a9b4f0b94489e46ff6c46e4 (diff)
Use link format and icon options also in book links.
Fix #315204: Add options to show only the current page in book links Fix #314521: Use file:// access when accessing images if private file system is enabled
-rw-r--r--print.admin.inc38
-rw-r--r--print.module36
-rw-r--r--print_mail/print_mail.admin.inc38
-rw-r--r--print_mail/print_mail.module15
-rw-r--r--print_pdf/print_pdf.admin.inc38
-rw-r--r--print_pdf/print_pdf.module15
-rw-r--r--print_pdf/print_pdf.pages.inc6
7 files changed, 104 insertions, 82 deletions
diff --git a/print.admin.inc b/print.admin.inc
index ea164ac..585d573 100644
--- a/print.admin.inc
+++ b/print.admin.inc
@@ -193,6 +193,22 @@ function print_html_settings() {
'#description' => t('Select the visual style of the link.'),
);
+ $form['settings']['adv_link']['print_html_link_use_alias'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use URL alias instead of node ID'),
+ '#default_value' => variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT),
+ '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
+ );
+
+ $form['settings']['adv_link']['print_html_link_class'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link class'),
+ '#default_value' => variable_get('print_html_link_class', PRINT_HTML_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['settings']['adv_link']['print_html_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
@@ -207,15 +223,6 @@ function print_html_settings() {
'#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['settings']['adv_link']['print_html_link_class'] = array(
- '#type' => 'textfield',
- '#title' => t('Link class'),
- '#default_value' => variable_get('print_html_link_class', PRINT_HTML_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['settings']['adv_link']['print_html_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
@@ -231,18 +238,11 @@ function print_html_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['settings']['adv_link']['print_html_link_use_alias'] = array(
- '#type' => 'checkbox',
- '#title' => t('Use URL alias instead of node ID'),
- '#default_value' => variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT),
- '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
- );
-
$form['settings']['print_html_book_link'] = array(
- '#type' => 'checkbox',
- '#title' => t('Take control of the book module printer-friendly link'),
+ '#type' => 'radios',
+ '#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT),
- '#description' => t('Activate this to have the printer-friendly link in book nodes handled by this module. Requires the (core) book module.'),
+ '#options' => array(t('Book module link not modified'), t('Current page and sub-pages'), t('Current page only')),
);
$form['settings']['print_html_new_window'] = array(
diff --git a/print.module b/print.module
index 304d070..275e1ad 100644
--- a/print.module
+++ b/print.module
@@ -155,7 +155,7 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
- if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !empty($print_html_link_pos['link'])) {
+ if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !isset($node->book) && !empty($print_html_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
$links = array();
$format = theme('print_format_link');
@@ -199,10 +199,23 @@ function print_link_alter(&$links, $node) {
if ($print_html_book_link) {
$format = theme('print_format_link');
- $format['attributes']['title'] = $link['attributes']['title'];
- $links[$module]['href'] = PRINT_PATH .'/'. $link['href'];
- $links[$module]['attributes'] = $format['attributes'];
+ switch ($print_html_book_link) {
+ case 1:
+ $path = $link['href'];
+ break;
+ case 2:
+ $print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
+ $path = $print_html_link_use_alias ? $node->path : $node->nid;
+ break;
+ }
+
+ $links[$module] = array(
+ 'href' => PRINT_PATH .'/'. $path,
+ 'title' => $format['text'],
+ 'attributes' => $format['attributes'],
+ 'html' => $format['html'],
+ );
}
}
}
@@ -540,12 +553,14 @@ function print_link_allowed($args) {
elseif (isset($node->book)) {
// Node is a book;
$print_html_book_link = variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT);
- if (!$print_html_book_link || !user_access('access printer-friendly version')) {
- // Book link is disabled
- return FALSE;
- }
- else {
- return PRINT_ALLOW_BOOK_LINK;
+ switch ($print_html_book_link) {
+ case 1:
+ if (user_access('access printer-friendly version')) {
+ return PRINT_ALLOW_BOOK_LINK;
+ }
+ break;
+ case 2:
+ return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
@@ -560,6 +575,7 @@ function print_link_allowed($args) {
return _print_page_match($print_html_sys_link_visibility, $print_html_sys_link_pages);
}
+ return FALSE;
}
/**
diff --git a/print_mail/print_mail.admin.inc b/print_mail/print_mail.admin.inc
index 3ab74a1..39b4b87 100644
--- a/print_mail/print_mail.admin.inc
+++ b/print_mail/print_mail.admin.inc
@@ -43,6 +43,22 @@ function print_mail_settings() {
'#description' => t('Select the visual style of the link.'),
);
+ $form['settings']['adv_link']['print_mail_link_use_alias'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use URL alias instead of node ID'),
+ '#default_value' => variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT),
+ '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
+ );
+
+ $form['settings']['adv_link']['print_mail_link_class'] = array(
+ '#type' => 'textfield',
+ '#title' => t('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['settings']['adv_link']['print_mail_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
@@ -57,15 +73,6 @@ function print_mail_settings() {
'#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['settings']['adv_link']['print_mail_link_class'] = array(
- '#type' => 'textfield',
- '#title' => t('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['settings']['adv_link']['print_mail_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
@@ -81,18 +88,11 @@ 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['settings']['adv_link']['print_mail_link_use_alias'] = array(
- '#type' => 'checkbox',
- '#title' => t('Use URL alias instead of node ID'),
- '#default_value' => variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT),
- '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
- );
-
$form['settings']['print_mail_book_link'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show link in book nodes'),
+ '#type' => 'radios',
+ '#title' => t('Link in book hierarchy 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.'),
+ '#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
);
$form['settings']['print_mail_hourly_threshold'] = array(
diff --git a/print_mail/print_mail.module b/print_mail/print_mail.module
index 795bff2..fe00910 100644
--- a/print_mail/print_mail.module
+++ b/print_mail/print_mail.module
@@ -314,12 +314,14 @@ function print_mail_link_allowed($args) {
elseif (isset($node->book)) {
// Node is a book;
$print_mail_book_link = variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT);
- if (!$print_mail_book_link || !user_access('access printer-friendly version')) {
- // Book link is disabled
- return FALSE;
- }
- else {
- return PRINT_ALLOW_BOOK_LINK;
+ switch ($print_mail_book_link) {
+ case 1:
+ if (user_access('access printer-friendly version')) {
+ return PRINT_ALLOW_BOOK_LINK;
+ }
+ break;
+ case 2:
+ return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
@@ -334,4 +336,5 @@ function print_mail_link_allowed($args) {
return _print_page_match($print_mail_sys_link_visibility, $print_mail_sys_link_pages);
}
+ return FALSE;
}
diff --git a/print_pdf/print_pdf.admin.inc b/print_pdf/print_pdf.admin.inc
index e9a564c..18b801a 100644
--- a/print_pdf/print_pdf.admin.inc
+++ b/print_pdf/print_pdf.admin.inc
@@ -55,6 +55,22 @@ function print_pdf_settings() {
'#description' => t('Select the visual style of the link.'),
);
+ $form['settings']['adv_link']['print_pdf_link_use_alias'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use URL alias instead of node ID'),
+ '#default_value' => variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT),
+ '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
+ );
+
+ $form['settings']['adv_link']['print_pdf_link_class'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link class'),
+ '#default_value' => variable_get('print_pdf_link_class', PRINT_PDF_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['settings']['adv_link']['print_pdf_node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
@@ -69,15 +85,6 @@ function print_pdf_settings() {
'#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['settings']['adv_link']['print_pdf_link_class'] = array(
- '#type' => 'textfield',
- '#title' => t('Link class'),
- '#default_value' => variable_get('print_pdf_link_class', PRINT_PDF_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['settings']['adv_link']['print_pdf_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
@@ -93,18 +100,11 @@ 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['settings']['adv_link']['print_pdf_link_use_alias'] = array(
- '#type' => 'checkbox',
- '#title' => t('Use URL alias instead of node ID'),
- '#default_value' => variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT),
- '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
- );
-
$form['settings']['print_pdf_book_link'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show link in book nodes'),
+ '#type' => 'radios',
+ '#title' => t('Link in book hierarchy 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.'),
+ '#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
);
$form['settings']['print_pdf_content_disposition'] = array(
diff --git a/print_pdf/print_pdf.module b/print_pdf/print_pdf.module
index 8099504..024a8cb 100644
--- a/print_pdf/print_pdf.module
+++ b/print_pdf/print_pdf.module
@@ -356,12 +356,14 @@ function print_pdf_link_allowed($args) {
elseif (isset($node->book)) {
// Node is a book;
$print_pdf_book_link = variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT);
- if (!$print_pdf_book_link || !user_access('access printer-friendly version')) {
- // Book link is disabled
- return FALSE;
- }
- else {
- return PRINT_ALLOW_BOOK_LINK;
+ switch ($print_pdf_book_link) {
+ case 1:
+ if (user_access('access printer-friendly version')) {
+ return PRINT_ALLOW_BOOK_LINK;
+ }
+ break;
+ case 2:
+ return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
@@ -376,4 +378,5 @@ function print_pdf_link_allowed($args) {
return _print_page_match($print_pdf_sys_link_visibility, $print_pdf_sys_link_pages);
}
+ return FALSE;
}
diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc
index fcdafb6..1de9f9a 100644
--- a/print_pdf/print_pdf.pages.inc
+++ b/print_pdf/print_pdf.pages.inc
@@ -42,8 +42,8 @@ function print_pdf_controller() {
// And converted from private to public paths
$file_downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC);
if ($file_downloads == FILE_DOWNLOADS_PRIVATE) {
- $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?${base_url}/)system/files(/[^>]*?>)!is";
- $replacement = '$1'. file_directory_path() .'$2';
+ $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/system/files(/[^>]*?>)!is";
+ $replacement = '$1file://'. file_directory_path() .'$2';
$print['content'] = preg_replace($pattern, $replacement, $print['content']);
$print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
$print['footer_message'] = preg_replace($pattern, $replacement, $print['footer_message']);
@@ -255,7 +255,7 @@ function theme_print_pdf_tcpdf_header(&$pdf, &$html, $font) {
if ($logo_ret) {
$logo = trim($matches[1], '\'"');
$size = getimagesize($logo);
- $ratio = $size[0] / $size[1];
+ $ratio = $size ? ($size[0] / $size[1]) : 0;
}
// set header font