You are here

function asset_get_formatters in Asset 6

Same name and namespace in other branches
  1. 5.2 asset.module \asset_get_formatters()
  2. 5 asset.module \asset_get_formatters()

Utility function to retrieve a list of all available formatters.

Return value

array returns an array keyed by filetype(extension) with elements as arrays of format information.

12 calls to asset_get_formatters()
asset_admin_formatter_defaults in inc/asset.admin.inc
Menu callback for selection of default formatting options.
asset_formatter_options in inc/asset.routines.inc
Utility function to return an array of available formatters for a file suitable for FAPI #options
asset_get_default_formatter in inc/asset.routines.inc
Get the default formatter for a given type and extension
asset_js_preview in ./asset.module
Menu Callback from javascript to print an assets preview
asset_views_handler_field_asset in ./asset_views.inc

... See full list

File

./asset.module, line 271

Code

function asset_get_formatters($reset = false) {
  static $formatters;
  if (empty($formatters) || $reset) {
    $cache = cache_get('asset_formatters');
    if ($reset || empty($cache) || empty($cache->data)) {
      $formatters = array();
      foreach (module_implements('asset_formatter') as $module) {
        $list = module_invoke($module, 'asset_formatter', 'info');
        foreach ((array) $list as $key => $data) {
          $data['module'] = $module;
          $data['format'] = $key;
          foreach ($data['types'] as $type => $exts) {
            foreach ($exts as $ext) {
              $formatters[$type][$ext][] = $data;
            }
          }
        }
      }
      cache_set('asset_formatters', $formatters);
    }
    else {
      $formatters = $cache->data;
    }
  }
  return $formatters;
}