You are here

function asset_get_formatters in Asset 5

Same name and namespace in other branches
  1. 5.2 asset.module \asset_get_formatters()
  2. 6 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.

7 calls to asset_get_formatters()
asset_admin_formatter_defaults in ./asset.module
Menu callback for selection of default formatting options.
asset_formatter_options in ./asset.module
Utility function to return an array of available formatters for a file suitable for FAPI #options
asset_get_default_formatter in ./asset.module
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 501

Code

function asset_get_formatters($reset = FALSE) {
  static $formatters;
  if (!isset($formatters) || $reset) {
    if (!$reset && ($cache = cache_get('asset_formatters')) && !empty($cache->data)) {
      $formatters = unserialize($cache->data);
    }
    else {
      $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', 'cache', serialize($formatters));
    }
  }
  return $formatters;
}