You are here

function mediafront_form_content_field_edit_form_alter in MediaFront 6.2

Same name and namespace in other branches
  1. 6 includes/mediafront.filefield.inc \mediafront_form_content_field_edit_form_alter()

Implementation of hook_form_FORM_ID_alter().

File

includes/mediafront.filefield.inc, line 45

Code

function mediafront_form_content_field_edit_form_alter(&$form, $form_state) {

  // See if this is a FileField.
  if ($form["#field"]["type"] == "filefield") {

    // See if this is an ImageField with ImageCache.
    $image = $form["#field"]["widget"]["type"] == "imagefield_widget" && module_exists('imagecache');

    // If this is a file field, or an image with ImageCache...
    if ($form["#field"]["widget"]["type"] == "filefield_widget" || $image) {

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

      // Get the file field.
      $field = mediafront_filefield_get($form['#field']['type_name'], $form['#field']['field_name']);

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

        // Get all of the presets.
        $presets = array();
        $pids = array();
        $presets['mediafront_original'] = t('Original Image');
        $presets['none'] = t('None');
        $result = db_query("SELECT * FROM {imagecache_preset}");
        while ($preset = db_fetch_object($result)) {
          $presets[$preset->presetid] = $preset->presetname;
          $pids[$preset->presetname] = $preset->presetid;
        }

        // Preset the media field form.
        $description = t('Select the ImageCache preset that you would like to use for this MediaFront image 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']['preview_image'] = array(
          '#type' => 'select',
          '#title' => t('Media Preview Image'),
          '#description' => $description,
          '#options' => $presets,
          '#default_value' => mediafront_filefield_get_default($field, 'node_preset', $pids),
        );
        $form['mediafront_filefield']['thumb_image'] = array(
          '#type' => 'select',
          '#title' => t('Media Thumbnail Image'),
          '#description' => $description,
          '#options' => $presets,
          '#default_value' => mediafront_filefield_get_default($field, 'thumb_preset', $pids),
        );
      }
      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';
    }
  }
}