You are here

public static function Preset::getEnabledPresets in Video 7.2

1 call to Preset::getEnabledPresets()
Transcoder::executeConversion in includes/Transcoder.inc
This helper function will help to execute video conversion job by loading job from the database and once it completed saving its data in to the database.

File

includes/Preset.inc, line 8
Class file used to store video presets on the video.

Class

Preset
@file Class file used to store video presets on the video.

Code

public static function getEnabledPresets($field_name = NULL) {
  if ($field_name != NULL) {
    $field = field_info_field($field_name);
    $names = $field['settings']['presets'];
    if (empty($names)) {
      return self::getEnabledPresets();
    }
  }
  else {
    $names = variable_get('video_preset', array());
  }
  $names = array_filter($names);
  $presets = array();
  $all = self::getAllPresets();
  $error = array();
  foreach ($names as $name) {
    if (isset($all[$name])) {
      $presets[$name] = $all[$name];
    }
    else {
      $error[] = $name;
    }
  }

  // Display a warning when presets are missing.
  if (!empty($error)) {
    $params = array(
      '%preset-names' => implode(', ', $error),
    );
    $message = t('The following selected presets are no longer available: %preset-names.', $params);

    // Log to the watchdog when none of the presets are available.
    if (empty($presets)) {
      watchdog('video', 'The following selected presets are no longer available: %preset-names.', $params);
    }
    if (!empty($field)) {
      $message .= ' ' . t('Please update the @field-name field settings.', array(
        '@field-name' => $field_name,
      ));
    }
    else {
      $message .= ' ' . t('Please update the Video module settings.');
    }
    drupal_set_message($message, 'warning', FALSE);
  }

  // When no presets are available and a field was supplied, try without a field.
  if (empty($presets) && !empty($field)) {
    return self::getEnabledPresets();
  }
  return $presets;
}