mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
Fix PHP 8.0 TypeError: get_class(): Argument #1 ($object) must be of type object, null given
Also fix some deprecated implode() calls
This commit is contained in:
parent
1ccbc60587
commit
bcb2c6fd91
@ -450,14 +450,20 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
|
|||||||
* @param stream $stream
|
* @param stream $stream
|
||||||
* @param importexport_definition $definition
|
* @param importexport_definition $definition
|
||||||
* @return String HTML for preview
|
* @return String HTML for preview
|
||||||
*/
|
*/
|
||||||
public function preview( $stream, importexport_definition $definition )
|
public function preview( $stream, importexport_definition $definition )
|
||||||
{
|
{
|
||||||
$this->import($stream, $definition);
|
$this->import($stream, $definition);
|
||||||
rewind($stream);
|
rewind($stream);
|
||||||
|
|
||||||
// Set up result
|
// 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
|
// Load labels for app
|
||||||
$record_class = get_class($this->preview_records[0]);
|
$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();
|
$plugin = get_called_class();
|
||||||
$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
|
$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
$wizard = new $wizard_name;
|
$wizard = new $wizard_name;
|
||||||
$fields = $wizard->get_import_fields();
|
$fields = $wizard->get_import_fields();
|
||||||
foreach($labels as $field => &$label)
|
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);
|
Api\Translation::add_app($definition->application);
|
||||||
foreach($labels as $field => &$label) {
|
foreach($labels as $field => &$label)
|
||||||
|
{
|
||||||
$label = lang($label);
|
$label = lang($label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ use EGroupware\Api\Etemplate;
|
|||||||
}
|
}
|
||||||
if(count($check_message))
|
if(count($check_message))
|
||||||
{
|
{
|
||||||
$this->message .= implode($check_message, "<br />\n") . "<br />\n";
|
$this->message .= implode("<br />\n", $check_message) . "<br />\n";
|
||||||
}
|
}
|
||||||
if($content['dry-run'])
|
if($content['dry-run'])
|
||||||
{
|
{
|
||||||
@ -489,17 +489,18 @@ use EGroupware\Api\Etemplate;
|
|||||||
if($dst_file)
|
if($dst_file)
|
||||||
{
|
{
|
||||||
// Still have uploaded file, jump there
|
// 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['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')";
|
$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
|
||||||
$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
|
$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
|
||||||
$edit_link, $definition->name );
|
$edit_link, $definition->name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$actions[] = lang('Edit your file to match the definition:') . ' '
|
$actions[] = lang('Edit your file to match the definition:') . ' '
|
||||||
. implode(', ', array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])));
|
. implode(', ', array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])));
|
||||||
$message[] = "\n<li>".implode($actions,"\n<li>");
|
$message[] = "\n<li>" . implode("\n<li>", $actions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ok;
|
return $ok;
|
||||||
|
Loading…
Reference in New Issue
Block a user