You are here

function insert_field_widget_settings_form in Insert 7

Configuration form for editing insert settings for a field instance.

1 call to insert_field_widget_settings_form()
insert_form_field_ui_field_edit_form_alter in ./insert.module
Implements hook_form_alter().

File

./insert.module, line 372
Allows insertion of files, images, and other media directly into the body field by using an "Insert" button next to the uploaded file.

Code

function insert_field_widget_settings_form($field, $instance) {
  $settings = array_merge(unserialize(INSERT_DEFAULT_SETTINGS), array(
    'insert_absolute' => variable_get('insert_absolute_paths', unserialize(INSERT_DEFAULT_SETTINGS)['insert_absolute']),
  ), $instance['widget']['settings']);
  $form['insert'] = array(
    '#type' => 'fieldset',
    '#title' => t('Insert'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('These options allow the user to easily insert an HTML tags into text areas or WYSIWYG editors after uploading a file or image. The "Automatic" style will insert a <img> tag for images and a <a> tag for other files. Other styles may insert tags that may not match the file type.'),
    '#weight' => 20,
    '#parents' => array(
      'instance',
      'widget',
      'settings',
    ),
  );
  $form['insert']['insert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable insert button'),
    '#default_value' => $settings['insert'],
    '#description' => t('Enable the insert button and options for this widget.'),
    '#weight' => -10,
  );
  $form['insert']['insert_absolute'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use absolute paths'),
    '#default_value' => isset($settings['insert_absolute']) ? $settings['insert_absolute'] : variable_get('insert_absolute_paths', FALSE),
    '#description' => t('Includes the full URL prefix "@base_url" in all links and image tags.', array(
      '@base_url' => $GLOBALS['base_url'],
    )),
    '#weight' => -9,
  );
  $form['insert']['insert_styles'] = array(
    '#title' => t('Enabled insert styles'),
    '#type' => 'checkboxes',
    '#options' => insert_styles_list(),
    '#default_value' => !empty($settings['insert_styles']['<all>']) ? array_keys(insert_styles_list()) : $settings['insert_styles'],
    '#description' => t('Select which styles should be available when sending items to text areas. If no styles are selected, the option to use a style is not displayed. If all styles are selected, new styles will be enabled by default.'),
    '#element_validate' => array(
      'insert_field_widget_settings_styles_validate',
    ),
    '#theme' => 'insert_field_widget_settings_styles',
    '#weight' => 0,
  );
  $form['insert']['insert_default'] = array(
    '#title' => t('Default insert style'),
    '#type' => 'select',
    '#options' => insert_styles_list(),
    '#default_value' => $settings['insert_default'],
    '#description' => t('Select the default style which will be selected by default or used if no specific styles above are enabled.'),
    '#weight' => 1,
  );
  $form['insert']['insert_class'] = array(
    '#title' => t('Additional CSS classes'),
    '#type' => 'textfield',
    '#default_value' => $settings['insert_class'],
    '#description' => t('Add any classes that should be added to the item on output.'),
    '#weight' => 5,
  );
  $form['insert']['insert_width'] = array(
    '#title' => t('Maximum image insert width'),
    '#type' => 'textfield',
    '#size' => 10,
    '#field_suffix' => ' ' . t('pixels'),
    '#default_value' => $settings['insert_width'],
    '#description' => t('When inserting images, the height and width of images may be scaled down to fit within the specified width. Note that this does not resize the image, it only affects the HTML output. To resize images it is recommended to install the <a href="http://drupal.org/project/image_resize_filter">Image Resize Filter</a> module.'),
    '#weight' => 10,
  );
  return $form;
}