function _googleanalytics_convert_form_value_data_types in Google Analytics 6.4
Same name and namespace in other branches
- 7.2 googleanalytics.admin.inc \_googleanalytics_convert_form_value_data_types()
Prepare form data types for Json conversion.
Parameters
array $values: Array of name/value pairs.
Return value
array Array of name/value pairs with casted data types.
1 call to _googleanalytics_convert_form_value_data_types()
- _googleanalytics_extract_create_field_values in ./
googleanalytics.admin.inc - Extracts the values array from the element.
File
- ./
googleanalytics.admin.inc, line 842 - Administrative page callbacks for the googleanalytics module.
Code
function _googleanalytics_convert_form_value_data_types($values) {
foreach ($values as $name => $value) {
// Convert data types.
// @todo: #2251377: Json utility class serializes boolean values to incorrect data type
$match = drupal_strtolower($value);
if ($match == 'true') {
$value = TRUE;
}
elseif ($match == 'false') {
$value = FALSE;
}
// Convert other known fields.
// @todo: #2251343: Json utility class serializes numeric values to incorrect data type
switch ($name) {
case 'sampleRate':
// Float
settype($value, 'float');
break;
case 'siteSpeedSampleRate':
case 'cookieExpires':
// Integer
settype($value, 'integer');
break;
}
$values[$name] = $value;
}
return $values;
}