You are here

function fillpdf_settings in FillPDF 7

Same name and namespace in other branches
  1. 6 fillpdf.admin.inc \fillpdf_settings()

Settings form for user to place API Key.

1 string reference to 'fillpdf_settings'
fillpdf_menu in ./fillpdf.module
Implements hook_menu().

File

./fillpdf.admin.inc, line 23
Allows mappings of PDFs to site content.

Code

function fillpdf_settings($form, &$form_state) {
  $fillpdf_service = variable_get('fillpdf_service');
  $scheme_options = fillpdf_scheme_options();
  $form['fillpdf_scheme'] = array(
    '#type' => 'radios',
    '#title' => t('Template download method'),
    '#default_value' => variable_get('fillpdf_scheme', isset($scheme_options['public']) ? 'public' : key($scheme_options)),
    '#options' => $scheme_options,
    '#description' => t('This setting is used as the download method for uploaded templates. The use of public files is more efficient, but does not provide any access control. Changing this setting will require you to migrate associated files and data yourself and is not recommended after you have uploaded a template.'),
  );

  // Assemble service options. Warning messages will be added next as needed.
  $options = array(
    'remote' => t('Use FillPDF Service: Sign up for <a href="https://fillpdf.io">FillPDF Service</a>.'),
    'local_service' => t("Use a network-accessible <strong>FillPDF LocalServer</strong>. You will need a VPS or dedicated server with FillPDF LocalServer. Use FillPDF Service if this isn't possible with your hosting."),
    'pdftk' => t('Use locally-installed pdftk: You will need a VPS or a dedicated server so you can install pdftk: (!see_documentation).', array(
      '!see_documentation' => l(t('see documentation'), 'http://drupal.org/documentation/modules/fillpdf'),
    )),
    'local' => t('LEGACY. USE FILLPDF LOCALSERVER INSTEAD.'),
  );
  $form['fillpdf_service'] = array(
    '#type' => 'radios',
    '#title' => t('PDF-filling service'),
    '#description' => t('This module requires the use of one of several external PDF manipulation tools. Choose the service you would like to use.'),
    '#default_value' => $fillpdf_service,
    '#options' => $options,
  );
  $form['remote'] = array(
    '#type' => 'fieldset',
    '#title' => t('Configure FillPDF Service'),
    '#states' => array(
      'visible' => array(
        ':input[name="fillpdf_service"]' => array(
          'value' => 'remote',
        ),
      ),
    ),
  );
  $form['remote']['fillpdf_remote_endpoint'] = array(
    '#type' => 'textfield',
    '#title' => t('Server endpoint'),
    '#default_value' => variable_get('fillpdf_remote_endpoint', 'fillpdf.io/xmlrpc.php'),
    '#description' => t('The endpoint for the FillPDF Service instance. This does not usually need to be changed, but you may want to if you have, for example, a <a href="https://fillpdf.io/hosting">private server</a>. Do not include the protocol, as this is determined by the <em>Use HTTPS?</em> setting below.'),
  );
  $form['remote']['fillpdf_api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('API Key'),
    '#default_value' => variable_get('fillpdf_api_key', ''),
    '#description' => t('You need to sign up for an API key at <a href="https://fillpdf.io">FillPDF Service</a>'),
  );
  $form['remote']['fillpdf_remote_protocol'] = array(
    '#type' => 'radios',
    '#title' => t('Use HTTPS?'),
    '#description' => t('It is recommended to select <em>Use HTTPS</em> for this option. Doing so will help prevent
      sensitive information in your PDFs from being intercepted in transit between your server and the remote service.'),
    '#default_value' => variable_get('fillpdf_remote_protocol', 'https'),
    '#options' => array(
      'https' => t('Use HTTPS'),
      'http' => t('Do not use HTTPS'),
    ),
  );
  $form['fillpdf_local_service_endpoint'] = array(
    '#type' => 'textfield',
    '#title' => t('Configure FillPDF LocalServer endpoint (address)'),
    '#default_value' => variable_get('fillpdf_local_service_endpoint'),
    '#description' => t("Enter the network address of your FillPDF LocalServer installation. If you are running the Docker container on port 8085 locally, then the address is <em>http://127.0.0.1:8085</em>. Don't worry; the module will check if it can communicate with LocalServer once you fill in this information."),
    '#states' => array(
      'visible' => array(
        ':input[name="fillpdf_service"]' => array(
          'value' => 'local_service',
        ),
      ),
    ),
  );
  $form['fillpdf_pdftk_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Configure path to pdftk'),
    '#description' => t("If FillPDF is not detecting your pdftk installation, you can specify the full path to the program here. Include the program name as well. For example, <em>/usr/bin/pdftk</em> is a valid value. You can almost always leave this field blank. If you should set it, you'll probably know."),
    '#default_value' => variable_get('fillpdf_pdftk_path'),
    '#states' => array(
      'visible' => array(
        ':input[name="fillpdf_service"]' => array(
          'value' => 'pdftk',
        ),
      ),
    ),
  );
  return system_settings_form($form);
}