function date_node_import_values_alter_date_text in Node import 6
1 call to date_node_import_values_alter_date_text()
- date_node_import_values_alter in supported/
date/ date.inc - Implementation of hook_node_import_values_alter().
File
- supported/
date/ date.inc, line 72 - Support file for the CCK Date module.
Code
function date_node_import_values_alter_date_text(&$values, $fields, $fieldname, $fieldinfo) {
foreach ($fieldinfo['columns'] as $colname => $colinfo) {
// Provide default value if the field has no values.
if (count($values[$fieldname]) == 0) {
$values[$fieldname] = array();
$values[$fieldname][0] = array();
$values[$fieldname][0][$colname] = array(
'date' => null,
);
}
else {
foreach ($values[$fieldname] as $i => $value) {
// Get the format that is expected from the pop-up calendar.
// If a custom format was entered, use it instead.
if ($fieldinfo['widget']['input_format_custom']) {
$widgetFormat = $fieldinfo['widget']['input_format_custom'];
}
else {
$widgetFormat = $fieldinfo['widget']['input_format'];
}
// Remove parts that are not valid for the selected granularity
$widgetFormat = date_limit_format($widgetFormat, $fieldinfo['granularity']);
// Get the original value format we need to convert
$time = strtotime($value[$colname]);
/* $colname is 'value' in most cases.
* We trash the original 'value' field and replace it with an array containing the various pieces entered
* from the 'pop-up calendar'.
*/
$values[$fieldname][$i][$colname] = array();
if ($time == FALSE) {
$values[$fieldname][$i][$colname]['date'] = $value[$colname];
}
else {
$values[$fieldname][$i][$colname]['date'] = date($widgetFormat, $time);
}
}
}
}
}