You are here

function mediafront_form_field_ui_field_edit_form_alter in MediaFront 7

Same name and namespace in other branches
  1. 7.2 includes/mediafront.field.inc \mediafront_form_field_ui_field_edit_form_alter()

Implementation of hook_form_FORM_ID_alter().

File

includes/mediafront.filefield.inc, line 50

Code

function mediafront_form_field_ui_field_edit_form_alter(&$form, $form_state) {
  if ($form["#field"]["type"] == "image" || $form["#field"]["type"] == "file") {

    // See if this is an Image field.
    $image = $form["#field"]["type"] == "image";

    // Create the file field field set.
    $form['mediafront_filefield'] = array(
      "#type" => "fieldset",
      "#weight" => -1,
      "#title" => $image ? t('MediaFront: Image Settings') : t('MediaFront: Media Settings'),
    );

    // Get the file field.
    $field = mediafront_filefield_get($form['instance']['entity_type']['#value'], $form['instance']['bundle']['#value'], $form['#field']['field_name']);

    // Preset a different form if we are an image...
    if ($image) {

      // Get all of the image styles.
      $styles = image_styles();
      $options = array();
      $options['mediafront_original'] = t('Original Image');
      $options['none'] = t('None');
      foreach ($styles as $name => $style) {
        $options[$name] = $style['name'];
      }
      $description = t('Select the Image style that you would like to use for this MediaFront display.  <strong>Note: The first two selections are special fields which have the following behavior.</strong>');
      $description .= '<br/>';
      $description .= '<ul>';
      $description .= '<li><strong>' . t('Original Image') . '</strong>: ' . t('Only use the original image for the MediaFront Media Player') . '</li>';
      $description .= '<li><strong>' . t('None') . '</strong>: ' . t('Do not include this image field in the MediaFront Media Player') . '</li>';
      $description .= '</ul>';
      $form['mediafront_filefield']['node_preset'] = array(
        '#type' => 'select',
        '#title' => t('Media Preview Image'),
        '#description' => $description,
        '#options' => $options,
        '#default_value' => $field ? $field->node_preset : 'mediafront_original',
      );
      $form['mediafront_filefield']['thumb_preset'] = array(
        '#type' => 'select',
        '#title' => t('Media Thumbnail Image'),
        '#description' => $description,
        '#options' => $options,
        '#default_value' => $field ? $field->thumb_preset : 'mediafront_original',
      );
    }
    else {

      // Preset the media field form.
      $description = t('Select how you would like to use this file field for MediaFront.');
      $description .= '<br/>';
      $description .= '<ul>';
      $description .= '<li><strong>' . t('None') . '</strong>: ' . t('Do not include this file field in the MediaFront Media Player') . '</li>';
      $description .= '<li><strong>' . t('Introduction') . '</strong>: ' . t('This selection will make this file field be used as an introduction, before the commercial') . '</li>';
      $description .= '<li><strong>' . t('Commercial') . '</strong>: ' . t('To use this file field as the commercial for this media type') . '</li>';
      $description .= '<li><strong>' . t('Pre-Reel') . '</strong>: ' . t('The pre-reel is shown right before the main media content, but after the commercial.') . '</li>';
      $description .= '<li><strong>' . t('Media Content') . '</strong>: ' . t('The media content is the main media piece to be played to the user.') . '</li>';
      $description .= '<li><strong>' . t('Post-Reel') . '</strong>: ' . t('The post-reel is shown right after the main media content.') . '</li>';
      $description .= '</ul>';
      $form['mediafront_filefield']['media_type'] = array(
        '#type' => 'select',
        '#title' => t('Media Type'),
        '#description' => $description,
        '#options' => array(
          'none' => t('None'),
          'intro' => t('Introduction'),
          'commercial' => t('Commercial'),
          'prereel' => t('Pre-Reel'),
          'media' => t('Media Content'),
          'postreel' => t('Post-Reel'),
        ),
        '#default_value' => $field ? $field->media_type : 'media',
      );
    }
    $form['#submit'][] = 'mediafront_filefield_submit';
  }
}