You are here

function emvideo_widget_settings in Embedded Media Field 6.2

Same name and namespace in other branches
  1. 6.3 contrib/emvideo/emvideo.module \emvideo_widget_settings()
  2. 6 contrib/emvideo/emvideo.module \emvideo_widget_settings()
2 calls to emvideo_widget_settings()
_eminline_default_filter_settings in contrib/eminline/eminline.module
_eminline_url_settings in contrib/eminline/eminline.module
Settings form for filter.

File

contrib/emvideo/emvideo.module, line 454
Embedded Video module is a handler for 3rd party video files.

Code

function emvideo_widget_settings($op, $widget) {
  switch ($op) {
    case 'form':
      if ($widget['type'] == 'emvideo_textfields') {
        $form = (array) emfield_emfield_widget_settings('form', $widget, 'emvideo');
        $width = variable_get('emvideo_default_video_width', EMVIDEO_DEFAULT_VIDEO_WIDTH);
        $height = variable_get('emvideo_default_video_height', EMVIDEO_DEFAULT_VIDEO_HEIGHT);
        $form['video'] = array(
          '#type' => 'fieldset',
          '#title' => t('Video Display Settings'),
          '#description' => t('These settings control how this video is displayed in its full size, which defaults to @widthx@height.', array(
            '@width' => $width,
            '@height' => $height,
          )),
          '#collapsible' => TRUE,
          '#collapsed' => FALSE,
        );
        $form['video']['video_width'] = array(
          '#type' => 'textfield',
          '#title' => t('Video display width'),
          '#default_value' => empty($widget['video_width']) ? $width : $widget['video_width'],
          '#required' => TRUE,
          '#description' => t('The width of the video. It defaults to @width.', array(
            '@width' => $width,
          )),
        );
        $form['video']['video_height'] = array(
          '#type' => 'textfield',
          '#title' => t('Video display height'),
          '#default_value' => empty($widget['video_height']) ? $height : $widget['video_height'],
          '#required' => TRUE,
          '#description' => t('The height of the video. It defaults to @height.', array(
            '@height' => $height,
          )),
        );
        $form['video']['video_autoplay'] = array(
          '#type' => 'checkbox',
          '#title' => t('Autoplay'),
          '#default_value' => empty($widget['video_autoplay']) ? '' : $widget['video_autoplay'],
          '#description' => t('If supported by the provider, checking this box will cause the video to automatically begin after the video loads when in its full size.'),
        );
        $width = variable_get('emvideo_default_preview_width', EMVIDEO_DEFAULT_PREVIEW_WIDTH);
        $height = variable_get('emvideo_default_preview_height', EMVIDEO_DEFAULT_PREVIEW_HEIGHT);
        $form['preview'] = array(
          '#type' => 'fieldset',
          '#title' => t('Video Preview Settings'),
          '#description' => t('These settings control how this video is displayed in its preview size, which defaults to @widthx@height.', array(
            '@width' => $width,
            '@height' => $height,
          )),
          '#collapsible' => TRUE,
          '#collapsed' => FALSE,
        );
        $form['preview']['preview_width'] = array(
          '#type' => 'textfield',
          '#title' => t('Video preview width'),
          '#default_value' => empty($widget['preview_width']) ? $width : $widget['preview_width'],
          '#required' => TRUE,
          '#description' => t('The width of the preview video. It defaults to @width.', array(
            '@width' => $width,
          )),
        );
        $form['preview']['preview_height'] = array(
          '#type' => 'textfield',
          '#title' => t('Video preview height'),
          '#default_value' => empty($widget['preview_height']) ? $height : $widget['preview_height'],
          '#required' => TRUE,
          '#description' => t('The height of the preview video. It defaults to @height.', array(
            '@height' => $height,
          )),
        );
        $form['preview']['preview_autoplay'] = array(
          '#type' => 'checkbox',
          '#title' => t('Autoplay'),
          '#default_value' => empty($widget['preview_autoplay']) ? '' : $widget['preview_autoplay'],
          '#description' => t('If supported by the provider, checking this box will cause the video to automatically begin after the video loads when in its preview size.'),
        );
        $width = variable_get('emvideo_default_thumbnail_width', EMVIDEO_DEFAULT_THUMBNAIL_WIDTH);
        $height = variable_get('emvideo_default_thumbnail_height', EMVIDEO_DEFAULT_THUMBNAIL_HEIGHT);
        $form['tn'] = array(
          '#type' => 'fieldset',
          '#title' => t('Thumbnail'),
          '#description' => t('When displayed as a thumbnail, these settings control the image returned. Note that not all 3rd party video content providers offer thumbnails, and others may require an API key or other requirements. More information from the <a href="@settings">settings page</a>. The default size for thumbnails is @widthx@height.', array(
            '@settings' => url('admin/content/emfield'),
            '@width' => $width,
            '@height' => $height,
          )),
          '#collapsible' => TRUE,
          '#collapsed' => FALSE,
        );
        $form['tn']['thumbnail_width'] = array(
          '#type' => 'textfield',
          '#title' => t('Thumbnail width'),
          '#default_value' => empty($widget['thumbnail_width']) ? $width : $widget['thumbnail_width'],
          '#required' => TRUE,
          '#description' => t('The width of the thumbnail. It defaults to @width.', array(
            '@width' => $width,
          )),
        );
        $form['tn']['thumbnail_height'] = array(
          '#type' => 'textfield',
          '#title' => t('Thumbnail height'),
          '#default_value' => empty($widget['thumbnail_height']) ? $height : $widget['thumbnail_height'],
          '#required' => TRUE,
          '#description' => t('The height of the thumbnail. It defaults to @height.', array(
            '@height' => $height,
          )),
        );

        // Construct the description, hinting of Embedded Media Thumbnail if it
        // is not enabled.
        $default_path = variable_get('emvideo_default_thumbnail_path', '');
        $description = t("Path to a local default thumbnail image for cases when a thumbnail can't be found. For example, you might have a default thumbnail at %files.", array(
          '%files' => 'files/thumbnail.png',
        ));
        if (!module_exists('emthumb')) {
          $description .= ' ' . t('You may be interested in activating the Embedded Media Thumbnails module as well, which will allow you to specify custom thumbnails on a per-node basis.');
        }
        $form['tn']['thumbnail_default_path'] = array(
          '#type' => 'textfield',
          '#title' => t('Default thumbnail path'),
          '#default_value' => empty($widget['thumbnail_default_path']) ? $default_path : $widget['thumbnail_default_path'],
          '#description' => $description,
        );
        $form['tn']['thumbnail_link_title'] = array(
          '#type' => 'textfield',
          '#title' => t('Thumbnail title'),
          '#default_value' => isset($widget['thumbnail_link_title']) ? $widget['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')),
          '#description' => t("The title/alt to display when hovering over a thumbnail, or if an image is broken."),
        );
        if (module_exists('token')) {
          $form['tn']['thumbnail_link_title']['#suffix'] = theme('token_help', 'global');
        }
        $form['meta_data'] = array(
          '#type' => 'fieldset',
          '#title' => t('Additional fields'),
          '#description' => t('Makes addition fields available for describing your content.'),
          '#collapsible' => TRUE,
          '#collapsed' => FALSE,
        );
        $form['meta_data']['meta_fields'] = array(
          '#type' => 'checkboxes',
          '#title' => t('Additional fields'),
          '#multiple' => TRUE,
          '#default_value' => isset($widget['meta_fields']) ? $widget['meta_fields'] : array(),
          '#options' => array(
            'title' => t('Title'),
            'description' => t('Description'),
          ),
        );
      }
      return $form;
    case 'validate':
      if ($widget['type'] == 'emvideo_textfields') {
        if (!is_numeric($widget['video_width']) || intval($widget['video_width']) != $widget['video_width'] || $widget['video_width'] < 1) {
          form_set_error('video_width', t('"Video width" must be a positive integer.'));
        }
        if (!is_numeric($widget['video_height']) || intval($widget['video_height']) != $widget['video_height'] || $widget['video_height'] < 1) {
          form_set_error('video_height', t('"Video height" must be a positive integer.'));
        }
        if (!is_numeric($widget['preview_width']) || intval($widget['preview_width']) != $widget['preview_width'] || $widget['preview_width'] < 1) {
          form_set_error('preview_width', t('"Preview width" must be a positive integer.'));
        }
        if (!is_numeric($widget['preview_height']) || intval($widget['preview_height']) != $widget['preview_height'] || $widget['preview_height'] < 1) {
          form_set_error('preview_height', t('"Preview height" must be a positive integer.'));
        }
        if (!is_numeric($widget['thumbnail_width']) || intval($widget['thumbnail_width']) != $widget['thumbnail_width'] || $widget['thumbnail_width'] < 1) {
          form_set_error('thumbnail_width', t('"Thumbnail width" must be a positive integer.'));
        }
        if (!is_numeric($widget['thumbnail_height']) || intval($widget['thumbnail_height']) != $widget['thumbnail_height'] || $widget['thumbnail_height'] < 1) {
          form_set_error('thumbnail_height', t('"Thumbnail height" must be a positive integer.'));
        }
      }
      break;
    case 'save':
      if ($widget['widget_type'] == 'emvideo_textfields') {
        $columns = array(
          'video_width',
          'video_height',
          'video_autoplay',
          'preview_width',
          'preview_height',
          'preview_autoplay',
          'thumbnail_width',
          'thumbnail_height',
          'thumbnail_default_path',
          'thumbnail_link_title',
          'meta_fields',
        );
        $columns = array_merge($columns, emfield_emfield_widget_settings('save', $widget, 'emvideo'));
        return $columns;
      }
      break;
  }
}