dolibarr 24.0.0-beta
modules_export.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
28
29
33class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance properties loaded by listOfAvailableExportFormat
34{
38 public $id = 'NOT IMPLEMENTED';
39
43 public $error = '';
44
48 public $driverlabel = array();
49
53 public $driverdesc = array();
54
58 public $driverversion = array();
59
63 public $liblabel = array();
64
68 public $libversion = array();
69
73 public $picto;
74
78 public $pictos;
79
83 public $desc;
84
88 public $escape;
89
93 public $enclosure;
94
98 public $separator;
99
103 public $col;
104
108 public $disabled;
109
117 public function listOfAvailableExportFormat($db, $maxfilenamelength = 0)
118 {
119 global $langs;
120
121 dol_syslog(get_class($this)."::listOfAvailableExportFormat");
122
123 $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
124 $handle = opendir($dir);
125
126 // Recherche des fichiers drivers exports disponibles
127 $i = 0;
128 if (is_resource($handle)) {
129 while (($file = readdir($handle)) !== false) {
130 $reg = array();
131 if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) {
132 $moduleid = $reg[1];
133 if ($moduleid == 'csv') {
134 continue; // This may happen if on old file export_csv.modules.php was not correctly deleted
135 }
136
137 // Loading Class
138 $file = $dir."export_".$moduleid.".modules.php";
139 $classname = "Export".ucfirst($moduleid);
140
141 require_once $file;
142 if (class_exists($classname)) {
143 $module = new $classname($db);
144 '@phan-var-force ModeleExports $module';
145 // var_dump($classname);
146
147 // Picto
148 $this->pictos[$module->id] = $module->picto;
149 // Driver properties
150 $this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key
151 if (method_exists($module, 'getDriverLabelBis')) {
152 // @phan-suppress-next-line PhanUndeclaredMethod
153 $labelBis = $module->getDriverLabelBis();
154 if ($labelBis) {
155 $this->driverlabel[$module->id] .= ' <span class="opacitymedium">('.$labelBis.')</span>';
156 }
157 }
158 $this->driverdesc[$module->id] = $module->getDriverDesc();
159 $this->driverversion[$module->id] = $module->getDriverVersion();
160 // If use an external lib
161 $this->liblabel[$module->id] = $module->getLibLabel();
162 $this->libversion[$module->id] = $module->getLibVersion();
163 }
164 $i++;
165 }
166 }
167 closedir($handle);
168 }
169
170 asort($this->driverlabel);
171
172 return $this->driverlabel;
173 }
174
175
182 public function getPictoForKey($key)
183 {
184 return $this->pictos[$key];
185 }
186
193 public function getDriverLabelForKey($key)
194 {
195 return $this->driverlabel[$key];
196 }
197
204 public function getDriverDescForKey($key)
205 {
206 return $this->driverdesc[$key];
207 }
208
215 public function getDriverVersionForKey($key)
216 {
217 return $this->driverversion[$key];
218 }
219
226 public function getLibLabelForKey($key)
227 {
228 return $this->liblabel[$key];
229 }
230
237 public function getLibVersionForKey($key)
238 {
239 // phpcs:enable
240 return $this->libversion[$key];
241 }
242
243 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
253 public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
254 {
255 // phpcs:enable
256 $msg = get_class($this)."::".__FUNCTION__." not implemented";
257 dol_syslog($msg, LOG_ERR);
258 $this->error = $msg;
259 return -1;
260 }
261
262
268 public function getDriverLabel()
269 {
270 $msg = get_class($this)."::".__FUNCTION__." not implemented";
271 dol_syslog($msg, LOG_ERR);
272 $this->error = $msg;
273 return 'Not implemented';
274 }
275
281 public function getDriverDesc()
282 {
283 $msg = get_class($this)."::".__FUNCTION__." not implemented";
284 dol_syslog($msg, LOG_ERR);
285 $this->error = $msg;
286 return 'Not implemented';
287 }
288
294 public function getDriverVersion()
295 {
296 $msg = get_class($this)."::".__FUNCTION__." not implemented";
297 dol_syslog($msg, LOG_ERR);
298 $this->error = $msg;
299 return 'Not implemented';
300 }
301
307 public function getLibLabel()
308 {
309 $msg = get_class($this)."::".__FUNCTION__." not implemented";
310 dol_syslog($msg, LOG_ERR);
311 $this->error = $msg;
312 return 'Not implemented';
313 }
314
320 public function getLibVersion()
321 {
322 $msg = get_class($this)."::".__FUNCTION__." not implemented";
323 dol_syslog($msg, LOG_ERR);
324 $this->error = $msg;
325 return 'Not implemented';
326 }
327
333 public function getDriverExtension()
334 {
335 $msg = get_class($this)."::".__FUNCTION__." not implemented";
336 dol_syslog($msg, LOG_ERR);
337 $this->error = $msg;
338 return 'Not implemented';
339 }
340
341 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
349 public function open_file($file, $outputlangs)
350 {
351 // phpcs:enable
352 $msg = get_class($this)."::".__FUNCTION__." not implemented";
353 dol_syslog($msg, LOG_ERR);
354 $this->error = $msg;
355 return -1;
356 }
357
358 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
365 public function write_header($outputlangs)
366 {
367 // phpcs:enable
368 $msg = get_class($this)."::".__FUNCTION__." not implemented";
369 dol_syslog($msg, LOG_ERR);
370 $this->error = $msg;
371 return -1;
372 }
373
374 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
384 public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
385 {
386 // phpcs:enable
387 $msg = get_class($this)."::".__FUNCTION__." not implemented";
388 dol_syslog($msg, LOG_ERR);
389 $this->error = $msg;
390 return -1;
391 }
392
393 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
400 public function write_footer($outputlangs)
401 {
402 $msg = get_class($this)."::".__FUNCTION__." not implemented";
403 dol_syslog($msg, LOG_ERR);
404 $this->error = $msg;
405 return -1;
406 }
407
408 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
414 public function close_file()
415 {
416 $msg = get_class($this)."::".__FUNCTION__." not implemented";
417 dol_syslog($msg, LOG_ERR);
418 $this->error = $msg;
419 return -1;
420 }
421}
Parent class for documents (PDF, ODT, ...) generators.
Parent class for export modules.
getDriverLabel()
getDriverLabel
getDriverExtension()
getDriverExtension
getLibVersion()
getLibVersion
getDriverLabelForKey($key)
Return label of driver export.
getDriverVersion()
getDriverVersion
write_footer($outputlangs)
Write footer.
getDriverVersionForKey($key)
Renvoi version d'un driver export.
getLibVersionForKey($key)
Return version of driver lib.
write_header($outputlangs)
Write header.
open_file($file, $outputlangs)
Open output file.
getDriverDescForKey($key)
Renvoi le descriptif d'un driver export.
close_file()
Close Excel file.
listOfAvailableExportFormat($db, $maxfilenamelength=0)
Load into memory list of available export format.
write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
Output record line into file.
getLibLabelForKey($key)
Renvoi label of driver lib.
getPictoForKey($key)
Return picto of export driver.
write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
Output title line into file.
getLibLabel()
getLibLabel
getDriverDesc()
getDriverDesc
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.