You are here

function insert_widget_form in Insert 6

Configuration form for editing insert settings for a field instance.

1 call to insert_widget_form()
insert_widget_settings_alter in ./insert.module
Implementation of hook_widget_settings_alter().

File

./insert.module, line 291
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_widget_form($widget) {
  $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' => 15,
  );
  $form['insert']['insert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable insert button'),
    '#default_value' => (bool) $widget['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($widget['insert_absolute']) ? $widget['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($widget['insert_styles']['<all>']) ? array_keys(insert_styles_list()) : (array) $widget['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' => (array) $widget['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' => empty($widget['insert_class']) ? '' : $widget['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' => empty($widget['insert_width']) ? '' : $widget['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;
}