From ffcfe30529ae9598ce9544fe7d9aa212b4a07f74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 16:51:54 +0200 Subject: [PATCH] FIX Avoid errors on debian --- .../modules/export/export_excel.modules.php | 37 ++++++++++--------- .../export/export_excel2007.modules.php | 35 ++++++++++-------- htdocs/core/modules/export/modules_export.php | 28 +++++++------- 3 files changed, 54 insertions(+), 46 deletions(-) diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 91f78522973..00d06e8511a 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -64,24 +64,27 @@ class ExportExcel extends ModeleExports $this->picto='mime/xls'; // Picto $this->version='1.30'; // Driver version - // If driver use an external library, put its name here - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; - $this->label_lib='PhpWriteExcel'; - $this->version_lib='unknown'; - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; // No way to get info from library - } - $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) + + if (empty($this->disabled)) + { + // If driver use an external library, put its name here + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) + { + require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; + require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; + require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; + $this->label_lib='PhpWriteExcel'; + $this->version_lib='unknown'; + } + else + { + require_once PHPEXCEL_PATH.'PHPExcel.php'; + require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; + $this->label_lib='PhpExcel'; + $this->version_lib='1.8.0'; // No way to get info from library + } + } $this->row=0; } diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index dcb649e780d..df9fd9d5705 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -64,25 +64,28 @@ class ExportExcel2007 extends ExportExcel $this->picto='mime/xls'; // Picto $this->version='1.30'; // Driver version - // If driver use an external library, put its name here - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) + $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) + + if (empty($this->disabled)) { - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; - $this->label_lib='PhpWriteExcel'; - $this->version_lib='unknown'; - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; // No way to get info from library + // If driver use an external library, put its name here + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) + { + require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; + require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; + require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; + $this->label_lib='PhpWriteExcel'; + $this->version_lib='unknown'; + } + else + { + require_once PHPEXCEL_PATH.'PHPExcel.php'; + require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; + $this->label_lib='PhpExcel'; + $this->version_lib='1.8.0'; // No way to get info from library + } } - $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) - $this->row=0; } diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index ee1c3b8e96c..8cbb3850c2b 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -65,22 +65,24 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac $moduleid=$reg[1]; // Loading Class - $file = $dir."/export_".$moduleid.".modules.php"; + $file = $dir."export_".$moduleid.".modules.php"; $classname = "Export".ucfirst($moduleid); require_once $file; - $module = new $classname($db); - - // Picto - $this->picto[$module->id]=$module->picto; - // Driver properties - $this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__'); // '__(Disabled)__' is a key - $this->driverdesc[$module->id]=$module->getDriverDesc(); - $this->driverversion[$module->id]=$module->getDriverVersion(); - // If use an external lib - $this->liblabel[$module->id]=$module->getLibLabel(); - $this->libversion[$module->id]=$module->getLibVersion(); - + if (class_exists($classname)) + { + $module = new $classname($db); + + // Picto + $this->picto[$module->id]=$module->picto; + // Driver properties + $this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__'); // '__(Disabled)__' is a key + $this->driverdesc[$module->id]=$module->getDriverDesc(); + $this->driverversion[$module->id]=$module->getDriverVersion(); + // If use an external lib + $this->liblabel[$module->id]=$module->getLibLabel(); + $this->libversion[$module->id]=$module->getLibVersion(); + } $i++; } }