You are here

function jquery_ajax_load_callback in jQuery AJAX Load 7

Callback function for AJAX request.

Rebuilds URL for page callback Uses menu_execute_active_handler to build page

1 string reference to 'jquery_ajax_load_callback'
jquery_ajax_load_menu in ./jquery_ajax_load.module
Implementation of hook_menu().

File

./jquery_ajax_load.module, line 170
Basic Module file.

Code

function jquery_ajax_load_callback() {

  // Get the arguments from this fuction
  $args = func_get_args();

  // In case the installation is on subdirectory
  $base_path = base_path();
  if (strlen($base_path) > 1) {
    $sub_paths = explode('/', $base_path);

    // Takes out blank items generated by initial slash
    array_shift($sub_paths[0]);
    foreach ($sub_paths as $sub_path) {
      array_shift($args[0]);
    }
  }

  // Verify is language prefix present and take out of URL
  if (module_exists('i18n')) {
    $languages = language_list('enabled');

    // Take only enabled
    $languages = $languages[1];
    if (array_key_exists($args[0], $languages)) {
      $language = $args[0];
      array_shift($args[0]);
    }
    else {
      $language = NULL;
    }
  }
  else {
    $language = NULL;
  }
  $path = implode('/', $args);
  $normal_path = drupal_get_normal_path($path, $language);
  $args = explode('/', $normal_path);

  // Evaluates if entity type have a special view mode
  // If function does not exists returns default view mode or rendered node
  $function = 'jquery_ajax_load_view_' . $args[0];
  if (function_exists($function)) {
    $render_string = $function($args[1]);
  }
  else {
    $render_string = menu_execute_active_handler($normal_path, FALSE);
  }
  return $render_string;
}