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 *
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 */
18
25require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
26
27
31class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance properties loaded by listOfAvailableExportFormat
32{
36 public $error = '';
37
38 public $driverlabel = array();
39
40 public $driverdesc = array();
41
42 public $driverversion = array();
43
44 public $liblabel = array();
45
46 public $libversion = array();
47
51 public $picto;
52
56 public $desc;
57
61 public $escape;
62
66 public $enclosure;
67
71 public $col;
72
76 public $disabled;
77
85 public function listOfAvailableExportFormat($db, $maxfilenamelength = 0)
86 {
87 global $langs;
88
89 dol_syslog(get_class($this)."::listOfAvailableExportFormat");
90
91 $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
92 $handle = opendir($dir);
93
94 // Recherche des fichiers drivers exports disponibles
95 $i = 0;
96 if (is_resource($handle)) {
97 while (($file = readdir($handle)) !== false) {
98 $reg = array();
99 if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) {
100 $moduleid = $reg[1];
101 if ($moduleid == 'csv') {
102 continue; // This may happen if on old file export_csv.modules.php was not correctly deleted
103 }
104
105 // Loading Class
106 $file = $dir."export_".$moduleid.".modules.php";
107 $classname = "Export".ucfirst($moduleid);
108
109 require_once $file;
110 if (class_exists($classname)) {
111 $module = new $classname($db);
112 // var_dump($classname);
113
114 // Picto
115 $this->picto[$module->id] = $module->picto;
116 // Driver properties
117 $this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key
118 if (method_exists($module, 'getDriverLabelBis')) {
119 if ($module->getDriverLabelBis()) {
120 $this->driverlabel[$module->id] .= ' <span class="opacitymedium">('.$module->getDriverLabelBis().')</span>';
121 }
122 }
123 $this->driverdesc[$module->id] = $module->getDriverDesc();
124 $this->driverversion[$module->id] = $module->getDriverVersion();
125 // If use an external lib
126 $this->liblabel[$module->id] = $module->getLibLabel();
127 $this->libversion[$module->id] = $module->getLibVersion();
128 }
129 $i++;
130 }
131 }
132 closedir($handle);
133 }
134
135 asort($this->driverlabel);
136
137 return $this->driverlabel;
138 }
139
140
147 public function getPictoForKey($key)
148 {
149 return $this->picto[$key];
150 }
151
158 public function getDriverLabelForKey($key)
159 {
160 return $this->driverlabel[$key];
161 }
162
169 public function getDriverDescForKey($key)
170 {
171 return $this->driverdesc[$key];
172 }
173
180 public function getDriverVersionForKey($key)
181 {
182 return $this->driverversion[$key];
183 }
184
191 public function getLibLabelForKey($key)
192 {
193 return $this->liblabel[$key];
194 }
195
202 public function getLibVersionForKey($key)
203 {
204 return $this->libversion[$key];
205 }
206}
Parent class for documents (PDF, ODT, ...) generators.
Parent class for export modules.
getDriverLabelForKey($key)
Return label of driver export.
getDriverVersionForKey($key)
Renvoi version d'un driver export.
getLibVersionForKey($key)
Return version of driver lib.
getDriverDescForKey($key)
Renvoi le descriptif d'un driver export.
listOfAvailableExportFormat($db, $maxfilenamelength=0)
Load into memory list of available export format.
getLibLabelForKey($key)
Renvoi label of driver lib.
getPictoForKey($key)
Return picto of export driver.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.