You are here

function uploadfield_widget_settings_validate in Video 6.3

Same name and namespace in other branches
  1. 6.5 types/uploadfield/uploadfield_widget.inc \uploadfield_widget_settings_validate()
  2. 6.4 types/uploadfield/uploadfield_widget.inc \uploadfield_widget_settings_validate()

Implementation of CCK's hook_widget_settings($op = 'validate').

1 call to uploadfield_widget_settings_validate()
uploadfield_widget_settings in types/uploadfield/uploadfield.module
Implementation of CCK's hook_widget_settings().

File

types/uploadfield/uploadfield_widget.inc, line 144
uploadfield widget hooks and callbacks.

Code

function uploadfield_widget_settings_validate($widget) {

  // Check that only web images are specified in the callback.
  $extensions = array_filter(explode(' ', $widget['file_extensions']));
  $web_extensions = array(
    'mov',
    'mp4',
    '3gp',
    '3g2',
    'mpg',
    'mpeg',
    // quicktime
    'divx',
    //divx
    'rm',
    // realplayer
    'flv',
    'f4v',
    //flash player
    'swf',
    // swf player
    'dir',
    'dcr',
    // dcr player
    'asf',
    'wmv',
    'avi',
    'mpg',
    'mpeg',
    // windows media
    'ogg',
  );
  if (count(array_diff($extensions, $web_extensions))) {
    form_set_error('file_extensions', t('Only web-standard videos are supported through the video widget. If needing to upload other types of files, change the widget to use a standard file upload.'));
  }

  // Check that set video resolutions are valid.
  foreach (array(
    'default_width',
  ) as $numerics) {
    if (!empty($widget[$numerics]) && !preg_match('/^[0-9]+$/', $widget[$numerics])) {
      form_set_error($numerics, t('Please specify default width in integers only (e.g. 640).'));
    }
  }

  // Check that set resolutions are valid.
  foreach (array(
    'default_resolution',
  ) as $resolution) {
    if (!empty($widget[$resolution]) && !preg_match('/^[0-9]+:[0-9]+$/', $widget[$resolution])) {
      form_set_error($resolution, t('Please specify a resolution in the format WIDTH:HEIGHT (e.g. 16:9).'));
    }
  }

  // Check for convertor is installed
}