You are here

function sweaver_menu_callback in Sweaver 7

Same name and namespace in other branches
  1. 6 sweaver.module \sweaver_menu_callback()

Sweaver menu callback.

Parameters

$settings: A collection of page arguments from the menu callback.

Return value

The rendered page - can be form or anything else.

1 string reference to 'sweaver_menu_callback'
_sweaver_menu in ./sweaver.registry.inc
Menu items.

File

./sweaver.module, line 722
Sweaver functions.

Code

function sweaver_menu_callback($settings) {
  $plugin_name = $settings['plugin'];
  $callback_method = isset($settings['callback_method']) ? $settings['callback_method'] : 'sweaver_menu_callback';
  $return_method = isset($settings['return_method']) ? $settings['return_method'] : 'drupal_get_form';
  $js = isset($settings['js']) ? TRUE : FALSE;
  if ($sweaver_plugin = Sweaver::get_instance()
    ->get_plugin($plugin_name, TRUE)) {
    $output = $sweaver_plugin
      ->{$callback_method}();
    if (!empty($output)) {
      if ($return_method == 'drupal_get_form') {
        return drupal_get_form('sweaver_menu_callback_form', $output, $plugin_name, $callback_method);
      }
      elseif (isset($js)) {
        exit(drupal_to_js($output));
      }
      elseif (!empty($return_method) && function_exists($return_method)) {
        return $return_method($output);
      }
      else {
        return $output;
      }
    }
  }
  return t('No page found or you do not have sufficient permissions to access the page.');
}