You are here

function manualcrop_field_widget_settings_form in Manual Crop 7

Add the Manual Crop field widget settings.

Parameters

$widget_type: Widget type.

$settings: Current settings.

Return value

Form elements to add.

2 calls to manualcrop_field_widget_settings_form()
manualcrop_form_field_ui_field_edit_form_alter in ./manualcrop.admin.inc
Implements hook_form_FORM_ID_alter().
manualcrop_form_file_entity_file_type_form_alter in ./manualcrop.admin.inc
Implements hook_form_FORM_ID_alter().

File

./manualcrop.admin.inc, line 629
Admin functionality for the Manual Crop module.

Code

function manualcrop_field_widget_settings_form($widget_type, $settings) {
  $form = array();

  // Get a list of styles.
  $style_options = manualcrop_styles_with_crop(FALSE, NULL, TRUE);

  // Add the Manual Crop fieldset.
  $form['manualcrop'] = array(
    '#type' => 'fieldset',
    '#title' => t('Manual Crop'),
    '#description' => t(''),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 25,
    '#parents' => array(
      'instance',
      'widget',
      'settings',
    ),
  );
  $form['manualcrop']['manualcrop_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable'),
    '#description' => t('Enable the Manual Crop features. To enable Manual Crop for this field, you must configure a Manual Crop image effect on at least one image style.'),
    '#default_value' => $settings['manualcrop_enable'] && !empty($style_options),
    '#disabled' => empty($style_options),
  );
  $form['manualcrop']['manualcrop_keyboard'] = array(
    '#type' => 'checkbox',
    '#title' => t('Keyboard shortcuts'),
    '#description' => t('Enable the keyboard shortcuts.'),
    '#default_value' => $settings['manualcrop_keyboard'],
  );
  if (manualcrop_supported_widgets($widget_type, 'thumblist')) {
    $form['manualcrop']['manualcrop_thumblist'] = array(
      '#type' => 'checkbox',
      '#title' => t('List thumbs'),
      '#description' => t('Instead of showing a button or selection list, show all thumbnails (this will disable the preview thumbnail).'),
      '#default_value' => $settings['manualcrop_thumblist'],
    );
  }
  if (manualcrop_supported_widgets($widget_type, 'inline_crop')) {
    $form['manualcrop']['manualcrop_inline_crop'] = array(
      '#type' => 'checkbox',
      '#title' => t('Inline cropping'),
      '#description' => t('Instead of opening an overlay, use inline cropping.'),
      '#default_value' => $settings['manualcrop_inline_crop'],
    );
  }
  $form['manualcrop']['manualcrop_crop_info'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show crop info'),
    '#description' => t('Show the crop selection details.'),
    '#default_value' => $settings['manualcrop_crop_info'],
  );
  $form['manualcrop']['manualcrop_instant_preview'] = array(
    '#type' => 'checkbox',
    '#title' => t('Instant preview'),
    '#description' => t('Show an instant preview of the crop selection.'),
    '#default_value' => $settings['manualcrop_instant_preview'],
  );
  if (manualcrop_supported_widgets($widget_type, 'instant_crop')) {
    $form['manualcrop']['manualcrop_instant_crop'] = array(
      '#type' => 'checkbox',
      '#title' => t('Crop after upload'),
      '#description' => t('Open the cropping tool immediately after a file upload. Please note that this feature requires a single image style to be enabled. Also it will only be applied for screens of at least 768px width.'),
      '#default_value' => $settings['manualcrop_instant_crop'],
    );
  }
  $form['manualcrop']['manualcrop_default_crop_area'] = array(
    '#type' => 'checkbox',
    '#title' => t('Default crop area'),
    '#description' => t('Create a default crop area when opening the cropping tool for uncropped images.'),
    '#default_value' => $settings['manualcrop_default_crop_area'],
  );
  $form['manualcrop']['manualcrop_maximize_default_crop_area'] = array(
    '#type' => 'checkbox',
    '#title' => t('Maximize default crop area'),
    '#description' => t('Maximize the default crop area.'),
    '#default_value' => $settings['manualcrop_maximize_default_crop_area'],
    '#states' => array(
      'disabled' => array(
        'input[name="instance[widget][settings][manualcrop_default_crop_area]"]' => array(
          'checked' => FALSE,
        ),
        'input[name="instance[widget][settings][manualcrop_default_crop_area]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['manualcrop']['manualcrop_styles_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Styles list mode'),
    '#options' => array(
      'include' => t('Include selected styles'),
      'exclude' => t('Exclude selected styles'),
    ),
    '#default_value' => $settings['manualcrop_styles_mode'],
  );
  $style_options = array_map('check_plain', $style_options);
  $form['manualcrop']['manualcrop_styles_list'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Styles list'),
    '#description' => t('Select all styles that should be shown or hidden (as selected above) in the widget. Please note that hiding styles will override requiring them and existing cropping selections will be kept.'),
    '#options' => $style_options,
    '#default_value' => $settings['manualcrop_styles_list'],
    '#element_validate' => array(
      'manualcrop_checkboxes_filter',
    ),
    '#multicolumn' => array(
      'width' => 3,
    ),
  );
  $form['manualcrop']['manualcrop_require_cropping'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Required croppings'),
    '#description' => t('Select all styles that must have a crop selection.'),
    '#options' => $style_options,
    '#default_value' => $settings['manualcrop_require_cropping'],
    '#element_validate' => array(
      'manualcrop_checkboxes_filter',
    ),
    '#multicolumn' => array(
      'width' => 3,
    ),
  );
  return $form;
}