You are here

function custom_formatters_formatters in Custom Formatters 6

Get an array of all custom formatters and their settings.

Parameters

reset: if set to TRUE it will clear the formatters cache.

Return value

array of formatters.

9 calls to custom_formatters_formatters()
content_multigroup_custom_formatters_form_alter in includes/content_multigroup.inc
Implements hook_custom_formatters_form_alter().
custom_formatters_ds_fields_alter in includes/ds.inc
Implements hook_type_alter().
custom_formatters_features_export_options in includes/features.inc
Implements hook_features_export_options().
custom_formatters_field_formatter_info in ./custom_formatters.module
Implements hook_field_formatter_info().
custom_formatters_formatter in ./custom_formatters.module
Load a formatter by name.

... See full list

File

./custom_formatters.module, line 281
Contains core functions for the Custom Formatters module.

Code

function custom_formatters_formatters($reset = FALSE, $limit = 0) {
  static $formatters = array();

  // Clear caches if $reset is TRUE;
  if ($reset) {
    $formatters = array();
    custom_formatters_clear_cache();
  }

  // Return formatters if the array is populated.
  if (!empty($formatters)) {
    return $formatters;
  }

  // Include default formatters from Features.
  if (module_exists('features')) {
    features_include_defaults('custom_formatters');
  }

  // Get formatters from modules.
  $results = module_invoke_all('custom_formatters_defaults');
  foreach ($results as $formatter) {
    $formatters[$formatter['name']] = (object) $formatter;
    $formatters[$formatter['name']]->source = 'module';
  }

  // Get formatters from database.
  $query = 'SELECT * FROM {formatters} ORDER BY label';
  $result = !$limit ? db_query($query) : pager_query($query, $limit);
  while ($formatter = db_fetch_object($result)) {
    $override = isset($formatters[$formatter->name]);
    $formatters[$formatter->name] = $formatter;
    $formatters[$formatter->name]->source = 'database';
    if ($override) {
      $formatters[$formatter->name]->override = $override;
    }
  }

  // Sort formatters.
  $sorted = array(
    array(),
    array(),
  );
  foreach ($formatters as $formatter) {
    $sorted[$formatter->status]["{$formatter->label}_{$formatter->name}"] = $formatter;
  }
  $formatters = array();
  foreach (array_reverse($sorted) as $status) {
    ksort($status);
    foreach ($status as $formatter) {
      $formatters[$formatter->name] = $formatter;
    }
  }
  return $formatters;
}