diff --git a/importexport/inc/class.importexport_basic_import_csv.inc.php b/importexport/inc/class.importexport_basic_import_csv.inc.php
index 7fc0c9ceff..37d15fd83e 100644
--- a/importexport/inc/class.importexport_basic_import_csv.inc.php
+++ b/importexport/inc/class.importexport_basic_import_csv.inc.php
@@ -450,14 +450,20 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
* @param stream $stream
* @param importexport_definition $definition
* @return String HTML for preview
- */
+ */
public function preview( $stream, importexport_definition $definition )
{
$this->import($stream, $definition);
rewind($stream);
// Set up result
- $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
+ $rows = array('h1' => array(), 'f1' => array(), '.h1' => 'class=th');
+
+ // Check for no results
+ if(!count($this->preview_records) || !is_object($this->preview_records[0]))
+ {
+ return Api\Html::table($rows);
+ }
// Load labels for app
$record_class = get_class($this->preview_records[0]);
@@ -467,16 +473,23 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
$plugin = get_called_class();
$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
- try {
+ try
+ {
$wizard = new $wizard_name;
$fields = $wizard->get_import_fields();
foreach($labels as $field => &$label)
{
- if($fields[$field]) $label = $fields[$field];
+ if($fields[$field])
+ {
+ $label = $fields[$field];
+ }
}
- } catch (Exception $e) {
+ }
+ catch (Exception $e)
+ {
Api\Translation::add_app($definition->application);
- foreach($labels as $field => &$label) {
+ foreach($labels as $field => &$label)
+ {
$label = lang($label);
}
}
diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php
index f34f73a59e..412b5a1a57 100644
--- a/importexport/inc/class.importexport_import_ui.inc.php
+++ b/importexport/inc/class.importexport_import_ui.inc.php
@@ -132,7 +132,7 @@ use EGroupware\Api\Etemplate;
}
if(count($check_message))
{
- $this->message .= implode($check_message, "
\n") . "
\n";
+ $this->message .= implode("
\n", $check_message) . "
\n";
}
if($content['dry-run'])
{
@@ -489,17 +489,18 @@ use EGroupware\Api\Etemplate;
if($dst_file)
{
// Still have uploaded file, jump there
- Api\Cache::setSession($definition->application,'csvfile',$dst_file);
+ Api\Cache::setSession($definition->application, 'csvfile', $dst_file);
$edit_link['step'] = 'wizard_step30';
}
- $edit_link = Egw::link('/index.php',$edit_link);
+ $edit_link = Egw::link('/index.php', $edit_link);
$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
$actions[] = lang('Edit definition %2 to match your file',
- $edit_link, $definition->name );
+ $edit_link, $definition->name
+ );
}
$actions[] = lang('Edit your file to match the definition:') . ' '
- . implode(', ', array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])));
- $message[] = "\n