You are here

function js_replace_callback_args in JS Callback Handler 7

Helper function for replacing integer based arguments with path values.

Parameters

array $args: An array of arguments to walk through and replace values.

Return value

array The arguments array replaced with correct path values.

1 call to js_replace_callback_args()
js_execute_callback in ./js.php
Loads the requested module and executes the requested callback.

File

./js.php, line 280
Callback page that serves custom JavaScript requests on a Drupal installation.

Code

function js_replace_callback_args(array $args = array()) {

  // Retrieve the original arguments again, but strip first and second
  // arguments ('js' and 'module').
  $original_args = array_slice(explode('/', $_GET['q']), 2);
  foreach ($args as $key => $value) {

    // Numeric argument exists, replace it.
    if (is_int($value) && !empty($original_args[$value])) {
      $args[$key] = $original_args[$value];
    }
    elseif (is_int($value)) {
      unset($args[$key]);
    }
  }
  return $args;
}