You are here

function forena_pdf_configure in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena_pdf/forena_pdf.module \forena_pdf_configure()
  2. 7.3 forena_pdf.module \forena_pdf_configure()
  3. 7.4 forena_pdf.module \forena_pdf_configure()

Implementation of configuration form.

Parameters

unknown_type $formid:

unknown_type $form_state:

1 string reference to 'forena_pdf_configure'
forena_pdf_menu in ./forena_pdf.module
Implementation of hook_menu

File

./forena_pdf.module, line 44
Forena pdf generation module @author metzlerd

Code

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'),
    'PrincePDF' => t('Prince XML'),
    'MPDFDocument' => t('MPDF'),
    'DocRaptorPDF' => t('DocRaptor PDF generation Service'),
  );
  $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 (forena_library_file('mpdf')) {
    $mpdf_path = 'sites/all/libraries/mpdf';
  }
  else {
    unset($pdf_options['MPDFDocument']);
  }
  $prince_path = t('Prince XML library not found.  Please install so sites/all/libraries/prince/prince.php exists.');
  if (forena_library_file('prince')) {
    $prince_path = 'sites/all/libraries/prince';
  }
  else {
    unset($pdf_options['PrincePDF']);
  }
  if (isset($form_state['values']['forena_pdf_generator'])) {
    $pdf_generator = $form_state['values']['forena_pdf_generator'];
  }
  $form['forena_pdf_generator'] = array(
    '#type' => 'select',
    '#title' => t('PDF Generation Method'),
    '#options' => $pdf_options,
    '#default_value' => $pdf_generator,
    '#ajax' => array(
      'wrapper' => 'config-wrapper',
      'callback' => 'forena_pdf_config_callback',
    ),
  );
  $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['config'] = array(
    '#prefix' => '<div id="config-wrapper">',
    '#suffix' => '</div>',
  );
  $form['config']['mpdf'] = array(
    '#type' => 'fieldset',
    '#title' => t('MPDF library'),
    '#access' => $pdf_generator == 'MPDFDocument',
  );
  $form['config']['mpdf']['library'] = array(
    '#type' => 'item',
    '#title' => 'Installation path',
    '#markup' => $mpdf_path,
  );
  $form['config']['prince'] = array(
    '#type' => 'fieldset',
    '#title' => t('Prince XML'),
    '#access' => $pdf_generator == 'PrincePDF',
  );
  $form['config']['prince']['library'] = array(
    '#type' => 'item',
    '#title' => t('PHP Library path'),
    '#markup' => $prince_path,
  );
  $form['config']['prince']['forena_pdf_prince_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to binary'),
    '#description' => t('Specify the location of the prince executable (e.g. /usr/local/bin/prince'),
    '#required' => TRUE,
    '#default_value' => $path,
  );
  $docraptor_url = variable_get('fornea_pdf_docrapter_url', 'https://docraptor.com/docs');
  $docraptor_key = variable_get('forena_pdf_docraptor_key', '');
  $docraptor_test = variable_get('forena_pdf_docraptor_test', TRUE);
  $form['config']['docraptor'] = array(
    '#type' => 'fieldset',
    '#title' => t("DocRaptor PDF Generation Service"),
    '#access' => $pdf_generator == 'DocRaptorPDF',
  );
  $form['config']['docraptor']['forena_pdf_docraptor_url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL to Docraptor Service'),
    '#description' => t('Specify the URL to the PDF Document Generation Service'),
    '#default_value' => $docraptor_url,
  );
  $form['config']['docraptor']['forena_pdf_docraptor_key'] = array(
    '#type' => 'textfield',
    '#title' => t('DocRaptor API Key'),
    '#description' => t('Enter the API key for your DocRaptor account here.'),
    '#default_value' => $docraptor_key,
  );
  $form['config']['docraptor']['forena_pdf_docraptor_test'] = array(
    '#type' => 'checkbox',
    '#title' => t('Test Mode Document Generation'),
    '#desciption' => t('Generating Documents in Test mode generally does not count towards document counts, but places
      a TEST DOCUMENT header at the top of every page of the document'),
    '#default_value' => $docraptor_test,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
  );
  return $form;
}