You are here

function custom_formatters_field_formatter_info in Custom Formatters 7.2

Same name and namespace in other branches
  1. 6 custom_formatters.module \custom_formatters_field_formatter_info()

Implements hook_field_formatter_info().

File

includes/field.inc, line 11
Field module integration.

Code

function custom_formatters_field_formatter_info() {
  $formatters = array();
  $settings = variable_get('custom_formatters_settings', array(
    'label_prefix' => TRUE,
    'label_prefix_value' => t('Custom'),
  ));
  foreach (custom_formatters_crud_load_all(TRUE) as $key => $formatter) {
    $label = $settings['label_prefix'] ? "{$settings['label_prefix_value']}: {$formatter->label}" : $formatter->label;
    $formatters["custom_formatters_{$key}"] = array(
      'label' => $label,
      'field types' => drupal_explode_tags($formatter->field_types),
    );
    if (isset($formatter->fapi)) {
      ob_start();
      eval($formatter->fapi);
      ob_get_clean();
      if (isset($form)) {
        $formatters["custom_formatters_{$key}"]['settings'] = array();
        foreach ($form as $form_key => $element) {
          $formatters["custom_formatters_{$key}"]['settings'][$form_key] = isset($element['#default_value']) ? $element['#default_value'] : '';
        }
      }
    }
  }
  return $formatters;
}