From 3678e052709c5f565c6227f876c577a8a1b965b6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 11 Apr 2016 16:36:00 +0200
Subject: [PATCH] Mutualize code by moving getter into parent class.

---
 .../modules/import/import_csv.modules.php     | 70 ---------------
 .../modules/import/import_xlsx.modules.php    | 89 ++-----------------
 htdocs/core/modules/import/modules_import.php | 72 +++++++++++++++
 3 files changed, 81 insertions(+), 150 deletions(-)

diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 85689edcf7c..245f1a15794 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -86,76 +86,6 @@ class ImportCsv extends ModeleImports
 		if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db);
 	}
 
-	/**
-	 * getDriverId
-	 *
-	 * @return string		Id
-	 */
-	function getDriverId()
-	{
-		return $this->id;
-	}
-
-	/**
-	 *	getDriverLabel
-	 *
-	 *	@return string	Label
-	 */
-	function getDriverLabel()
-	{
-		return $this->label;
-	}
-
-	/**
-	 *	getDriverDesc
-	 *
-	 *	@return string	Description
-	 */
-	function getDriverDesc()
-	{
-		return $this->desc;
-	}
-
-	/**
-	 * getDriverExtension
-	 *
-	 * @return string	Driver suffix
-	 */
-	function getDriverExtension()
-	{
-		return $this->extension;
-	}
-
-	/**
-	 *	getDriverVersion
-	 *
-	 *	@return string	Driver version
-	 */
-	function getDriverVersion()
-	{
-		return $this->version;
-	}
-
-	/**
-	 *	getDriverLabel
-	 *
-	 *	@return string	Label of external lib
-	 */
-	function getLibLabel()
-	{
-		return $this->label_lib;
-	}
-
-	/**
-	 * getLibVersion
-	 *
-	 *	@return string	Version of external lib
-	 */
-	function getLibVersion()
-	{
-		return $this->version_lib;
-	}
-
 
 	/**
 	 * 	Output header of an example file for this format
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index a821540f29b..309e3dd7085 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -73,100 +73,29 @@ class Importxlsx extends ModeleImports
 
 		// this is used as an extension from the example file code, so we have to put xlsx here !!!
 		$this->id='xlsx';                // Same value as xxx in file name export_xxx.modules.php
-		$this->label='Excel';             // Label of driver
-		$this->desc=$langs->trans("ExcelFormatDesc",$this->separator,$this->enclosure,$this->escape);
+		$this->label='Excel 2007';             // Label of driver
+		$this->desc=$langs->trans("Excel2007FormatDesc");
 		$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
 
 		// If driver use an external library, put its name here
-    require_once PHPEXCEL_PATH.'PHPExcel.php';
+        require_once PHPEXCEL_PATH.'PHPExcel.php';
 		require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
-              if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
-              {
+        if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
+        {
                 $langs->load("errors");
                 $this->error=$langs->trans('ErrorPHPNeedModule','zip');
                 return -1;
-              }
-    $this->label_lib='PhpExcel';
-    $this->version_lib='1.8.0';
+        }
+        $this->label_lib='PhpExcel';
+        $this->version_lib='1.8.0';
 
 		$this->datatoimport=$datatoimport;
 		if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db);
 	}
 
-// Those Get methods should all be in the parent class !!! 
-	/**
-	 * getDriverId
-	 *
-	 * @return string		Id
-	 */
-	function getDriverId()
-	{
-		return $this->id;
-	}
-
-	/**
-	 *	getDriverLabel
-	 *
-	 *	@return string	Label
-	 */
-	function getDriverLabel()
-	{
-		return $this->label;
-	}
-
-	/**
-	 *	getDriverDesc
-	 *
-	 *	@return string	Description
-	 */
-	function getDriverDesc()
-	{
-		return $this->desc;
-	}
-
-	/**
-	 * getDriverExtension
-	 *
-	 * @return string	Driver suffix
-	 */
-	function getDriverExtension()
-	{
-		return $this->extension;
-	}
-
-	/**
-	 *	getDriverVersion
-	 *
-	 *	@return string	Driver version
-	 */
-	function getDriverVersion()
-	{
-		return $this->version;
-	}
-
-	/**
-	 *	getDriverLabel
-	 *
-	 *	@return string	Label of external lib
-	 */
-	function getLibLabel()
-	{
-		return $this->label_lib;
-	}
-
-	/**
-	 * getLibVersion
-	 *
-	 *	@return string	Version of external lib
-	 */
-	function getLibVersion()
-	{
-		return $this->version_lib;
-	}
-
-
+	
 	/**
 	 * 	Output header of an example file for this format
 	 *
diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php
index a27b0fd9426..11b81ecb820 100644
--- a/htdocs/core/modules/import/modules_import.php
+++ b/htdocs/core/modules/import/modules_import.php
@@ -59,6 +59,78 @@ class ModeleImports
 	{
 	}
 
+	
+	/**
+	 * getDriverId
+	 *
+	 * @return string		Id
+	 */
+	function getDriverId()
+	{
+	    return $this->id;
+	}
+	
+	/**
+	 *	getDriverLabel
+	 *
+	 *	@return string	Label
+	 */
+	function getDriverLabel()
+	{
+	    return $this->label;
+	}
+	
+	/**
+	 *	getDriverDesc
+	 *
+	 *	@return string	Description
+	 */
+	function getDriverDesc()
+	{
+	    return $this->desc;
+	}
+	
+	/**
+	 * getDriverExtension
+	 *
+	 * @return string	Driver suffix
+	 */
+	function getDriverExtension()
+	{
+	    return $this->extension;
+	}
+	
+	/**
+	 *	getDriverVersion
+	 *
+	 *	@return string	Driver version
+	 */
+	function getDriverVersion()
+	{
+	    return $this->version;
+	}
+	
+	/**
+	 *	getDriverLabel
+	 *
+	 *	@return string	Label of external lib
+	 */
+	function getLibLabel()
+	{
+	    return $this->label_lib;
+	}
+	
+	/**
+	 * getLibVersion
+	 *
+	 *	@return string	Version of external lib
+	 */
+	function getLibVersion()
+	{
+	    return $this->version_lib;
+	}
+	
+	
 	/**
 	 *  Charge en memoire et renvoie la liste des modeles actifs
 	 *
-- 
GitLab