function webform_replace_url_tokens in Webform 7.4
Replace tokens within a URL, encoding the parts within the query string.
Parameters
string $redirect_url: The redirect URL, with everything other than tokens already URL encoded.
object $node: If replacing node-level tokens, the node for which tokens will be created.
$submission: If replacing submission-level tokens, the submission for which tokens will be created.
Return value
array An array of path and url() options, suitable for a redirect or drupal_goto.
1 call to webform_replace_url_tokens()
- webform_client_form_submit in ./
webform.module - Submit handler for saving the form values and sending e-mails.
File
- ./
webform.module, line 4162 - This module provides a simple way to create forms and questionnaires.
Code
function webform_replace_url_tokens($redirect_url, $node = NULL, $submission = NULL) {
// Parse the url into its components.
$parsed_redirect_url = drupal_parse_url($redirect_url);
// Replace tokens in each component.
$parsed_redirect_url['path'] = webform_replace_tokens($parsed_redirect_url['path'], $node, $submission);
if (!empty($parsed_redirect_url['query'])) {
foreach ($parsed_redirect_url['query'] as $key => $value) {
$parsed_redirect_url['query'][$key] = trim(webform_replace_tokens($value, $node, $submission));
}
}
$parsed_redirect_url['fragment'] = webform_replace_tokens($parsed_redirect_url['fragment'], $node, $submission);
// Determine whether the path is internal or external. Paths which contain the
// site's base url are still considered internal. #webform_external is private
// to webform.
$parsed_redirect_url['#webform_external'] = url_is_external($parsed_redirect_url['path']);
foreach (array(
NULL,
TRUE,
FALSE,
) as $https) {
if (stripos($parsed_redirect_url['path'], url('', array(
'absolute' => TRUE,
'https' => $https,
))) === 0) {
$parsed_redirect_url['#webform_external'] = FALSE;
}
}
// Return an array suitable for a form redirect or drupal_goto.
return array(
$parsed_redirect_url['path'],
$parsed_redirect_url,
);
}