dolibarr  x.y.z
modules_import.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  * or see https://www.gnu.org/
18  */
19 
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
26 
27 
32 {
36  public $db;
37 
38  public $datatoimport;
39 
43  public $error = '';
44 
48  public $id;
49 
53  public $label;
54 
55  public $extension; // Extension of files imported by driver
56 
61  public $version = 'dolibarr';
62 
63  public $label_lib; // Label of external lib used by driver
64 
65  public $version_lib; // Version of external lib used by driver
66 
67  // Array of all drivers
68  public $driverlabel = array();
69 
70  public $driverdesc = array();
71 
72  public $driverversion = array();
73 
74  public $liblabel = array();
75 
76  public $libversion = array();
77 
78 
82  public function __construct()
83  {
84  }
85 
86 
92  public function getDriverId()
93  {
94  return $this->id;
95  }
96 
102  public function getDriverLabel()
103  {
104  return $this->label;
105  }
106 
112  public function getDriverDesc()
113  {
114  return $this->desc;
115  }
116 
122  public function getDriverExtension()
123  {
124  return $this->extension;
125  }
126 
132  public function getDriverVersion()
133  {
134  return $this->version;
135  }
136 
142  public function getLibLabel()
143  {
144  return $this->label_lib;
145  }
146 
152  public function getLibVersion()
153  {
154  return $this->version_lib;
155  }
156 
157 
165  public function listOfAvailableImportFormat($db, $maxfilenamelength = 0)
166  {
167  dol_syslog(get_class($this)."::listOfAvailableImportFormat");
168 
169  $dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
170  $handle = opendir($dir);
171 
172  // Recherche des fichiers drivers imports disponibles
173  $i = 0;
174  if (is_resource($handle)) {
175  while (($file = readdir($handle)) !== false) {
176  if (preg_match("/^import_(.*)\.modules\.php/i", $file, $reg)) {
177  $moduleid = $reg[1];
178 
179  // Loading Class
180  $file = $dir."/import_".$moduleid.".modules.php";
181  $classname = "Import".ucfirst($moduleid);
182 
183  require_once $file;
184  $module = new $classname($db, '');
185 
186  // Picto
187  $this->picto[$module->id] = $module->picto;
188  // Driver properties
189  $this->driverlabel[$module->id] = $module->getDriverLabel('');
190  $this->driverdesc[$module->id] = $module->getDriverDesc('');
191  $this->driverversion[$module->id] = $module->getDriverVersion('');
192  // If use an external lib
193  $this->liblabel[$module->id] = $module->getLibLabel('');
194  $this->libversion[$module->id] = $module->getLibVersion('');
195 
196  $i++;
197  }
198  }
199  }
200 
201  return array_keys($this->driverlabel);
202  }
203 
204 
211  public function getPictoForKey($key)
212  {
213  return $this->picto[$key];
214  }
215 
222  public function getDriverLabelForKey($key)
223  {
224  return $this->driverlabel[$key];
225  }
226 
233  public function getDriverDescForKey($key)
234  {
235  return $this->driverdesc[$key];
236  }
237 
244  public function getDriverVersionForKey($key)
245  {
246  return $this->driverversion[$key];
247  }
248 
255  public function getLibLabelForKey($key)
256  {
257  return $this->liblabel[$key];
258  }
259 
266  public function getLibVersionForKey($key)
267  {
268  return $this->libversion[$key];
269  }
270 }
Parent class for import file readers.
getLibVersionForKey($key)
Renvoi version de librairie externe du driver.
getDriverDescForKey($key)
Renvoi la description d'un driver import.
getDriverLabelForKey($key)
Renvoi libelle d'un driver import.
getLibLabel()
getDriverLabel
getDriverVersionForKey($key)
Renvoi version d'un driver import.
getDriverLabel()
getDriverLabel
getPictoForKey($key)
Return picto of import driver.
getDriverId()
getDriverId
getLibLabelForKey($key)
Renvoi libelle de librairie externe du driver.
getDriverVersion()
getDriverVersion
listOfAvailableImportFormat($db, $maxfilenamelength=0)
Load into memory list of available import format.
getDriverExtension()
getDriverExtension
getLibVersion()
getLibVersion
__construct()
Constructor.
getDriverDesc()
getDriverDesc
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.