dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
17  * or see http://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  function __construct()
83  {
84  }
85 
86 
92  function getDriverId()
93  {
94  return $this->id;
95  }
96 
102  function getDriverLabel()
103  {
104  return $this->label;
105  }
106 
112  function getDriverDesc()
113  {
114  return $this->desc;
115  }
116 
123  {
124  return $this->extension;
125  }
126 
132  function getDriverVersion()
133  {
134  return $this->version;
135  }
136 
142  function getLibLabel()
143  {
144  return $this->label_lib;
145  }
146 
152  function getLibVersion()
153  {
154  return $this->version_lib;
155  }
156 
157 
158  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
166  function liste_modeles($db,$maxfilenamelength=0)
167  {
168  // phpcs:enable
169  dol_syslog(get_class($this)."::liste_modeles");
170 
171  $dir=DOL_DOCUMENT_ROOT."/core/modules/import/";
172  $handle=opendir($dir);
173 
174  // Recherche des fichiers drivers imports disponibles
175  $i=0;
176  if (is_resource($handle))
177  {
178  while (($file = readdir($handle))!==false)
179  {
180  if (preg_match("/^import_(.*)\.modules\.php/i",$file,$reg))
181  {
182  $moduleid=$reg[1];
183 
184  // Loading Class
185  $file = $dir."/import_".$moduleid.".modules.php";
186  $classname = "Import".ucfirst($moduleid);
187 
188  require_once $file;
189  $module = new $classname($db,'');
190 
191  // Picto
192  $this->picto[$module->id]=$module->picto;
193  // Driver properties
194  $this->driverlabel[$module->id]=$module->getDriverLabel('');
195  $this->driverdesc[$module->id]=$module->getDriverDesc('');
196  $this->driverversion[$module->id]=$module->getDriverVersion('');
197  // If use an external lib
198  $this->liblabel[$module->id]=$module->getLibLabel('');
199  $this->libversion[$module->id]=$module->getLibVersion('');
200 
201  $i++;
202  }
203  }
204  }
205 
206  return array_keys($this->driverlabel);
207  }
208 
209 
216  function getPictoForKey($key)
217  {
218  return $this->picto[$key];
219  }
220 
227  function getDriverLabelForKey($key)
228  {
229  return $this->driverlabel[$key];
230  }
231 
238  function getDriverDescForKey($key)
239  {
240  return $this->driverdesc[$key];
241  }
242 
249  function getDriverVersionForKey($key)
250  {
251  return $this->driverversion[$key];
252  }
253 
260  function getLibLabelForKey($key)
261  {
262  return $this->liblabel[$key];
263  }
264 
271  function getLibVersionForKey($key)
272  {
273  return $this->libversion[$key];
274  }
275 }
getDriverLabelForKey($key)
Renvoi libelle d&#39;un driver import.
getLibVersion()
getLibVersion
liste_modeles($db, $maxfilenamelength=0)
Charge en memoire et renvoie la liste des modeles actifs.
getDriverVersion()
getDriverVersion
getLibVersionForKey($key)
Renvoi version de librairie externe du driver.
getDriverExtension()
getDriverExtension
getPictoForKey($key)
Return picto of import driver.
getDriverId()
getDriverId
getDriverLabel()
getDriverLabel
getLibLabel()
getDriverLabel
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getDriverDescForKey($key)
Renvoi la description d&#39;un driver import.
Parent class for import file readers.
$version
Dolibarr version of driver string.
getLibLabelForKey($key)
Renvoi libelle de librairie externe du driver.
getDriverVersionForKey($key)
Renvoi version d&#39;un driver import.
__construct()
Constructor.
getDriverDesc()
getDriverDesc