dolibarr 21.0.0-alpha
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 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
27
28
32class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance properties loaded by listOfAvailableExportFormat
33{
37 public $id = 'NOT IMPLEMENTED';
38
42 public $error = '';
43
47 public $driverlabel = array();
48
52 public $driverdesc = array();
53
57 public $driverversion = array();
58
62 public $liblabel = array();
63
67 public $libversion = array();
68
72 public $picto;
73
77 public $pictos;
78
82 public $desc;
83
87 public $escape;
88
92 public $enclosure;
93
97 public $col;
98
102 public $disabled;
103
111 public function listOfAvailableExportFormat($db, $maxfilenamelength = 0)
112 {
113 global $langs;
114
115 dol_syslog(get_class($this)."::listOfAvailableExportFormat");
116
117 $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
118 $handle = opendir($dir);
119
120 // Recherche des fichiers drivers exports disponibles
121 $i = 0;
122 if (is_resource($handle)) {
123 while (($file = readdir($handle)) !== false) {
124 $reg = array();
125 if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) {
126 $moduleid = $reg[1];
127 if ($moduleid == 'csv') {
128 continue; // This may happen if on old file export_csv.modules.php was not correctly deleted
129 }
130
131 // Loading Class
132 $file = $dir."export_".$moduleid.".modules.php";
133 $classname = "Export".ucfirst($moduleid);
134
135 require_once $file;
136 if (class_exists($classname)) {
137 $module = new $classname($db);
138 '@phan-var-force ModeleExports $module';
139 // var_dump($classname);
140
141 // Picto
142 $this->pictos[$module->id] = $module->picto;
143 // Driver properties
144 $this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key
145 if (method_exists($module, 'getDriverLabelBis')) {
146 // @phan-suppress-next-line PhanUndeclaredMethod
147 $labelBis = $module->getDriverLabelBis();
148 if ($labelBis) {
149 $this->driverlabel[$module->id] .= ' <span class="opacitymedium">('.$labelBis.')</span>';
150 }
151 }
152 $this->driverdesc[$module->id] = $module->getDriverDesc();
153 $this->driverversion[$module->id] = $module->getDriverVersion();
154 // If use an external lib
155 $this->liblabel[$module->id] = $module->getLibLabel();
156 $this->libversion[$module->id] = $module->getLibVersion();
157 }
158 $i++;
159 }
160 }
161 closedir($handle);
162 }
163
164 asort($this->driverlabel);
165
166 return $this->driverlabel;
167 }
168
169
176 public function getPictoForKey($key)
177 {
178 return $this->pictos[$key];
179 }
180
187 public function getDriverLabelForKey($key)
188 {
189 return $this->driverlabel[$key];
190 }
191
198 public function getDriverDescForKey($key)
199 {
200 return $this->driverdesc[$key];
201 }
202
209 public function getDriverVersionForKey($key)
210 {
211 return $this->driverversion[$key];
212 }
213
220 public function getLibLabelForKey($key)
221 {
222 return $this->liblabel[$key];
223 }
224
231 public function getLibVersionForKey($key)
232 {
233 // phpcs:enable
234 return $this->libversion[$key];
235 }
236
237 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
247 public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
248 {
249 // phpcs:enable
250 $msg = get_class($this)."::".__FUNCTION__." not implemented";
251 dol_syslog($msg, LOG_ERR);
252 $this->error = $msg;
253 return -1;
254 }
255
256
262 public function getDriverLabel()
263 {
264 $msg = get_class($this)."::".__FUNCTION__." not implemented";
265 dol_syslog($msg, LOG_ERR);
266 $this->error = $msg;
267 return 'Not implemented';
268 }
269
275 public function getDriverDesc()
276 {
277 $msg = get_class($this)."::".__FUNCTION__." not implemented";
278 dol_syslog($msg, LOG_ERR);
279 $this->error = $msg;
280 return 'Not implemented';
281 }
282
288 public function getDriverVersion()
289 {
290 $msg = get_class($this)."::".__FUNCTION__." not implemented";
291 dol_syslog($msg, LOG_ERR);
292 $this->error = $msg;
293 return 'Not implemented';
294 }
295
301 public function getLibLabel()
302 {
303 $msg = get_class($this)."::".__FUNCTION__." not implemented";
304 dol_syslog($msg, LOG_ERR);
305 $this->error = $msg;
306 return 'Not implemented';
307 }
308
314 public function getLibVersion()
315 {
316 $msg = get_class($this)."::".__FUNCTION__." not implemented";
317 dol_syslog($msg, LOG_ERR);
318 $this->error = $msg;
319 return 'Not implemented';
320 }
321
327 public function getDriverExtension()
328 {
329 $msg = get_class($this)."::".__FUNCTION__." not implemented";
330 dol_syslog($msg, LOG_ERR);
331 $this->error = $msg;
332 return 'Not implemented';
333 }
334
335 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
343 public function open_file($file, $outputlangs)
344 {
345 // phpcs:enable
346 $msg = get_class($this)."::".__FUNCTION__." not implemented";
347 dol_syslog($msg, LOG_ERR);
348 $this->error = $msg;
349 return -1;
350 }
351
352 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
359 public function write_header($outputlangs)
360 {
361 // phpcs:enable
362 $msg = get_class($this)."::".__FUNCTION__." not implemented";
363 dol_syslog($msg, LOG_ERR);
364 $this->error = $msg;
365 return -1;
366 }
367
368 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
378 public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
379 {
380 // phpcs:enable
381 $msg = get_class($this)."::".__FUNCTION__." not implemented";
382 dol_syslog($msg, LOG_ERR);
383 $this->error = $msg;
384 return -1;
385 }
386
387 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
394 public function write_footer($outputlangs)
395 {
396 $msg = get_class($this)."::".__FUNCTION__." not implemented";
397 dol_syslog($msg, LOG_ERR);
398 $this->error = $msg;
399 return -1;
400 }
401
402 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
408 public function close_file()
409 {
410 $msg = get_class($this)."::".__FUNCTION__." not implemented";
411 dol_syslog($msg, LOG_ERR);
412 $this->error = $msg;
413 return -1;
414 }
415}
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.