summaryrefslogtreecommitdiffstats
path: root/plugins/test_plugin/drulenium_takescreenshot.inc
blob: 61fe54d024e5b23da4eeddcb1816940c22675ca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php

/**
 * @file takescreenshot.inc
 * 
 * Main (ctools) plugin file for "takescreenshot" plugin type
 */

$plugin = array(
  'title' => t('Take screenshot'),
  'description' => t('Drulenium Take screenshot plugin'),
);

function drulenium_takescreenshot_defaults() {
  return array(
    'locator' => '',
    'locator_type' => 'css',
    'snapshot_mode' => 'include',
    'width' => '0',
    'height' => '0',
    'offset_width' => '0',
    'offset_height' => '0',
  );
}

function drulenium_takescreenshot_fb_settings($options) {
  $form = array();
  $form['snapshot_mode'] = array(
    '#type' => 'select',
    '#title' => t('Snapshot Type'),
    '#options' => array(
      'include' => t('Include'),
      'exclude' => t('Exclude'),
    ),
    '#description' => t('Choose "Include" to take the snapshot of only the specified HTML element.<br/>Choose "Exclude" to take snapshot of the whole page except the specified HTML elements.'),
  );
  $form['locator_type'] = array(
    '#type' => 'select',
    '#title' => t('Locator Type'),
    '#options' => array(
      'id' => t('ID'),
      'name' => t('Name'),
      'css' => t('CSS'),
      'xpath' => t('XPath'),
    ),
    '#description' => t('Type of the Locator of the element you want to include or exclude in the screenshot.<br/> Example CSS selector like {#food span.dairy}'),
  );
  $form['locator'] = array(
    '#type' => 'textfield',
    '#title' => t('Element Locator'),
    '#description' => t('The Locator(s).<br/>Multiple selectors can be coma seperated for exclusion.')
  );
  $form['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#description' => t('Width for the element. To override the automatically calculated width of the element.')
  );
  $form['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#description' => t('Height for the element. To override the automatically calculated height of the element.')
  );
  $form['offset_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width Offset'),
    '#description' => t('Extra width for the element. Negative values(like -10) for subtracting from the automatically calculated width of the element.')
  );
  $form['offset_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height Offset'),
    '#description' => t('Extra height for the element. Negative values(like -10) for subtracting from the automatically calculated height of the element.')
  );

  $defaults = drulenium_takescreenshot_defaults();

  foreach ( $form as $id => $f ) {
    $form[$id]['#default_value'] = isset($options[$id]) ? $options[$id] : $defaults[$id];
  }

  return $form;

}