You are here

function imageeditor_widget_settings_form in Image Editor 6

Configuration form for editing Pixlr settings for a field instance.

1 call to imageeditor_widget_settings_form()
imageeditor_widget_settings_alter in ./imageeditor.module
Implementation of hook_widget_settings_alter().

File

./imageeditor.module, line 565
Allows online editing of images using different image editing services.

Code

function imageeditor_widget_settings_form($widget) {
  drupal_add_css(drupal_get_path('module', 'imageeditor') . '/imageeditor.css');
  $form['imageeditor'] = array(
    '#type' => 'fieldset',
    '#title' => t('Image editor'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 20,
    '#theme' => 'imageeditor_widget_settings_form',
  );
  $form['imageeditor']['editors'] = array(
    '#type' => 'item',
    '#title' => t('Enabled Image Editors'),
    '#description' => t('Choose enabled image editors for this field and their order.'),
  );
  $position = 0;
  foreach (imageeditor_editors() as $codename => $editor) {
    $position++;
    $form['imageeditor'][$codename . '_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => '<div class="imageeditor-editor ' . $editor['class'] . '"></div>' . $editor['name'] . ' (<a href="' . $editor['site'] . '" target="_blank">' . t('site') . '</a>)',
      '#default_value' => isset($widget[$codename . '_enabled']) ? $widget[$codename . '_enabled'] : 0,
    );
    $form['imageeditor'][$codename . '_description'] = array(
      '#type' => 'markup',
      '#value' => $editor['description'],
    );
    $form['imageeditor'][$codename . '_api_key'] = array(
      '#type' => 'markup',
      '#value' => $editor['api_key'] ? variable_get($editor['api_key_codename'], '') ? '<a href="/admin/settings/imageeditor">' . t('Already set') . '</a>' : '<a href="/admin/settings/imageeditor">' . t('Required') . '</a>' : t('Not needed'),
    );
    $form['imageeditor'][$codename . '_position'] = array(
      '#type' => 'textfield',
      '#default_value' => isset($widget[$codename . '_position']) ? $widget[$codename . '_position'] : $position,
      '#size' => 3,
      '#maxlenth' => 4,
      '#attributes' => array(
        'class' => 'imageeditor-position',
      ),
    );
  }
  $form['imageeditor']['uploaders'] = array(
    '#type' => 'item',
    '#title' => t('Enabled Upload services'),
    '#description' => t('Choose enabled upload services to upload images to if your images are not available from external network.'),
  );
  $position = 0;
  foreach (imageeditor_uploaders() as $codename => $uploader) {
    $position++;
    $form['imageeditor'][$codename . '_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => '<div class="imageeditor-uploader ' . $uploader['class'] . '"></div>' . $uploader['name'] . ' (<a href="' . $uploader['site'] . '" target="_blank">' . t('site') . '</a>)',
      '#default_value' => isset($widget[$codename . '_enabled']) ? $widget[$codename . '_enabled'] : 0,
    );
    $form['imageeditor'][$codename . '_description'] = array(
      '#type' => 'markup',
      '#value' => $uploader['description'],
    );
    $form['imageeditor'][$codename . '_api_key'] = array(
      '#type' => 'markup',
      '#value' => $uploader['api_key'] ? variable_get($uploader['api_key_codename'], '') ? '<a href="/admin/settings/imageeditor">' . t('Already set') . '</a>' : '<a href="/admin/settings/imageeditor">' . t('Required') . '</a>' : t('Not needed'),
    );
    $form['imageeditor'][$codename . '_position'] = array(
      '#type' => 'textfield',
      '#default_value' => isset($widget[$codename . '_position']) ? $widget[$codename . '_position'] : $position,
      '#size' => 3,
      '#maxlenth' => 4,
      '#attributes' => array(
        'class' => 'imageuploader-position',
      ),
    );
  }
  $form['imageeditor']['imageeditor_icons_position'] = array(
    '#type' => 'radios',
    '#title' => t('Icons position'),
    '#description' => t('Whether to show editing icons under the image preview or as a popup when you hover your mouse over the image preview.'),
    '#options' => array(
      t('Under the image preview'),
      t('Popup on the image preview when you hover over it'),
    ),
    '#default_value' => $widget['imageeditor_icons_position'] ? $widget['imageeditor_icons_position'] : 0,
    '#weight' => 20,
  );
  $form['imageeditor']['imageeditor_replace'] = array(
    '#type' => 'checkbox',
    '#title' => t('Replace original images'),
    '#description' => t('When editing images replace the original image with the edited one. You will be able to override this setting when using Picnik editor.'),
    '#default_value' => (bool) $widget['imageeditor_replace'],
    '#weight' => 30,
  );
  return $form;
}