forena_pdf.module in Forena Reports 7.3
Same filename and directory in other branches
Forena pdf generation module @author metzlerd
File
forena_pdf.moduleView source
<?php
/**
* @file
* Forena pdf generation module
* @author metzlerd
*/
/**
* Implementation of hook_menu
*/
function forena_pdf_menu() {
$items = array();
$items['admin/config/content/forena/pdf'] = array(
'title' => 'PDF',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array(
'forena_pdf_configure',
),
'access arguments' => array(
'administer forena reports',
),
);
return $items;
}
/**
* Implementation of hook_forena_document_types
*/
function forena_pdf_forena_document_types() {
//require_once 'docformats/FrxPrincePDF.inc';
$items = array();
$pdf_generator = variable_get('forena_pdf_generator', '');
if ($pdf_generator) {
include_once 'docformats/' . $pdf_generator . '.inc';
$items['pdf'] = array(
'class' => $pdf_generator,
'title' => t('PDF Document'),
);
}
return $items;
}
/**
* Implementation of configuration form.
* @param unknown_type $formid
* @param unknown_type $form_state
*/
function forena_pdf_configure($formid, &$form_state) {
$path = variable_get('forena_pdf_prince_path', '/usr/local/bin/prince');
$disable_links = variable_get('forena_pdf_disable_links', TRUE);
$pdf_options = array(
'' => t('None'),
'FrxPrincePDF' => t('Prince XML'),
'FrxMPDF' => t('MPDF'),
);
$pdf_generator = variable_get('forena_pdf_generator', '');
$mpdf_path = t('MDPF Libarary not found. Please install so sites/all/libraries/mpdf/mpdf.php exists.');
if (file_exists('sites/all/libraries/mpdf/mpdf.php')) {
$mpdf_path = 'sites/all/libraries/mpdf';
}
else {
unset($pdf_options['FrxMPDF']);
}
$prince_path = t('Prince XML library not found. Please install so sites/all/libraries/prince/prince.php exists.');
if (file_exists('sites/all/libraries/prince/prince.php')) {
$prince_path = 'sites/all/libraries/prince';
}
else {
unset($pdf_options['FrxPrincePDF']);
}
$form['forena_pdf_generator'] = array(
'#type' => 'select',
'#title' => t('PDF Generation Method'),
'#options' => $pdf_options,
'#default_value' => $pdf_generator,
);
$form['forena_pdf_disable_links'] = array(
'#type' => 'checkbox',
'#title' => 'Disable links in PDF Documents',
'#description' => t('When checked links in reports will not appear as links in PDF documents.'),
'#default_value' => $disable_links,
);
$form['mpdf'] = array(
'#type' => 'fieldset',
'#title' => t('MPDF library'),
);
$form['mpdf']['library'] = array(
'#type' => 'item',
'#title' => 'Installation path',
'#markup' => $mpdf_path,
);
$form['prince'] = array(
'#type' => 'fieldset',
'#title' => t('Prince XML'),
);
$form['prince']['library'] = array(
'#type' => 'item',
'#title' => 'PHP Library path',
'#markup' => $prince_path,
);
$form['prince']['forena_pdf_prince_path'] = array(
'#type' => 'textfield',
'#title' => 'Path to binary',
'#description' => t('Specify the location of the prince executable (e.g. /usr/local/bin/prince'),
'#required' => TRUE,
'#default_value' => $path,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}
function forena_pdf_configure_submit($form, &$form_state) {
variable_set('forena_pdf_generator', $form_state['values']['forena_pdf_generator']);
variable_set('forena_pdf_prince_path', $form_state['values']['forena_pdf_prince_path']);
variable_set('forena_pdf_disable_links', $form_state['values']['forena_pdf_disable_links']);
drupal_set_message(t('Options Saved'));
}
Functions
Name | Description |
---|---|
forena_pdf_configure | Implementation of configuration form. |
forena_pdf_configure_submit | |
forena_pdf_forena_document_types | Implementation of hook_forena_document_types |
forena_pdf_menu | Implementation of hook_menu |