dolibarr  17.0.3
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 
158  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
166  public 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  while (($file = readdir($handle)) !== false) {
178  if (preg_match("/^import_(.*)\.modules\.php/i", $file, $reg)) {
179  $moduleid = $reg[1];
180 
181  // Loading Class
182  $file = $dir."/import_".$moduleid.".modules.php";
183  $classname = "Import".ucfirst($moduleid);
184 
185  require_once $file;
186  $module = new $classname($db, '');
187 
188  // Picto
189  $this->picto[$module->id] = $module->picto;
190  // Driver properties
191  $this->driverlabel[$module->id] = $module->getDriverLabel('');
192  $this->driverdesc[$module->id] = $module->getDriverDesc('');
193  $this->driverversion[$module->id] = $module->getDriverVersion('');
194  // If use an external lib
195  $this->liblabel[$module->id] = $module->getLibLabel('');
196  $this->libversion[$module->id] = $module->getLibVersion('');
197 
198  $i++;
199  }
200  }
201  }
202 
203  return array_keys($this->driverlabel);
204  }
205 
206 
213  public function getPictoForKey($key)
214  {
215  return $this->picto[$key];
216  }
217 
224  public function getDriverLabelForKey($key)
225  {
226  return $this->driverlabel[$key];
227  }
228 
235  public function getDriverDescForKey($key)
236  {
237  return $this->driverdesc[$key];
238  }
239 
246  public function getDriverVersionForKey($key)
247  {
248  return $this->driverversion[$key];
249  }
250 
257  public function getLibLabelForKey($key)
258  {
259  return $this->liblabel[$key];
260  }
261 
268  public function getLibVersionForKey($key)
269  {
270  return $this->libversion[$key];
271  }
272 }
ModeleImports\__construct
__construct()
Constructor.
Definition: modules_import.php:82
ModeleImports\liste_modeles
liste_modeles($db, $maxfilenamelength=0)
Charge en memoire et renvoie la liste des modeles actifs.
Definition: modules_import.php:166
ModeleImports\getDriverVersionForKey
getDriverVersionForKey($key)
Renvoi version d'un driver import.
Definition: modules_import.php:246
ModeleImports\getLibVersionForKey
getLibVersionForKey($key)
Renvoi version de librairie externe du driver.
Definition: modules_import.php:268
ModeleImports\getLibLabel
getLibLabel()
getDriverLabel
Definition: modules_import.php:142
ModeleImports\getDriverId
getDriverId()
getDriverId
Definition: modules_import.php:92
ModeleImports\getDriverLabel
getDriverLabel()
getDriverLabel
Definition: modules_import.php:102
ModeleImports\getDriverExtension
getDriverExtension()
getDriverExtension
Definition: modules_import.php:122
ModeleImports\getDriverLabelForKey
getDriverLabelForKey($key)
Renvoi libelle d'un driver import.
Definition: modules_import.php:224
ModeleImports\getLibVersion
getLibVersion()
getLibVersion
Definition: modules_import.php:152
ModeleImports\getPictoForKey
getPictoForKey($key)
Return picto of import driver.
Definition: modules_import.php:213
ModeleImports
Parent class for import file readers.
Definition: modules_import.php:31
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
ModeleImports\getDriverDescForKey
getDriverDescForKey($key)
Renvoi la description d'un driver import.
Definition: modules_import.php:235
ModeleImports\getLibLabelForKey
getLibLabelForKey($key)
Renvoi libelle de librairie externe du driver.
Definition: modules_import.php:257
ModeleImports\getDriverDesc
getDriverDesc()
getDriverDesc
Definition: modules_import.php:112
ModeleImports\getDriverVersion
getDriverVersion()
getDriverVersion
Definition: modules_import.php:132