You are here

function _ctools_context_get_converters in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \_ctools_context_get_converters()

Get a list of converters available for a given context.

2 calls to _ctools_context_get_converters()
ctools_context_get_all_converters in includes/context.inc
Get a list of all contexts + converters available.
ctools_context_get_converters in includes/context.inc
Get a list of converters available for a given context.

File

includes/context.inc, line 444
Contains code related to the ctools system of 'context'.

Code

function _ctools_context_get_converters($id, $plugin_name) {
  $plugin = ctools_get_context($plugin_name);
  if (empty($plugin['convert list'])) {
    return array();
  }
  $converters = array();
  if (is_array($plugin['convert list'])) {
    $converters = $plugin['convert list'];
  }
  else {
    if ($function = ctools_plugin_get_function($plugin, 'convert list')) {
      $converters = (array) $function();
    }
  }

  // DEPRECATED, but left in: This alter was misnamed.
  foreach (module_implements('ctools_context_convert_list') as $module) {
    $function = $module . '_ctools_context_convert_list';
    $function($plugin, $converters);
  }
  foreach (module_implements('ctools_context_convert_list_alter') as $module) {
    $function = $module . '_ctools_context_convert_list_alter';
    $function($plugin, $converters);
  }

  // Now, change them all to include the plugin:
  $return = array();
  foreach ($converters as $key => $title) {
    $return[$id . $key] = $title;
  }
  natcasesort($return);
  return $return;
}