You are here

function media_get_fields in D7 Media 6

Get all fields that can be enabled on a field type.

Parameters

string $field_type: The field type to get items for.

string $function_type: The kind of functionality being looked for.

Return value

array Array of full registration objects.

2 calls to media_get_fields()
media_active_fields_for_node_type in ./media.module
Get a list of fields for the requested node type.
media_settings_content_type in ./media_settings.inc
Provide per content type settings.

File

./media.module, line 232
Media API

Code

function media_get_fields($field_type, $function_type = 'resource') {
  static $data;

  // Do we have cached version?
  if ($data[$field_type][$function_type]) {
    return $data[$field_type][$function_type];
  }
  $data = array();

  // Get all the registered modules.
  foreach (media_get_registered_modules() as $id => $registration) {

    // Check to see if this registration supports this function type.
    if ($registration['kind'] == $function_type) {

      // Now look for the fields.
      if ($registration['fields']) {
        foreach ($registration['fields'] as $field) {

          // If this registration supports this field type, add it to the
          // returned array.
          if ($field == $field_type) {
            $data[$field_type][$function_type][$id] = $registration;
          }
        }
      }
    }
  }
  return $data[$field_type][$function_type];
}