You are here

function emfield_allowed_emapi_providers in Embedded Media Field 6.3

Return a list of providers allowed for a specific field.

Parameters

array $field: (Optional) The field we're checking for providers.

Return value

If $field is NULL, then return all supported providers. Otherwise, we'll return the subset of providers allowed by this field.

1 call to emfield_allowed_emapi_providers()
emfield_widget in ./emfield.module
Implementation of hook_widget()

File

./emfield.module, line 291
Embedded Media Field is a CCK-based framework for embedding media files.

Code

function emfield_allowed_emapi_providers($field = NULL) {
  $classes = emapi_get_provider_classes();
  $providers = $all_providers = array();
  foreach ($classes as $class) {
    $providers[$class['class_name']] = $all_providers[$class['class_name']] = $class['class_name'];
  }
  $field_providers = isset($field['widget']['providers']) ? $field['widget']['providers'] : (isset($field['providers']) ? $field['providers'] : array());
  foreach ($field_providers as $provider => $allowed) {
    if (!$allowed) {
      unset($providers[$provider]);
    }
  }
  if (!empty($providers)) {
    return $providers;
  }
  return $all_providers;
}