You are here

function phantomjs_capture_admin_form in PhantomJS Capture 7

The administration form.

It allows site admins to enter information about the systems installation of PhantomJS.

Return value

array Drupal form array with the administration form.

1 string reference to 'phantomjs_capture_admin_form'
phantomjs_capture_menu in ./phantomjs_capture.module
Implements hook_menu().

File

./phantomjs_capture.module, line 35
Defines the administration interface and utility functions to use PhantomJS and test screen shot capture functions.

Code

function phantomjs_capture_admin_form() {
  $form = array();
  $form['phantomjs_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('PhantomJS settings'),
    '#collapsible' => FALSE,
  );
  $form['phantomjs_settings']['phantomjs_capture_binary'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('Path to phantomJS'),
    '#description' => t('This module requries that you install PhantomJS on your server and enter the path to the executable. The program is not include in the module due to linces and operation system constrains. See !url for information about download.', array(
      '!url' => l('PhantomJs.org', 'http://phantomjs.org/'),
    )),
    '#default_value' => variable_get('phantomjs_capture_binary', _phantomjs_capture_get_binary()),
  );
  $form['phantomjs_settings']['phantomjs_capture_dest'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('Default destination'),
    '#description' => t('The default destination for screenshots captures with PhantomJS'),
    '#default_value' => variable_get('phantomjs_capture_dest', 'phantomjs'),
  );
  $form['phantomjs_settings']['phantomjs_capture_script'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('PhantomJS capture script'),
    '#description' => t('The script used by PhantomJS to capture the screen. It captures full HD images (1920 x 1080).'),
    '#default_value' => variable_get('phantomjs_capture_script', drupal_get_path('module', 'phantomjs_capture') . '/js/phantomjs_capture.js'),
  );
  $form['phantomjs_capture_test'] = array(
    '#type' => 'fieldset',
    '#title' => t('Phantom JS test'),
    '#description' => t('You can use the form in this section to test your installation of PhantomJS.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
  );
  $form['phantomjs_capture_test']['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),
    '#description' => t('Absolute URL to the homepage that should be capture (it has to be a complet URL with http://).'),
    '#default_value' => 'http://www.google.com',
  );
  $form['phantomjs_capture_test']['format'] = array(
    '#type' => 'select',
    '#title' => 'File format',
    '#options' => array(
      '.png' => 'png',
      '.jpg' => 'jpg',
      '.pdf' => 'pdf',
    ),
  );
  $form['phantomjs_capture_test']['result'] = array(
    '#prefix' => '<div id="phantomjs-capture-test-result">',
    '#suffix' => '</div>',
    '#markup' => '',
  );
  $form['phantomjs_capture_test']['button'] = array(
    '#type' => 'button',
    '#value' => t('Capture'),
    "#ajax" => array(
      "callback" => "phantomjs_capture_test_submit",
      "wrapper" => "phantomjs-capture-test-result",
      "method" => 'replace',
      "effect" => "fade",
    ),
  );
  return system_settings_form($form);
}