<?php
-// $Id$
/**
* @file
define('PRINTPDF_PATH', 'printpdf');
-define('PRINT_PDF_FORMAT', 'pdf');
+// Defined in print.module
+//define('PRINT_PDF_FORMAT', 'pdf');
define('PRINT_PDF_LIB_PATH', 'sites/all/libraries');
define('PRINT_PDF_AUTOCONFIG_DEFAULT', 1);
define('PRINT_PDF_FONT_FAMILY_DEFAULT', 'dejavusans');
define('PRINT_PDF_FONT_SIZE_DEFAULT', 10);
+define('PRINT_PDF_FONT_SUBSETTING_DEFAULT', 0);
define('PRINT_PDF_FILENAME_DEFAULT', '[site:name] - [node:title] - [node:changed:custom:Y-m-d]');
define('PRINT_PDF_DOMPDF_UNICODE_DEFAULT', 0);
define('PRINT_PDF_WKHTMLTOPDF_OPTIONS', "--footer-font-size 7 --footer-right '[page]'");
$items[PRINTPDF_PATH . '/' . PRINTPDF_PATH] = array(
'access callback' => FALSE,
);
- $items['admin/config/print/pdf'] = array(
+ $items['admin/config/user-interface/print/pdf'] = array(
'title' => 'PDF',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_settings'),
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
- $items['admin/config/print/pdf/options'] = array(
+ $items['admin/config/user-interface/print/pdf/options'] = array(
'title' => 'Options',
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/config/print/pdf/strings'] = array(
+ $items['admin/config/user-interface/print/pdf/strings'] = array(
'title' => 'Text strings',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_strings_settings'),
$requirements['print_pdf_tool'] = array(
'title' => $t('PDF generation library'),
'value' => $t('No PDF tool selected'),
- 'description' => $t('Please configure it in the <a href="@url">PDF settings page</a>.', array('@url' => url('admin/config/print/pdf'))),
+ 'description' => $t('Please configure it in the <a href="@url">PDF settings page</a>.', array('@url' => url('admin/config/user-interface/print/pdf'))),
'severity' => REQUIREMENT_ERROR,
);
}
);
}
}
+ elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') {
+ $version = _print_pdf_tcpdf_version();
+
+ if (version_compare($version, '5.9.012', '<')) {
+ $requirements['print_pdf_tool'] = array(
+ 'title' => $t('TCPDF library'),
+ 'value' => $t('Unsupported version'),
+ 'description' => $t('The currently selected version of TCPDF (@version) is not supported. Please update to a <a href="@url">newer version</a>.', array('@version' => $version, '@url' => url('http://www.tcpdf.org'))),
+ 'severity' => REQUIREMENT_ERROR,
+ );
+ }
+ }
elseif (substr(basename($print_pdf_pdf_tool, '.exe'), 0, 11) == 'wkhtmltopdf') {
if (function_exists('is_executable') && !is_executable($print_pdf_pdf_tool)) {
$requirements['print_pdf_tool'] = array(
}
if (!empty($args['path'])) {
$nid = preg_replace('!^node/!', '', drupal_get_normal_path($args['path']));
- if (is_numeric($nid)) {
+ if (ctype_digit($nid)) {
$args['node'] = node_load($nid);
}
}
}
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
// Link is for a comment, return the configured setting
- $res = db_query("SELECT comments FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
- ->fetch();
- $print_display_comment = $res ? intval($res->comments) : variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
+ // Cache this statically to avoid duplicate queries for every comment.
+ static $res = array();
+ if (!isset($res[$node->nid])) {
+ $res[$node->nid] = db_query("SELECT comments FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
+ ->fetch();
+ }
+ $print_display_comment = $res ? intval($res[$node->nid]->comments) : variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
if ($print_display_comment) {
return PRINT_ALLOW_NORMAL_LINK;
}
return FALSE;
}
+/**
+ * Find out the version of the TCPDF library
+ */
+function _print_pdf_tcpdf_version() {
+ $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
+ require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool);
+
+ $pdf = new TCPDF();
+
+ return $pdf->getTCPDFVersion();
+}
+
+/**
+ * Find out the version of the wkhtmltopdf library
+ */
function _print_pdf_wkhtmltopdf_version() {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
-
- $cmd = realpath($print_pdf_pdf_tool) ." --version";
+
+ $cmd = realpath($print_pdf_pdf_tool) . ' --version';
$process = proc_open($cmd, $descriptor, $pipes, NULL, NULL);
if (is_resource($process)) {
$out = preg_match('!.*?(\d+\.\d+\.\d+).*$!m', stream_get_contents($pipes[1]), $matches);