function js_update_path in JS Callback Handler 7.2
Updates the request path after that the JS prefixes has been stripped.
1 call to js_update_path()
- js_bootstrap in ./
js.module - Ensures Drupal is bootstrapped to the specified phase.
File
- ./
js.module, line 837 - JavaScript callback handler module.
Code
function js_update_path() {
global $_js;
static $processed;
if (!$processed) {
$processed = TRUE;
$path = implode('/', $_js['args']);
// Add language path prefix if there's one. If not added the language
// detection based on path prefix wont work.
if (!empty($_js['lang'])) {
$path = $_js['lang'] . '/' . $path;
}
// Rebuild the query string.
$query_array = array();
foreach (array_diff_key($_GET, array(
'q' => FALSE,
)) as $param => $value) {
$query_array[] = $param . '=' . urlencode($value);
}
$query_params = implode('&', $query_array);
// Update global state.
$_GET['q'] = $path;
if (isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = '/' . $path . ($query_params ? '?' . $query_params : '');
}
else {
if (isset($_SERVER['argv'])) {
$_SERVER['argv'][0] = $path . ($query_params ? '?' . $query_params : '');
}
elseif (isset($_SERVER['QUERY_STRING'])) {
$_SERVER['QUERY_STRING'] = 'q=' . $path . ($query_params ? '&' . $query_params : '');
}
}
}
}