mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix error when import module not compatible with PHP
This commit is contained in:
parent
d376a2a406
commit
89b56120eb
|
|
@ -87,12 +87,12 @@ class ImportCsv extends ModeleImports
|
|||
*/
|
||||
public function __construct($db, $datatoimport)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
parent::__construct();
|
||||
$this->db = $db;
|
||||
|
||||
$this->separator = (GETPOST('separator') ? GETPOST('separator') : (!getDolGlobalString('IMPORT_CSV_SEPARATOR_TO_USE') ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE));
|
||||
$this->separator = (GETPOST('separator') ? GETPOST('separator') : getDolGlobalString('IMPORT_CSV_SEPARATOR_TO_USE', ','));
|
||||
$this->enclosure = '"';
|
||||
$this->escape = '"';
|
||||
|
||||
|
|
@ -102,6 +102,14 @@ class ImportCsv extends ModeleImports
|
|||
$this->extension = 'csv'; // Extension for generated file by this driver
|
||||
$this->picto = 'mime/other'; // Picto
|
||||
$this->version = '1.34'; // Driver version
|
||||
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
if (versioncompare($this->phpmin, versionphparray()) > 0) {
|
||||
dol_syslog("Module need a higher PHP version");
|
||||
$this->error = "Module need a higher PHP version";
|
||||
return;
|
||||
}
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib = 'Dolibarr';
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class ImportXlsx extends ModeleImports
|
|||
*/
|
||||
public function __construct($db, $datatoimport)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
parent::__construct();
|
||||
$this->db = $db;
|
||||
|
|
@ -106,6 +106,14 @@ class ImportXlsx extends ModeleImports
|
|||
$this->extension = 'xlsx'; // Extension for generated file by this driver
|
||||
$this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...)
|
||||
$this->version = '1.0'; // Driver version
|
||||
$this->phpmin = array(7, 1); // Minimum version of PHP required by module
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
if (versioncompare($this->phpmin, versionphparray()) > 0) {
|
||||
dol_syslog("Module need a higher PHP version");
|
||||
$this->error = "Module need a higher PHP version";
|
||||
return;
|
||||
}
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php';
|
||||
|
|
|
|||
|
|
@ -71,9 +71,23 @@ class ModeleImports
|
|||
*/
|
||||
public $version = 'dolibarr';
|
||||
|
||||
public $label_lib; // Label of external lib used by driver
|
||||
/**
|
||||
* PHP minimal version required by driver
|
||||
* @var string
|
||||
*/
|
||||
public $phpmin = array();
|
||||
|
||||
public $version_lib; // Version of external lib used by driver
|
||||
/**
|
||||
* Label of external lib used by driver
|
||||
* @var string
|
||||
*/
|
||||
public $label_lib;
|
||||
|
||||
/**
|
||||
* Version of external lib used by driver
|
||||
* @var string
|
||||
*/
|
||||
public $version_lib;
|
||||
|
||||
// Array of all drivers
|
||||
public $driverlabel = array();
|
||||
|
|
@ -82,6 +96,8 @@ class ModeleImports
|
|||
|
||||
public $driverversion = array();
|
||||
|
||||
public $drivererror = array();
|
||||
|
||||
public $liblabel = array();
|
||||
|
||||
public $libversion = array();
|
||||
|
|
@ -225,10 +241,10 @@ class ModeleImports
|
|||
$dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
|
||||
$handle = opendir($dir);
|
||||
|
||||
// Recherche des fichiers drivers imports disponibles
|
||||
$i = 0;
|
||||
// Search list ov drivers available and qualified
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$reg = array();
|
||||
if (preg_match("/^import_(.*)\.modules\.php/i", $file, $reg)) {
|
||||
$moduleid = $reg[1];
|
||||
|
||||
|
|
@ -245,11 +261,10 @@ class ModeleImports
|
|||
$this->driverlabel[$module->id] = $module->getDriverLabel('');
|
||||
$this->driverdesc[$module->id] = $module->getDriverDesc('');
|
||||
$this->driverversion[$module->id] = $module->getDriverVersion('');
|
||||
$this->drivererror[$module->id] = $module->error ? $module->error : '';
|
||||
// If use an external lib
|
||||
$this->liblabel[$module->id] = $module->getLibLabel('');
|
||||
$this->liblabel[$module->id] = ($module->error ? '<span class="error">'.$module->error.'</span>' : $module->getLibLabel(''));
|
||||
$this->libversion[$module->id] = $module->getLibVersion('');
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,20 +465,25 @@ if ($step == 2 && $datatoimport) {
|
|||
foreach ($list as $key) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).'</td>';
|
||||
$text = $objmodelimport->getDriverDescForKey($key);
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
print '<td>'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).'</td>';
|
||||
$htmltext = $objmodelimport->getDriverDescForKey($key);
|
||||
print '<td>'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $htmltext).'</td>';
|
||||
print '<td style="text-align:center">';
|
||||
$filename = $langs->transnoentitiesnoconv("ExampleOfImportFile").'_'.$datatoimport.'.'.$key;
|
||||
print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'&output=file&file='.urlencode($filename).'" target="_blank" rel="noopener noreferrer">';
|
||||
print img_picto('', 'download', 'class="paddingright opacitymedium"');
|
||||
print $langs->trans("DownloadEmptyExampleShort");
|
||||
print '</a>';
|
||||
print $form->textwithpicto('', $langs->trans("DownloadEmptyExample").'.<br>'.$langs->trans("StarAreMandatory"));
|
||||
if (empty($objmodelimport->drivererror[$key])) {
|
||||
$filename = $langs->transnoentitiesnoconv("ExampleOfImportFile").'_'.$datatoimport.'.'.$key;
|
||||
print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'&output=file&file='.urlencode($filename).'" target="_blank" rel="noopener noreferrer">';
|
||||
print img_picto('', 'download', 'class="paddingright opacitymedium"');
|
||||
print $langs->trans("DownloadEmptyExampleShort");
|
||||
print '</a>';
|
||||
print $form->textwithpicto('', $langs->trans("DownloadEmptyExample").'.<br>'.$langs->trans("StarAreMandatory"));
|
||||
} else {
|
||||
print dolPrintHtml($objmodelimport->drivererror[$key]);
|
||||
}
|
||||
print '</td>';
|
||||
// Action button
|
||||
print '<td style="text-align:right">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=3&format='.$key.$param.'">'.img_picto($langs->trans("SelectFormat"), 'next', 'class="fa-15"').'</a>';
|
||||
if (empty($objmodelimport->drivererror[$key])) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=3&format='.$key.$param.'">'.img_picto($langs->trans("SelectFormat"), 'next', 'class="fa-15"').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user