function _webform_filtervalues in Webform 5
Filters all special tokens provided by webform, such as %post and %profile.
21 calls to _webform_filtervalues()
- theme_webform_mail_grid in components/
grid.inc - Format the output of emailed data for this component.
- theme_webform_mail_select in components/
select.inc - Format the output of emailed data for this component.
- _webform_analysis_rows_grid in components/
grid.inc - Calculate and returns statistics about results for this component from all submission to this webform. The output of this function will be displayed under the "results" tab then "analysis".
- _webform_analysis_rows_select in components/
select.inc - Calculate and returns statistics about results for this component from all submission to this webform. The output of this function will be displayed under the "results" tab then "analysis".
- _webform_csv_data_grid in components/
grid.inc - Return the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".
File
- ./
webform.module, line 1711
Code
function _webform_filtervalues($string, $strict = TRUE) {
global $user;
// Setup default token replacements.
$find = array(
'%username',
'%useremail',
'%site',
'%date',
);
$replace = array(
$user->name,
$user->mail,
variable_get('site_name', 'drupal'),
format_date(time(), 'large'),
);
// Provide a list of candidates for token replacement.
$tokens = array(
'%server' => $_SERVER,
'%session' => $_SESSION,
'%cookie' => $_COOKIE,
'%get' => $_GET,
'%post' => $_POST,
'%request' => $_REQUEST,
'%profile' => $user,
);
foreach ($tokens as $token => $variable) {
if (strpos($string, $token) !== FALSE) {
foreach ($variable as $key => $value) {
$find[] = $token . '[' . $key . ']';
// This special case for profile module dates.
if ($token == '%profile' && is_array($value) && $value['year']) {
$replace[] = format_date(strtotime($value['month'] . '/' . $value['day'] . '/' . $value['year']), 'custom', 'F j, Y', '0');
}
else {
$replace[] = $value;
}
}
}
}
$string = str_replace($find, $replace, $string);
// Clean up any unused tokens.
foreach (array_keys($tokens) as $token) {
$string = preg_replace('/\\' . $token . '\\[\\w+\\]/', '', $string);
}
if ($strict) {
return filter_xss($string);
}
else {
return $string;
}
}