Commit dd0fda21 authored by jcnventura's avatar jcnventura

Fix #303506 partly by joostvdl: remove the country code from paths to private...

Fix #303506 partly by joostvdl: remove the country code from paths to private image files used in generating PDFs
Use hook_node_* instead of hook_nodeapi_* in line with changes to Drupal 7
Simpler fix to #388008: Use a 'heavier' weight even in the absense of the CCK module
parent 4c80db2e
......@@ -48,6 +48,7 @@ define('PRINT_TYPE_URLLIST_DEFAULT', 1);
define('PRINT_ALLOW_NORMAL_LINK', 1);
define('PRINT_ALLOW_BOOK_LINK', 2);
define('PRINT_TYPE_FIELDS_WEIGHT', 50);
/**
* Implementation of hook_perm().
......@@ -254,9 +255,9 @@ function print_help($path, $arg) {
}
/**
* Implementation of hook_nodeapi_view().
* Implementation of hook_node_view().
*/
function print_nodeapi_view($node, $teaser) {
function print_node_view($node, $teaser) {
$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' => 'node', 'node' => $node, 'teaser' => $teaser));
......@@ -307,27 +308,27 @@ function print_nodeapi_view($node, $teaser) {
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function print_nodeapi_load($nodes, $types) {
function print_node_load($nodes, $types) {
foreach ($nodes as $node) {
_print_set_node_fields($node);
}
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function print_nodeapi_update($node) {
function print_node_update($node) {
if (user_access('administer print') || user_access('node-specific print configuration')) {
_print_node_conf_modify($node->nid, $node->print_display, $node->print_display_comment, $node->print_display_urllist);
}
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function print_nodeapi_delete($node) {
function print_node_delete($node) {
db_delete('print_node_conf')
->condition('nid', $node->nid)
->execute();
......@@ -348,12 +349,9 @@ function print_form_alter(&$form, $form_state, $form_id) {
'#title' => t('Printer, e-mail and PDF versions'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => function_exists('cck_extra_field_weight') ? cck_extra_field_weight($form['type']['#value'], 'print') : PRINT_TYPE_FIELDS_WEIGHT,
);
if (function_exists('cck_extra_field_weight')) {
$form['print']['#weight'] = cck_extra_field_weight($form['type']['#value'], 'print');
}
$form['print']['label'] = array(
'#type' => 'markup',
'#markup' => '<p><strong>'. t('Printer-friendly version') .'</strong></p>',
......@@ -394,7 +392,7 @@ function print_cck_extra_fields($type_name) {
$fields['print'] = array(
'label' => t('Printer, e-mail and PDF versions'),
'description' => t('Print module form.'),
'weight' => 50,
'weight' => PRINT_TYPE_FIELDS_WEIGHT,
);
return $fields;
}
......
......@@ -617,8 +617,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
}
$node->body .= $comments;
}
node_invoke_nodeapi($node, 'alter', $teaser, TRUE);
node_invoke_node($node, 'alter', $teaser, TRUE);
if ($teaser) {
$node->body = $node->teaser;
......
......@@ -105,9 +105,9 @@ function print_mail_block_view($delta = 0) {
}
/**
* Implementation of hook_nodeapi_view().
* Implementation of hook_node_view().
*/
function print_mail_nodeapi_view($node, $teaser) {
function print_mail_node_view($node, $teaser) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_mail_link_allowed(array('type' => 'node', 'node' => $node, 'teaser' => $teaser));
......@@ -187,27 +187,27 @@ function print_mail_help($path, $arg) {
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function print_mail_nodeapi_load($nodes, $types) {
function print_mail_node_load($nodes, $types) {
foreach ($nodes as $node) {
_print_mail_set_node_fields($node);
}
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function print_mail_nodeapi_update($node) {
function print_mail_node_update($node) {
if (user_access('administer print') || user_access('node-specific print configuration')) {
_print_mail_node_conf_modify($node->nid, $node->print_mail_display, $node->print_mail_display_comment, $node->print_mail_display_urllist);
}
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function print_mail_nodeapi_delete($node) {
function print_mail_node_delete($node) {
db_delete('print_mail_node_conf')
->condition('nid', $node->nid)
->execute();
......
......@@ -146,9 +146,9 @@ function print_pdf_requirements($phase) {
}
/**
* Implementation of hook_nodeapi_view().
* Implementation of hook_node_view().
*/
function print_pdf_nodeapi_view($node, $teaser) {
function print_pdf_node_view($node, $teaser) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
$print_pdf_link_use_alias = variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_pdf_link_allowed(array('type' => 'node', 'node' => $node, 'teaser' => $teaser));
......@@ -227,27 +227,27 @@ function print_pdf_help($path, $arg) {
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function print_pdf_nodeapi_load($nodes, $types) {
function print_pdf_node_load($nodes, $types) {
foreach ($nodes as $node) {
_print_pdf_set_node_fields($node);
}
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function print_pdf_nodeapi_update($node) {
function print_pdf_node_update($node) {
if (user_access('administer print') || user_access('node-specific print configuration')) {
_print_pdf_node_conf_modify($node->nid, $node->print_pdf_display, $node->print_pdf_display_comment, $node->print_pdf_display_urllist);
}
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function print_pdf_nodeapi_delete($node) {
function print_pdf_node_delete($node) {
db_delete('print_pdf_node_conf')
->condition('nid', $node->nid)
->execute();
......
......@@ -20,7 +20,7 @@ require_once(DRUPAL_ROOT .'/'. drupal_get_path('module', 'print') .'/print.pages
* @see _print_pdf_tcpdf()
*/
function print_pdf_controller() {
global $base_url;
global $base_url, $language;
// Disable caching for generated PDFs, as Drupal doesn't ouput the proper headers from the cache
$GLOBALS['conf']['cache'] = FALSE;
......@@ -45,7 +45,16 @@ 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}/(?:(?:index.php)?\?q=)?system/files(/[^>]*?>)!is";
switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
case LANGUAGE_NEGOTIATION_PATH:
$lang = $language->language;
break;
default:
$lang = '';
break;
}
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files(/[^>]*?>)!is";
$replacement = '$1file://'. realpath(file_directory_path()) .'$2';
$print['content'] = preg_replace($pattern, $replacement, $print['content']);
$print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
......
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