Commit 75f94765 authored by jcnventura's avatar jcnventura

Issue #757244: enable printer-friendly versions of old revisions.

parent 7d4b4c6c
......@@ -86,8 +86,10 @@ function print_controller($path, $format, $cid = NULL, $teaser = FALSE) {
array_shift($parts);
$path = implode('/', $parts);
}
if (ctype_digit($parts[0]) && (count($parts) == 1)) {
$node = _print_generate_node($path, $format, $cid, $teaser);
$revision_view = preg_match('!^[\d]*/revisions/[\d]*/view$!', $path);
if (ctype_digit($parts[0]) && ((count($parts) == 1) || $revision_view)) {
$vid = $revision_view ? $parts[2] : NULL;
$node = _print_generate_node($path, $format, $vid, $cid, $teaser);
}
else {
$ret = preg_match('!^book/export/html/(.*)!i', $path, $matches);
......@@ -552,15 +554,17 @@ function _print_url_list_enabled($node, $format) {
* node ID of the node to be rendered into a printer-friendly page
* @param string $format
* format of the page being generated
* @param int $vid
* (optional) revision ID of the node to use
* @param int $cid
* comment ID of the individual comment to be rendered
* (optional) comment ID of the individual comment to be rendered
* @param bool $teaser
* if set to TRUE, outputs only the node's teaser
* (optional) if set to TRUE, outputs only the node's teaser
*
* @return object
* filled node-like object to be used in the print template
*/
function _print_generate_node($nid, $format, $cid = NULL, $teaser = FALSE) {
function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $teaser = FALSE) {
global $_print_urls;
if (!isset($langcode)) {
......@@ -568,7 +572,7 @@ function _print_generate_node($nid, $format, $cid = NULL, $teaser = FALSE) {
}
// We can take a node id
$node = node_load($nid);
$node = node_load($nid, $vid);
if (!$node) {
// Node not found
drupal_not_found();
......
......@@ -127,7 +127,7 @@ function print_ui_block_view($delta = '') {
function print_ui_help($path, $arg) {
$links = '';
if ($path !== 'node/%') {
if (($path !== 'node/%') && ($path !== 'node/%/revisions/%/view')) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -200,6 +200,16 @@ function print_ui_node_view($node, $view_mode) {
$link_pos = variable_get('print_' . $link['format'] . '_link_pos', array(PRINT_UI_LINK_POS_DEFAULT => PRINT_UI_LINK_POS_DEFAULT));
$link_use_alias = variable_get('print_' . $link['format'] . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT);
if (!preg_match('!^node/[\d]*/revisions/[\d]*/view$!', $_GET['q'])) {
// Not a revision, use node->nid to build the path
$path = (($link_use_alias) && ($alias = drupal_lookup_path('alias', 'node/' . $node->nid))) ? $alias : $node->nid;
}
else {
// This is a node revision, replace only the node component
$path = preg_replace('!^node/!', '', $_GET['q']);
}
$path = $link['path'] . '/' . $path;
foreach (array('node', 'comment') as $type) {
$allowed_type = print_ui_link_allowed($link, array('type' => $type, 'node' => $node, 'view_mode' => $view_mode));
if ($allowed_type) {
......@@ -209,18 +219,18 @@ function print_ui_node_view($node, $view_mode) {
// Show book link
if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) {
$path = $link['path'] . '/book/export/html/' . $node->nid;
$links['book_' . $link['format']] = array(
'href' => $link['path'] . '/book/export/html/' . $node->nid,
'href' => $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
);
}
elseif ($allowed_type === PRINT_UI_ALLOW_NORMAL_LINK) {
$path = (($link_use_alias) && ($alias = drupal_lookup_path('alias', 'node/' . $node->nid))) ? $alias : $node->nid;
$links['print_' . $link['format']] = array(
'href' => $link['path'] . '/' . $path,
'href' => $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -250,7 +260,7 @@ function print_ui_node_view($node, $view_mode) {
}
if (!empty($link_pos['corner'])) {
$corner_markup .= print_ui_insert_link($link, NULL, $node);
$corner_markup .= print_ui_insert_link($link, $path);
}
}
}
......
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