You are here

function views_php_handler_field::options_form in Views PHP 7.2

Same name and namespace in other branches
  1. 6 plugins/views/views_php_handler_field.inc \views_php_handler_field::options_form()
  2. 7 plugins/views/views_php_handler_field.inc \views_php_handler_field::options_form()

Implements views_handler#options_form().

Overrides views_handler_field::options_form

File

plugins/views/views_php_handler_field.inc, line 36

Class

views_php_handler_field
A handler to provide a field that is constructed by the administrator using PHP.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form += views_php_form_element($this, array(
    'use_php_setup',
    t('Use setup code'),
    t('If checked, you can provide PHP code to be run once right before execution of the view. This may be useful to define functions to be re-used in the value and/or output code.'),
  ), array(
    'php_setup',
    t('Setup code'),
    t('Code to run right before execution of the view.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
  ));
  $form += views_php_form_element($this, FALSE, array(
    'php_value',
    t('Value code'),
    t('Code to construct the value of this field.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
    '$row',
  ));
  $form += views_php_form_element($this, array(
    'use_php_click_sortable',
    t('Enable click sort'),
    t('If checked, you can use PHP code to enable click sort on the field.'),
  ), array(
    'php_click_sortable',
    t('Click sort code'),
    t('The comparison code must return an integer less than, equal to, or greater than zero if the first row should respectively appear before, stay where it was compared to, or appear after the second row.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
    '$row1' => t('Data of row.'),
    '$row2' => t('Data of row to compare against.'),
  ));
  $form['use_php_click_sortable']['#type'] = 'select';
  $form['use_php_click_sortable']['#options'] = array(
    self::CLICK_SORT_DISABLED => t('No'),
    self::CLICK_SORT_NUMERIC => t('Sort numerically'),
    self::CLICK_SORT_ALPHA => t('Sort alphabetically'),
    self::CLICK_SORT_ALPHA_CASE => t('Sort alphabetically (case insensitive)'),
    self::CLICK_SORT_NAT => t('Sort using a "natural order" algorithm'),
    self::CLICK_SORT_NAT_CASE => t('Sort using a "natural order" algorithm (case insensitive)'),
    self::CLICK_SORT_PHP => t('Sort using custom PHP code'),
  );
  $form['use_php_click_sortable']['#default_value'] = $this->options['use_php_click_sortable'];
  $form['php_click_sortable']['#states'] = array(
    'visible' => array(
      ':input[name="options[use_php_click_sortable]"]' => array(
        'value' => (string) self::CLICK_SORT_PHP,
      ),
    ),
  );
  $form += views_php_form_element($this, FALSE, array(
    'php_output',
    t('Output code'),
    t('Code to construct the output of this field.'),
    TRUE,
  ), array(
    '$view',
    '$handler',
    '$static',
    '$row',
    '$data',
    '$value' => t('Value of this field.'),
  ));
}