Try translation of lookup values if straight lookup fails

This commit is contained in:
Nathan Gray 2012-10-10 15:58:58 +00:00
parent 7d568d90c7
commit 4f76748536

View File

@ -266,6 +266,10 @@ class importexport_import_csv implements importexport_iface_import_record { //,
// Automatic conversions // Automatic conversions
if($appname) { if($appname) {
// Load translations
translation::add_app($appname);
if(!self::$cf_parse_cache[$appname]) { if(!self::$cf_parse_cache[$appname]) {
$c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods);
self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
@ -285,9 +289,17 @@ class importexport_import_csv implements importexport_iface_import_record { //,
foreach((array)$fields['select'] as $name) { foreach((array)$fields['select'] as $name) {
if($record[$name] != null && is_array($selects) && $selects[$name]) { if($record[$name] != null && is_array($selects) && $selects[$name]) {
$key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name])); $key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name]));
if($key !== false)
{
$record[$name] = $key;
}
else
{
$key = array_search(strtolower($record[$name]), array_map('strtolower',array_map('lang',$selects[$name])));
if($key !== false) $record[$name] = $key; if($key !== false) $record[$name] = $key;
} }
} }
}
foreach((array)$fields['links'] as $name) { foreach((array)$fields['links'] as $name) {
if($record[$name]) { if($record[$name]) {
// TODO // TODO