summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ventura2009-02-02 19:47:13 (GMT)
committer Joao Ventura2009-02-02 19:47:13 (GMT)
commitb9615c272f143c142f6d6e4abb8c3c9b47af78e9 (patch)
treeb38c530f2e894df7eebc58d456f8ffb2d1a7994f
parent98d19dfefd8e3047fd5a3be020681d2a0ddae6a1 (diff)
Fix #366835: support RTL languages in TCPDF generated PDFs
-rw-r--r--print_pdf/print_pdf.admin.inc29
-rw-r--r--print_pdf/print_pdf.module21
-rw-r--r--print_pdf/print_pdf.pages.inc7
3 files changed, 46 insertions, 11 deletions
diff --git a/print_pdf/print_pdf.admin.inc b/print_pdf/print_pdf.admin.inc
index a464676..a96ef50 100644
--- a/print_pdf/print_pdf.admin.inc
+++ b/print_pdf/print_pdf.admin.inc
@@ -55,13 +55,6 @@ function print_pdf_settings() {
'#description' => t('Select the visual style of the link.'),
);
- $form['settings']['adv_link']['print_pdf_link_text'] = array(
- '#type' => 'textfield',
- '#title' => t('Link text'),
- '#default_value' => variable_get('print_pdf_link_text', t('PDF version')),
- '#description' => t("Text used in the link to the PDF version."),
- );
-
$form['settings']['adv_link']['print_pdf_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
@@ -263,3 +256,25 @@ function _print_pdf_tools() {
return $tools2;
}
}
+
+/**
+ * Menu callback for the PDF version module text strings settings form.
+ *
+ * @ingroup forms
+ * @see _print_pdf_tools()
+ */
+function print_pdf_strings_settings() {
+ $form['print_pdf_text'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Text strings'),
+ );
+
+ $form['print_pdf_text']['print_pdf_link_text'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link text),
+ '#default_value' => variable_get('print_pdf_link_text', t('PDF version')),
+ '#description' => t("Text used in the link to the PDF version."),
+ );
+
+ return system_settings_form($form);
+}
diff --git a/print_pdf/print_pdf.module b/print_pdf/print_pdf.module
index a859413..23f821a 100644
--- a/print_pdf/print_pdf.module
+++ b/print_pdf/print_pdf.module
@@ -84,6 +84,20 @@ function print_pdf_menu() {
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
+ $items['admin/settings/print/pdf/options'] = array(
+ 'title' => 'Options',
+ 'weight' => 1,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/settings/print/pdf/strings'] = array(
+ 'title' => 'Text strings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('print_pdf_strings_settings'),
+ 'access arguments' => array('administer print'),
+ 'weight' => 2,
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'print_pdf.admin.inc',
+ );
return $items;
}
@@ -278,9 +292,10 @@ function print_pdf_form_alter(&$form, $form_state, $form_id) {
$form['print']['print_pdf_display_urllist']['#default_value'] = variable_get('print_pdf_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
- $form['print']['print_pdf_display']['#default_value'] = $form['#node']->print_pdf_display;
- $form['print']['print_pdf_display_comment']['#default_value'] = $form['#node']->print_pdf_display_comment;
- $form['print']['print_pdf_display_urllist']['#default_value'] = $form['#node']->print_pdf_display_urllist;
+ $node = $form['#node'];
+ $form['print']['print_pdf_display']['#default_value'] = isset($node->print_pdf_display) ? $node->print_pdf_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
+ $form['print']['print_pdf_display_comment']['#default_value'] = isset($node->print_pdf_display_comment) ? $node->print_pdf_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
+ $form['print']['print_pdf_display_urllist']['#default_value'] = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
}
}
}
diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc
index e3ea99c..d9705c5 100644
--- a/print_pdf/print_pdf.pages.inc
+++ b/print_pdf/print_pdf.pages.inc
@@ -144,7 +144,8 @@ function _print_pdf_dompdf($print, $html, $filename) {
* @see print_pdf_controller()
*/
function _print_pdf_tcpdf($print, $html, $filename) {
- global $base_url;
+ global $base_url, $language;
+
$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);
@@ -188,6 +189,10 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$pdf->SetKeywords($keys);
$pdf->setPDFVersion('1.6');
+ if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
+ $pdf->setRTL(TRUE);
+ }
+
$pdf = theme('print_pdf_tcpdf_header', $pdf, $html, $font);
$pdf = theme('print_pdf_tcpdf_footer', $pdf, $html, $font);
$pdf = theme('print_pdf_tcpdf_page', $pdf);