You are here

function editor_note_field_settings_form in Editor Notes 7

Implements hook_field_settings_form().

Creates field settings form.

File

./editor_note.module, line 380
Main functionality for Editor Notes module.

Code

function editor_note_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form['notes_display_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Display mode'),
    '#required' => TRUE,
    '#description' => t('"Display list of notes per entity revision" means separate list of notes for each revision while "Display list of notes per entity" displays combined list of notes for all revisions.'),
    '#default_value' => isset($settings['notes_display_mode']) ? $settings['notes_display_mode'] : 'per_revision',
    '#options' => array(
      'per_revision' => t('Display list of notes per entity revision'),
      'per_entity' => t('Display list of notes per entity'),
    ),
  );
  $form['notes_permissions'] = array(
    '#type' => 'radios',
    '#title' => t('Field-level permissions'),
    '#required' => TRUE,
    '#description' => t('"Default" mode means configuring "Administer any editor note" permission on !permissions page while "Create only" mode can be used to prevent ability to update or edit notes.', array(
      '!permissions' => l(t('Permissions'), 'admin/people/permissions'),
    )),
    '#default_value' => isset($settings['notes_permissions']) ? $settings['notes_permissions'] : 'default',
    '#options' => array(
      'default' => t('Default'),
      'create_only' => t('Create only'),
    ),
  );
  $form['notes_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Size of Notes field (rows)'),
    '#default_value' => $settings['notes_size'],
    '#required' => TRUE,
    '#description' => t('Specify the visible number of lines in textarea for adding note.'),
    '#element_validate' => array(
      'element_validate_integer_positive',
    ),
  );
  $form['notes_placeholder'] = array(
    '#type' => 'textfield',
    '#title' => t('Placeholder for blank Notes field'),
    '#default_value' => $settings['notes_placeholder'],
    '#required' => FALSE,
    '#description' => t('Specifies a short hint that describes the expected value of the textarea.'),
  );
  $form['limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Display a specified number of items.'),
    '#default_value' => $settings['limit'],
    '#required' => TRUE,
    '#description' => t('Display a specified number of items. Set 0 for no limit.'),
    '#element_validate' => array(
      'editor_note_validate_integer_positive_or_zero',
    ),
  );
  $form['text_processing'] = array(
    '#type' => 'radios',
    '#title' => t('Text processing'),
    '#default_value' => isset($settings['text_processing']) ? $settings['text_processing'] : EDITOR_NOTE_DEFAULT_TEXT_FORMAT,
    '#options' => array(
      'plain_text' => t('Plain text'),
      'filtered_text' => t('Filtered text (user selects text format)'),
    ),
  );
  $form['notes_maxlength'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of characters user can enter'),
    '#default_value' => $settings['notes_maxlength'],
    '#required' => TRUE,
    '#description' => t('Specifies the maximum number of characters allowed in the textarea. Set 0 for no limit. This makes sense for "Plain text" text format only!'),
    '#element_validate' => array(
      'editor_note_validate_integer_positive_or_zero',
    ),
    '#states' => array(
      'invisible' => array(
        'input[name="field[settings][text_processing]"]' => array(
          'value' => 'filtered_text',
        ),
      ),
    ),
  );
  $form['order'] = array(
    '#type' => 'radios',
    '#title' => t('Notes ordering'),
    '#options' => array(
      'DESC' => t('Display recently updated notes first'),
      'ASC' => t('Display recently updated notes last'),
    ),
    '#default_value' => $settings['order'],
    '#description' => t('Set order of notes in the table.'),
  );
  $form['display'] = array(
    '#type' => 'checkbox',
    '#title' => t('Textarea above notes table'),
    '#default_value' => $settings['display'],
    '#description' => t('Display "Create a note" field above the notes table. Otherwise it will be shown below the notes table.'),
  );
  $form['pager'] = array(
    '#type' => 'fieldset',
    '#title' => t('Pagination'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
    '#states' => array(
      'invisible' => array(
        'input[name="field[settings][limit]"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $form['pager']['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable pagination'),
    '#default_value' => $settings['pager']['enabled'],
    '#description' => t('Whether to display pagination if number of notes added is greater that can be displayed.'),
  );
  $form['pager']['pager_below'] = array(
    '#type' => 'checkbox',
    '#title' => t('Pagination below notes table'),
    '#default_value' => $settings['pager']['pager_below'],
    '#description' => t('Displays pagination below the notes table, if unchecked pagination displays above the table.'),
    '#states' => array(
      'invisible' => array(
        'input[name="field[settings][pager][enabled]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['modal'] = array(
    '#type' => 'fieldset',
    '#title' => t('Configuration of modal popups'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
  );
  $form['modal']['overlay'] = array(
    '#type' => 'fieldset',
    '#title' => t('Overlay'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
  );
  $form['modal']['overlay']['opacity'] = array(
    '#type' => 'textfield',
    '#title' => t('Opacity'),
    '#default_value' => $settings['modal']['overlay']['opacity'],
    '#maxlength' => 3,
    '#required' => TRUE,
    '#element_validate' => array(
      'editor_note_validate_float_positive_or_zero',
    ),
    '#description' => t('Sets opacity level for overlay where 1 is not transparent at all, 0.6 - 0.4 is nearly 50% see-through, and 0 is completely transparent.'),
  );
  $form['modal']['overlay']['bgcolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Background color'),
    '#default_value' => $settings['modal']['overlay']['bgcolor'],
    '#element_validate' => array(
      'editor_note_validate_hex',
    ),
    '#maxlength' => 6,
    '#required' => TRUE,
    '#description' => t('Sets the background-color of overlay. Supports 6-digits HEX value. Do not include # sign. Example: 000000.'),
  );
  $form['modal']['edit'] = array(
    '#type' => 'fieldset',
    '#title' => t('"Edit" popup'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
  );
  $form['modal']['edit']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $settings['modal']['edit']['width'],
    '#element_validate' => array(
      'editor_note_validate_size',
    ),
    '#required' => TRUE,
    '#description' => t('Sets the width of an "Edit" popup. Accepts either numeric value (pixels) or "auto" (the browser calculates the width).'),
  );
  $form['modal']['edit']['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => $settings['modal']['edit']['height'],
    '#element_validate' => array(
      'editor_note_validate_size',
    ),
    '#required' => TRUE,
    '#description' => t('Sets the height of an "Edit" popup. Accepts either numeric value (pixels) or "auto" (the browser calculates the height).'),
  );
  $form['modal']['remove'] = array(
    '#type' => 'fieldset',
    '#title' => t('"Remove" popup'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
  );
  $form['modal']['remove']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $settings['modal']['remove']['width'],
    '#element_validate' => array(
      'editor_note_validate_size',
    ),
    '#required' => TRUE,
    '#description' => t('Sets the width of an "Remove" popup. Accepts either numeric value (pixels) or "auto" (the browser calculates the width).'),
  );
  $form['modal']['remove']['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => $settings['modal']['remove']['height'],
    '#element_validate' => array(
      'editor_note_validate_size',
    ),
    '#required' => TRUE,
    '#description' => t('Sets the height of an "Remove" popup. Accepts either numeric value (pixels) or "auto" (the browser calculates the height).'),
  );
  return $form;
}