You are here

function asset_formatter_options in Asset 5

Same name and namespace in other branches
  1. 6 inc/asset.routines.inc \asset_formatter_options()

Utility function to return an array of available formatters for a file suitable for FAPI #options

Parameters

$filename: Filename to retrieve options for. Will also work with just an extension.

1 call to asset_formatter_options()
asset_admin_formatter_defaults in ./asset.module
Menu callback for selection of default formatting options.

File

./asset.module, line 533

Code

function asset_formatter_options($type = '*', $filename = null) {
  $pos = strrpos($filename, '.');
  if ($pos === false) {

    // allow for case where extension is passed instead of filename
    $ext = $filename;
  }
  else {
    $ext = substr($filename, $pos + 1);
  }
  $formatters = asset_get_formatters();
  $options = array();
  if (is_array($formatters[$type][$ext])) {
    foreach ($formatters[$type][$ext] as $formatter) {
      $options[$formatter['module'] . ':' . $formatter['format']] = $formatter['name'];
    }
  }
  if (is_array($formatters[$type]['*'])) {
    foreach ($formatters[$type]['*'] as $formatter) {
      $options[$formatter['module'] . ':' . $formatter['format']] = $formatter['name'];
    }
  }
  if (is_array($formatters['*']['*'])) {
    foreach ($formatters['*']['*'] as $formatter) {
      $options[$formatter['module'] . ':' . $formatter['format']] = $formatter['name'];
    }
  }
  return $options;
}