You are here

function filefield_sources_info in FileField Sources 7

Same name and namespace in other branches
  1. 8 filefield_sources.module \filefield_sources_info()
  2. 6 filefield_sources.module \filefield_sources_info()

Load hook_filefield_sources_info() data from all modules.

5 calls to filefield_sources_info()
filefield_sources_field_process in ./filefield_sources.module
A #process callback to extend the filefield_widget element type.
filefield_sources_field_validate in ./filefield_sources.module
An #element_validate function to run source validations.
filefield_sources_field_value in ./filefield_sources.module
A #filefield_value_callback to run source value callbacks.
filefield_sources_form in ./filefield_sources.module
Configuration form for editing FileField Sources settings for a widget.
filefield_sources_list in ./filefield_sources.module
Create a list of FileField Sources by name, suitable for a select list.

File

./filefield_sources.module, line 339
Extend FileField to allow files from multiple sources.

Code

function filefield_sources_info($include_default = TRUE) {

  // Cache the expensive part.
  $cache =& drupal_static(__FUNCTION__, array());
  if (empty($cache)) {
    $cache['upload'] = array(
      'name' => t('Upload (default)'),
      'label' => t('Upload'),
      'description' => t('Upload a file from your computer.'),
      'weight' => -10,
    );

    // Add the providing module name to each source.
    foreach (module_implements('filefield_sources_info') as $module) {
      $function = $module . '_filefield_sources_info';
      $additions = $function();
      foreach ($additions as $source_name => $source_info) {
        $additions[$source_name]['module'] = $module;
      }
      $cache += $additions;
    }
    drupal_alter('filefield_sources_info', $cache);
    uasort($cache, '_filefield_sources_sort');
  }

  // Remove the upload option from the returned value if needed.
  $info = $cache;
  if (!$include_default) {
    unset($info['upload']);
  }
  return $info;
}