You are here

function ctools_export_ui_switcher_page in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/export-ui.inc \ctools_export_ui_switcher_page()

Main page callback to manipulate exportables.

This simply loads the object defined in the plugin and hands it off to a method based upon the name of the operation in use. This can easily be used to add more ops.

1 string reference to 'ctools_export_ui_switcher_page'
ctools_export_ui_process in includes/export-ui.inc
Process an export-ui plugin to provide it with defaults.

File

includes/export-ui.inc, line 453
Provide a tool for creating UIs for exportable objects.

Code

function ctools_export_ui_switcher_page($plugin_name, $op) {
  $args = func_get_args();
  $js = !empty($_REQUEST['js']);

  // Load the $plugin information.
  $plugin = ctools_get_export_ui($plugin_name);
  if (!$plugin) {
    return t('Configuration error. No plugin found: %plugin_name.', array(
      '%plugin_name' => $plugin_name,
    ));
  }
  $handler = ctools_export_ui_get_handler($plugin);
  if (!$handler) {
    return t('Configuration error. No handler found.');
  }
  $method = $op . '_page';
  if (method_exists($handler, $method)) {

    // Replace the first two arguments:
    $args[0] = $js;
    $args[1] = $_POST;
    return call_user_func_array(array(
      $handler,
      $method,
    ), $args);
  }
}