You are here

function data_get_views_handler_options in Data 6

Same name and namespace in other branches
  1. 8 data.views.inc \data_get_views_handler_options()
  2. 7 data.views.inc \data_get_views_handler_options()

Return all available field handlers.

Parameters

$type: Optional: the view handler type whose options should be provided ('field', 'filter', 'sort', 'argument'). If omitted, a full array keyed on type is returned.

$reset: Boolean to reset the static cache.

Return value

An array suitable for use as options in a FormAPI element.

1 call to data_get_views_handler_options()
data_ui_views_form in data_ui/data_ui.admin.inc
Views handler configuration form.

File

./data.views.inc, line 123
Views hooks and utility functions.

Code

function data_get_views_handler_options($type = NULL, $reset = FALSE) {
  static $handlers;
  if (!isset($handlers) || $reset) {
    $handlers = array();
    module_load_include('inc', 'views', 'includes/base');
    module_load_include('inc', 'views', 'includes/handlers');
    $available_handlers = views_discover_handlers();
    $handlers = array(
      'field',
      'filter',
      'argument',
      'sort',
    );
    foreach ($available_handlers as $available_handler => $def) {
      foreach ($handlers as $handler) {

        // Look for handler names of the form 'views_handler_TYPE.*'.
        $pattern = '/^views_handler_';
        $pattern .= $handler;
        $pattern .= '([_][^_.]+)*$/';
        if (preg_match($pattern, $available_handler)) {
          $handlers[$handler][$available_handler] = $available_handler;
        }
      }
    }

    // Allow other modules to alter the list of available handlers.
    drupal_alter('data_views_handlers', $handlers);
  }
  return isset($type) && isset($handlers[$type]) ? $handlers[$type] : $handlers;
}