dolibarr  7.0.0-beta
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@capnetworks.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 {
33  public $db;
34  public $datatoimport;
35 
36  public $error='';
37 
38  public $id; // Id of driver
39  public $label; // Label of driver
40  public $extension; // Extension of files imported by driver
41  public $version; // Version of driver
42 
43  public $label_lib; // Label of external lib used by driver
44  public $version_lib; // Version of external lib used by driver
45 
46  // Array of all drivers
47  public $driverlabel=array();
48  public $driverdesc=array();
49  public $driverversion=array();
50 
51  public $liblabel=array();
52  public $libversion=array();
53 
54 
58  function __construct()
59  {
60  }
61 
62 
68  function getDriverId()
69  {
70  return $this->id;
71  }
72 
78  function getDriverLabel()
79  {
80  return $this->label;
81  }
82 
88  function getDriverDesc()
89  {
90  return $this->desc;
91  }
92 
98  function getDriverExtension()
99  {
100  return $this->extension;
101  }
102 
108  function getDriverVersion()
109  {
110  return $this->version;
111  }
112 
118  function getLibLabel()
119  {
120  return $this->label_lib;
121  }
122 
128  function getLibVersion()
129  {
130  return $this->version_lib;
131  }
132 
133 
141  function liste_modeles($db,$maxfilenamelength=0)
142  {
143  dol_syslog(get_class($this)."::liste_modeles");
144 
145  $dir=DOL_DOCUMENT_ROOT."/core/modules/import/";
146  $handle=opendir($dir);
147 
148  // Recherche des fichiers drivers imports disponibles
149  $var=True;
150  $i=0;
151  if (is_resource($handle))
152  {
153  while (($file = readdir($handle))!==false)
154  {
155  if (preg_match("/^import_(.*)\.modules\.php/i",$file,$reg))
156  {
157  $moduleid=$reg[1];
158 
159  // Loading Class
160  $file = $dir."/import_".$moduleid.".modules.php";
161  $classname = "Import".ucfirst($moduleid);
162 
163  require_once $file;
164  $module = new $classname($db,'');
165 
166  // Picto
167  $this->picto[$module->id]=$module->picto;
168  // Driver properties
169  $this->driverlabel[$module->id]=$module->getDriverLabel('');
170  $this->driverdesc[$module->id]=$module->getDriverDesc('');
171  $this->driverversion[$module->id]=$module->getDriverVersion('');
172  // If use an external lib
173  $this->liblabel[$module->id]=$module->getLibLabel('');
174  $this->libversion[$module->id]=$module->getLibVersion('');
175 
176  $i++;
177  }
178  }
179  }
180 
181  return array_keys($this->driverlabel);
182  }
183 
184 
191  function getPictoForKey($key)
192  {
193  return $this->picto[$key];
194  }
195 
202  function getDriverLabelForKey($key)
203  {
204  return $this->driverlabel[$key];
205  }
206 
213  function getDriverDescForKey($key)
214  {
215  return $this->driverdesc[$key];
216  }
217 
224  function getDriverVersionForKey($key)
225  {
226  return $this->driverversion[$key];
227  }
228 
235  function getLibLabelForKey($key)
236  {
237  return $this->liblabel[$key];
238  }
239 
246  function getLibVersionForKey($key)
247  {
248  return $this->libversion[$key];
249  }
250 
251 }
252 
getDriverLabelForKey($key)
Renvoi libelle d'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'un driver import.
Parent class for import file readers.
getLibLabelForKey($key)
Renvoi libelle de librairie externe du driver.
getDriverVersionForKey($key)
Renvoi version d'un driver import.
__construct()
Constructor.
getDriverDesc()
getDriverDesc