function asset_formatter_options in Asset 6
Same name and namespace in other branches
- 5 asset.module \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 inc/
asset.admin.inc - Menu callback for selection of default formatting options.
File
- inc/
asset.routines.inc, line 21
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;
}