function videojs_settings_form_validate in Video.js (HTML5 Video Player) 7.3
Same name and namespace in other branches
- 6.2 includes/videojs.admin.inc \videojs_settings_form_validate()
- 6 includes/videojs.admin.inc \videojs_settings_form_validate()
- 7 includes/videojs.admin.inc \videojs_settings_form_validate()
- 7.2 includes/videojs.admin.inc \videojs_settings_form_validate()
Validation function to validate the videojs_settings_form() form.
1 string reference to 'videojs_settings_form_validate'
- videojs_settings_form in includes/
videojs.admin.inc - Menu callback; Provides the Video.js settings form.
File
- includes/
videojs.admin.inc, line 80 - Administrative pages for the Video.js module.
Code
function videojs_settings_form_validate($form, &$form_state) {
$form_state['values']['videojs_directory'] = rtrim($form_state['values']['videojs_directory'], '/');
$location = $form_state['values']['videojs_location'];
switch ($location) {
case 'path':
$form_state['videojs_version'] = videojs_get_version($form_state['values']['videojs_directory']);
$form_state['videojs_directory'] = $form_state['values']['videojs_directory'];
if (!$form_state['videojs_version']) {
form_error($form['location']['videojs_directory'], t('The directory specified does not seem to contain the Video.js library. Check to make sure that the video.js file is located within this directory.'));
}
break;
case 'libraries':
$form_state['videojs_directory'] = libraries_get_path('video-js');
$form_state['videojs_version'] = videojs_get_version($form_state['videojs_directory']);
if (empty($form_state['videojs_directory']) || !$form_state['videojs_version']) {
form_error($form['location']['videojs_location'], t('The Libraries API could not find the location of Video.js. Please put Video.js at the right location or select another location type.'));
}
break;
case 'cdn':
default:
$form_state['values']['videojs_cdn_version'] = trim($form_state['values']['videojs_cdn_version']);
$form_state['videojs_version'] = $form_state['values']['videojs_cdn_version'];
if (empty($form_state['videojs_version'])) {
form_error($form['location']['videojs_cdn_version'], t('You must set a version when using the Video.js CDN.'));
}
else {
$form_state['videojs_directory'] = videojs_utility::CDN_HOST . $form_state['videojs_version'];
$version = videojs_get_version($form_state['videojs_directory']);
if (empty($version)) {
form_error($form['location']['videojs_cdn_version'], t('@version does not seems to be a valid Video.js version, as @path could not be found.', array(
'@version' => $form_state['videojs_version'],
'@path' => $form_state['videojs_directory'] . '/video.js',
)));
$form_state['videojs_version'] = NULL;
}
}
break;
}
if (!empty($form_state['videojs_version']) && version_compare($form_state['videojs_version'], '4', '<')) {
form_error($form['location']['videojs_location'], t('Version @version of Video.js was found, but this version is not supported. Use version 4 of the Video.js player or another version of the Video.js module.', array(
'@version' => $form_state['videojs_version'],
)));
}
}