@@ -33,49 +33,49 @@ discard block |
||
33 | 33 | class Documents extends DolibarrApi |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
38 | - */ |
|
39 | - static $DOCUMENT_FIELDS = array( |
|
40 | - 'modulepart' |
|
41 | - ); |
|
42 | - |
|
43 | - /** |
|
44 | - * Constructor |
|
45 | - */ |
|
46 | - function __construct() |
|
47 | - { |
|
48 | - global $db; |
|
49 | - $this->db = $db; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
55 | - * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
56 | - * |
|
57 | - * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
58 | - * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
59 | - * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
60 | - * Also, note that setting this to 1 nead write access on object. |
|
61 | - * @return array List of documents |
|
62 | - * |
|
63 | - * @throws 500 |
|
64 | - * @throws 501 |
|
65 | - * @throws 400 |
|
66 | - * @throws 401 |
|
67 | - * @throws 200 |
|
68 | - */ |
|
69 | - public function index($module_part, $original_file='', $regeneratedoc=0) |
|
70 | - { |
|
36 | + /** |
|
37 | + * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
38 | + */ |
|
39 | + static $DOCUMENT_FIELDS = array( |
|
40 | + 'modulepart' |
|
41 | + ); |
|
42 | + |
|
43 | + /** |
|
44 | + * Constructor |
|
45 | + */ |
|
46 | + function __construct() |
|
47 | + { |
|
48 | + global $db; |
|
49 | + $this->db = $db; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
55 | + * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
56 | + * |
|
57 | + * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
58 | + * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
59 | + * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
60 | + * Also, note that setting this to 1 nead write access on object. |
|
61 | + * @return array List of documents |
|
62 | + * |
|
63 | + * @throws 500 |
|
64 | + * @throws 501 |
|
65 | + * @throws 400 |
|
66 | + * @throws 401 |
|
67 | + * @throws 200 |
|
68 | + */ |
|
69 | + public function index($module_part, $original_file='', $regeneratedoc=0) |
|
70 | + { |
|
71 | 71 | global $conf; |
72 | 72 | |
73 | 73 | if (empty($module_part)) { |
74 | - throw new RestException(400, 'bad value for parameter modulepart'); |
|
74 | + throw new RestException(400, 'bad value for parameter modulepart'); |
|
75 | + } |
|
76 | + if (empty($original_file)) { |
|
77 | + throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
75 | 78 | } |
76 | - if (empty($original_file)) { |
|
77 | - throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
78 | - } |
|
79 | 79 | |
80 | 80 | //--- Finds and returns the document |
81 | 81 | $entity=$conf->entity; |
@@ -87,94 +87,94 @@ discard block |
||
87 | 87 | |
88 | 88 | if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) |
89 | 89 | { |
90 | - throw new RestException(401); |
|
90 | + throw new RestException(401); |
|
91 | + } |
|
92 | + if (!$accessallowed) { |
|
93 | + throw new RestException(401); |
|
94 | + } |
|
95 | + |
|
96 | + // --- Generates the document |
|
97 | + if ($regeneratedoc) |
|
98 | + { |
|
99 | + $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
100 | + $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
101 | + $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
102 | + |
|
103 | + if ($module_part == 'facture' || $module_part == 'invoice') |
|
104 | + { |
|
105 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
106 | + $this->invoice = new Facture($this->db); |
|
107 | + $result = $this->invoice->fetch(0, $ref); |
|
108 | + if( ! $result ) { |
|
109 | + throw new RestException(404, 'Invoice not found'); |
|
110 | + } |
|
111 | + $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
112 | + if( $result <= 0 ) { |
|
113 | + throw new RestException(500, 'Error generating document'); |
|
114 | + } |
|
115 | + } |
|
91 | 116 | } |
92 | - if (!$accessallowed) { |
|
93 | - throw new RestException(401); |
|
94 | - } |
|
95 | - |
|
96 | - // --- Generates the document |
|
97 | - if ($regeneratedoc) |
|
98 | - { |
|
99 | - $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
100 | - $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
101 | - $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
102 | - |
|
103 | - if ($module_part == 'facture' || $module_part == 'invoice') |
|
104 | - { |
|
105 | - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
106 | - $this->invoice = new Facture($this->db); |
|
107 | - $result = $this->invoice->fetch(0, $ref); |
|
108 | - if( ! $result ) { |
|
109 | - throw new RestException(404, 'Invoice not found'); |
|
110 | - } |
|
111 | - $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
112 | - if( $result <= 0 ) { |
|
113 | - throw new RestException(500, 'Error generating document'); |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
117 | 117 | |
118 | 118 | $filename = basename($original_file); |
119 | 119 | $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset |
120 | 120 | |
121 | 121 | if (! file_exists($original_file_osencoded)) |
122 | 122 | { |
123 | - throw new RestException(404, 'File not found'); |
|
123 | + throw new RestException(404, 'File not found'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $file_content=file_get_contents($original_file_osencoded); |
127 | - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Return a document. |
|
133 | - * |
|
134 | - * @param int $id ID of document |
|
135 | - * @return array Array with data of file |
|
136 | - * |
|
137 | - * @throws RestException |
|
138 | - */ |
|
139 | - /* |
|
127 | + return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Return a document. |
|
133 | + * |
|
134 | + * @param int $id ID of document |
|
135 | + * @return array Array with data of file |
|
136 | + * |
|
137 | + * @throws RestException |
|
138 | + */ |
|
139 | + /* |
|
140 | 140 | public function get($id) { |
141 | 141 | return array('note'=>'xxx'); |
142 | 142 | }*/ |
143 | 143 | |
144 | 144 | |
145 | - /** |
|
146 | - * Push a file. |
|
147 | - * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
148 | - * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
149 | - * |
|
150 | - * @param string $filename Name of file to create ('FA1705-0123') |
|
151 | - * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
152 | - * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
153 | - * @param string $subdir Subdirectory (Only if ref not provided) |
|
154 | - * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
155 | - * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
156 | - * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
157 | - * @return bool State of copy |
|
158 | - * @throws RestException |
|
159 | - */ |
|
160 | - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
161 | - { |
|
162 | - global $db, $conf; |
|
163 | - |
|
164 | - /*var_dump($modulepart); |
|
145 | + /** |
|
146 | + * Push a file. |
|
147 | + * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
148 | + * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
149 | + * |
|
150 | + * @param string $filename Name of file to create ('FA1705-0123') |
|
151 | + * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
152 | + * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
153 | + * @param string $subdir Subdirectory (Only if ref not provided) |
|
154 | + * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
155 | + * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
156 | + * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
157 | + * @return bool State of copy |
|
158 | + * @throws RestException |
|
159 | + */ |
|
160 | + public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
161 | + { |
|
162 | + global $db, $conf; |
|
163 | + |
|
164 | + /*var_dump($modulepart); |
|
165 | 165 | var_dump($filename); |
166 | 166 | var_dump($filecontent); |
167 | 167 | exit;*/ |
168 | 168 | |
169 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
169 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
170 | 170 | |
171 | - if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
172 | - throw new RestException(401); |
|
173 | - } |
|
171 | + if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
172 | + throw new RestException(401); |
|
173 | + } |
|
174 | 174 | |
175 | - $newfilecontent = ''; |
|
176 | - if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
177 | - if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
175 | + $newfilecontent = ''; |
|
176 | + if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
177 | + if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
178 | 178 | |
179 | 179 | $original_file = dol_sanitizeFileName($filename); |
180 | 180 | |
@@ -183,37 +183,37 @@ discard block |
||
183 | 183 | $entity = $user->entity; |
184 | 184 | if ($ref) |
185 | 185 | { |
186 | - if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
187 | - { |
|
188 | - $modulepart='facture'; |
|
189 | - $object=new Facture($db); |
|
190 | - $result = $object->fetch('', $ref); |
|
191 | - } |
|
192 | - |
|
193 | - if (! ($object->id > 0)) |
|
194 | - { |
|
195 | - throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
196 | - } |
|
197 | - |
|
198 | - $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
199 | - $upload_dir = $tmp['original_file']; |
|
200 | - |
|
201 | - if (empty($upload_dir) || $upload_dir == '/') |
|
202 | - { |
|
203 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
204 | - } |
|
186 | + if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
187 | + { |
|
188 | + $modulepart='facture'; |
|
189 | + $object=new Facture($db); |
|
190 | + $result = $object->fetch('', $ref); |
|
191 | + } |
|
192 | + |
|
193 | + if (! ($object->id > 0)) |
|
194 | + { |
|
195 | + throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
196 | + } |
|
197 | + |
|
198 | + $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
199 | + $upload_dir = $tmp['original_file']; |
|
200 | + |
|
201 | + if (empty($upload_dir) || $upload_dir == '/') |
|
202 | + { |
|
203 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
204 | + } |
|
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
208 | - if ($modulepart == 'invoice') $modulepart ='facture'; |
|
208 | + if ($modulepart == 'invoice') $modulepart ='facture'; |
|
209 | 209 | |
210 | - $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
211 | - $upload_dir = $tmp['original_file']; |
|
210 | + $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
211 | + $upload_dir = $tmp['original_file']; |
|
212 | 212 | |
213 | - if (empty($upload_dir) || $upload_dir == '/') |
|
214 | - { |
|
215 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
216 | - } |
|
213 | + if (empty($upload_dir) || $upload_dir == '/') |
|
214 | + { |
|
215 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,46 +223,46 @@ discard block |
||
223 | 223 | $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; |
224 | 224 | dol_delete_file($destfiletmp); |
225 | 225 | |
226 | - if (!dol_is_dir($upload_dir)) { |
|
227 | - throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
228 | - } |
|
229 | - |
|
230 | - if (! $overwriteifexists && dol_is_file($destfile)) |
|
231 | - { |
|
232 | - throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
233 | - } |
|
234 | - |
|
235 | - $fhandle = @fopen($destfiletmp, 'w'); |
|
236 | - if ($fhandle) |
|
237 | - { |
|
238 | - $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
239 | - fclose($fhandle); |
|
240 | - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
241 | - } |
|
242 | - else |
|
243 | - { |
|
244 | - throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
245 | - } |
|
246 | - |
|
247 | - $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
248 | - |
|
249 | - return $result; |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Validate fields before create or update object |
|
254 | - * |
|
255 | - * @param array $data Array with data to verify |
|
256 | - * @return array |
|
257 | - * @throws RestException |
|
258 | - */ |
|
259 | - function _validate_file($data) { |
|
260 | - $result = array(); |
|
261 | - foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
262 | - if (!isset($data[$field])) |
|
263 | - throw new RestException(400, "$field field missing"); |
|
264 | - $result[$field] = $data[$field]; |
|
265 | - } |
|
266 | - return $result; |
|
267 | - } |
|
226 | + if (!dol_is_dir($upload_dir)) { |
|
227 | + throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
228 | + } |
|
229 | + |
|
230 | + if (! $overwriteifexists && dol_is_file($destfile)) |
|
231 | + { |
|
232 | + throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
233 | + } |
|
234 | + |
|
235 | + $fhandle = @fopen($destfiletmp, 'w'); |
|
236 | + if ($fhandle) |
|
237 | + { |
|
238 | + $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
239 | + fclose($fhandle); |
|
240 | + @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
245 | + } |
|
246 | + |
|
247 | + $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
248 | + |
|
249 | + return $result; |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Validate fields before create or update object |
|
254 | + * |
|
255 | + * @param array $data Array with data to verify |
|
256 | + * @return array |
|
257 | + * @throws RestException |
|
258 | + */ |
|
259 | + function _validate_file($data) { |
|
260 | + $result = array(); |
|
261 | + foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
262 | + if (!isset($data[$field])) |
|
263 | + throw new RestException(400, "$field field missing"); |
|
264 | + $result[$field] = $data[$field]; |
|
265 | + } |
|
266 | + return $result; |
|
267 | + } |
|
268 | 268 | } |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | $sql .= " AND fd.fk_code_ventilation > 0"; |
101 | 101 | $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy |
102 | 102 | if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
103 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
103 | + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
104 | 104 | } else { |
105 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
105 | + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
106 | 106 | } |
107 | 107 | if ($date_start && $date_end) |
108 | 108 | $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $bookkeeping->doc_type = 'supplier_invoice'; |
278 | 278 | $bookkeeping->fk_doc = $key; |
279 | 279 | $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
280 | - $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
|
280 | + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
|
281 | 281 | $bookkeeping->subledger_account = ''; |
282 | 282 | $bookkeeping->subledger_label = ''; |
283 | 283 | $bookkeeping->numero_compte = $k; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $bookkeeping->doc_type = 'customer_invoice'; |
296 | 296 | $bookkeeping->fk_doc = $key; |
297 | 297 | $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
298 | - $bookkeeping->thirdparty_code = $companystatic->code_client; |
|
298 | + $bookkeeping->thirdparty_code = $companystatic->code_client; |
|
299 | 299 | $bookkeeping->subledger_account = ''; |
300 | 300 | $bookkeeping->subledger_label = ''; |
301 | 301 | $bookkeeping->numero_compte = $k; |
@@ -550,12 +550,12 @@ discard block |
||
550 | 550 | |
551 | 551 | // Button to write into Ledger |
552 | 552 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
553 | - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
554 | - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
|
553 | + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
554 | + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
|
555 | 555 | } |
556 | 556 | print '<div class="tabsAction tabsActionNoBottom">'; |
557 | 557 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
558 | - print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
558 | + print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
559 | 559 | } |
560 | 560 | else { |
561 | 561 | print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
77 | 77 | if (empty($newmask)) // This should no happen |
78 | 78 | { |
79 | - $newmask='0664'; |
|
79 | + $newmask='0664'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -86,179 +86,179 @@ discard block |
||
86 | 86 | |
87 | 87 | if ($dirins && $action == 'initmodule' && $modulename) |
88 | 88 | { |
89 | - if (preg_match('/\s/', $modulename)) |
|
90 | - { |
|
91 | - $error++; |
|
92 | - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
93 | - } |
|
94 | - |
|
95 | - if (! $error) |
|
96 | - { |
|
97 | - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; |
|
98 | - $destdir = $dirins.'/'.strtolower($modulename); |
|
99 | - |
|
100 | - $arrayreplacement=array( |
|
101 | - 'mymodule'=>strtolower($modulename), |
|
102 | - 'MyModule'=>$modulename |
|
103 | - ); |
|
104 | - |
|
105 | - $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); |
|
106 | - //dol_mkdir($destfile); |
|
107 | - if ($result <= 0) |
|
108 | - { |
|
109 | - if ($result < 0) |
|
110 | - { |
|
111 | - $error++; |
|
112 | - $langs->load("errors"); |
|
113 | - setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); |
|
114 | - } |
|
115 | - else // $result == 0 |
|
116 | - { |
|
117 | - setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - // Delete some files |
|
122 | - dol_delete_file($destdir.'/myobject_card.php'); |
|
123 | - dol_delete_file($destdir.'/myobject_note.php'); |
|
124 | - dol_delete_file($destdir.'/myobject_document.php'); |
|
125 | - dol_delete_file($destdir.'/myobject_agenda.php'); |
|
126 | - dol_delete_file($destdir.'/myobject_list.php'); |
|
127 | - dol_delete_file($destdir.'/lib/myobject.lib.php'); |
|
128 | - dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); |
|
129 | - dol_delete_file($destdir.'/sql/llx_myobject.sql'); |
|
130 | - dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); |
|
131 | - dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); |
|
132 | - dol_delete_file($destdir.'/scripts/myobject.php'); |
|
133 | - dol_delete_file($destdir.'/img/object_myobject.png'); |
|
134 | - dol_delete_file($destdir.'/class/myobject.class.php'); |
|
135 | - dol_delete_file($destdir.'/class/api_myobject.class.php'); |
|
136 | - } |
|
137 | - |
|
138 | - // Edit PHP files |
|
139 | - if (! $error) |
|
140 | - { |
|
141 | - $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); |
|
142 | - foreach($listofphpfilestoedit as $phpfileval) |
|
143 | - { |
|
144 | - //var_dump($phpfileval['fullname']); |
|
145 | - $arrayreplacement=array( |
|
146 | - 'mymodule'=>strtolower($modulename), |
|
147 | - 'MyModule'=>$modulename, |
|
148 | - 'MYMODULE'=>strtoupper($modulename), |
|
149 | - 'My module'=>$modulename, |
|
150 | - 'my module'=>$modulename, |
|
151 | - 'Mon module'=>$modulename, |
|
152 | - 'mon module'=>$modulename, |
|
153 | - 'htdocs/modulebuilder/template'=>strtolower($modulename), |
|
154 | - '---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') |
|
155 | - ); |
|
156 | - |
|
157 | - |
|
158 | - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); |
|
159 | - //var_dump($result); |
|
160 | - if ($result < 0) |
|
161 | - { |
|
162 | - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - if (! $error) |
|
168 | - { |
|
169 | - setEventMessages('ModuleInitialized', null); |
|
170 | - $module=$modulename; |
|
171 | - $modulename = ''; |
|
172 | - } |
|
89 | + if (preg_match('/\s/', $modulename)) |
|
90 | + { |
|
91 | + $error++; |
|
92 | + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
93 | + } |
|
94 | + |
|
95 | + if (! $error) |
|
96 | + { |
|
97 | + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; |
|
98 | + $destdir = $dirins.'/'.strtolower($modulename); |
|
99 | + |
|
100 | + $arrayreplacement=array( |
|
101 | + 'mymodule'=>strtolower($modulename), |
|
102 | + 'MyModule'=>$modulename |
|
103 | + ); |
|
104 | + |
|
105 | + $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); |
|
106 | + //dol_mkdir($destfile); |
|
107 | + if ($result <= 0) |
|
108 | + { |
|
109 | + if ($result < 0) |
|
110 | + { |
|
111 | + $error++; |
|
112 | + $langs->load("errors"); |
|
113 | + setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); |
|
114 | + } |
|
115 | + else // $result == 0 |
|
116 | + { |
|
117 | + setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + // Delete some files |
|
122 | + dol_delete_file($destdir.'/myobject_card.php'); |
|
123 | + dol_delete_file($destdir.'/myobject_note.php'); |
|
124 | + dol_delete_file($destdir.'/myobject_document.php'); |
|
125 | + dol_delete_file($destdir.'/myobject_agenda.php'); |
|
126 | + dol_delete_file($destdir.'/myobject_list.php'); |
|
127 | + dol_delete_file($destdir.'/lib/myobject.lib.php'); |
|
128 | + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); |
|
129 | + dol_delete_file($destdir.'/sql/llx_myobject.sql'); |
|
130 | + dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); |
|
131 | + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); |
|
132 | + dol_delete_file($destdir.'/scripts/myobject.php'); |
|
133 | + dol_delete_file($destdir.'/img/object_myobject.png'); |
|
134 | + dol_delete_file($destdir.'/class/myobject.class.php'); |
|
135 | + dol_delete_file($destdir.'/class/api_myobject.class.php'); |
|
136 | + } |
|
137 | + |
|
138 | + // Edit PHP files |
|
139 | + if (! $error) |
|
140 | + { |
|
141 | + $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); |
|
142 | + foreach($listofphpfilestoedit as $phpfileval) |
|
143 | + { |
|
144 | + //var_dump($phpfileval['fullname']); |
|
145 | + $arrayreplacement=array( |
|
146 | + 'mymodule'=>strtolower($modulename), |
|
147 | + 'MyModule'=>$modulename, |
|
148 | + 'MYMODULE'=>strtoupper($modulename), |
|
149 | + 'My module'=>$modulename, |
|
150 | + 'my module'=>$modulename, |
|
151 | + 'Mon module'=>$modulename, |
|
152 | + 'mon module'=>$modulename, |
|
153 | + 'htdocs/modulebuilder/template'=>strtolower($modulename), |
|
154 | + '---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') |
|
155 | + ); |
|
156 | + |
|
157 | + |
|
158 | + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); |
|
159 | + //var_dump($result); |
|
160 | + if ($result < 0) |
|
161 | + { |
|
162 | + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + if (! $error) |
|
168 | + { |
|
169 | + setEventMessages('ModuleInitialized', null); |
|
170 | + $module=$modulename; |
|
171 | + $modulename = ''; |
|
172 | + } |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | if ($dirins && $action == 'initobject' && $module && $objectname) |
176 | 176 | { |
177 | - if (preg_match('/\s/', $objectname)) |
|
178 | - { |
|
179 | - $error++; |
|
180 | - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
181 | - } |
|
182 | - |
|
183 | - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; |
|
184 | - $destdir = $dirins.'/'.strtolower($module); |
|
185 | - |
|
186 | - // Scan dir class to find if an object with same name already exists. |
|
187 | - if (! $error) |
|
188 | - { |
|
189 | - $dirlist=dol_dir_list($destdir.'/class','files',0,'\.txt$'); |
|
190 | - $alreadyfound=false; |
|
191 | - foreach($dirlist as $key => $val) |
|
192 | - { |
|
193 | - $filefound=preg_replace('/\.txt$/','',$val['name']); |
|
194 | - if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) |
|
195 | - { |
|
196 | - $alreadyfound=true; |
|
197 | - $error++; |
|
198 | - setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); |
|
199 | - break; |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - if (! $error) |
|
205 | - { |
|
206 | - // Delete some files |
|
207 | - $filetogenerate = array( |
|
208 | - 'myobject_card.php'=>strtolower($objectname).'_card.php', |
|
209 | - 'myobject_note.php'=>strtolower($objectname).'_note.php', |
|
210 | - 'myobject_document.php'=>strtolower($objectname).'_document.php', |
|
211 | - 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', |
|
212 | - 'myobject_list.php'=>strtolower($objectname).'_list.php', |
|
213 | - 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', |
|
214 | - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', |
|
215 | - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', |
|
216 | - 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', |
|
217 | - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', |
|
218 | - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', |
|
219 | - 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', |
|
220 | - 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', |
|
221 | - 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php' |
|
222 | - ); |
|
223 | - |
|
224 | - foreach($filetogenerate as $srcfile => $destfile) |
|
225 | - { |
|
226 | - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); |
|
227 | - if ($result <= 0) |
|
228 | - { |
|
229 | - if ($result < 0) |
|
230 | - { |
|
231 | - $error++; |
|
232 | - $langs->load("errors"); |
|
233 | - setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); |
|
234 | - } |
|
235 | - else // $result == 0 |
|
236 | - { |
|
237 | - setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings'); |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - if (! $error) |
|
243 | - { |
|
244 | - // Scan for object class files |
|
245 | - $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); |
|
246 | - |
|
247 | - $firstobjectname=''; |
|
248 | - foreach($listofobject as $fileobj) |
|
249 | - { |
|
250 | - if (preg_match('/^api_/',$fileobj['name'])) continue; |
|
251 | - if (preg_match('/^actions_/',$fileobj['name'])) continue; |
|
252 | - |
|
253 | - $tmpcontent=file_get_contents($fileobj['fullname']); |
|
254 | - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) |
|
255 | - { |
|
256 | - $objectnameloop = $reg[1]; |
|
257 | - if (empty($firstobjectname)) $firstobjectname = $objectnameloop; |
|
258 | - } |
|
259 | - |
|
260 | - // Regenerate left menu entry in descriptor for $objectname |
|
261 | - $stringtoadd=" |
|
177 | + if (preg_match('/\s/', $objectname)) |
|
178 | + { |
|
179 | + $error++; |
|
180 | + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
181 | + } |
|
182 | + |
|
183 | + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; |
|
184 | + $destdir = $dirins.'/'.strtolower($module); |
|
185 | + |
|
186 | + // Scan dir class to find if an object with same name already exists. |
|
187 | + if (! $error) |
|
188 | + { |
|
189 | + $dirlist=dol_dir_list($destdir.'/class','files',0,'\.txt$'); |
|
190 | + $alreadyfound=false; |
|
191 | + foreach($dirlist as $key => $val) |
|
192 | + { |
|
193 | + $filefound=preg_replace('/\.txt$/','',$val['name']); |
|
194 | + if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) |
|
195 | + { |
|
196 | + $alreadyfound=true; |
|
197 | + $error++; |
|
198 | + setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); |
|
199 | + break; |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + if (! $error) |
|
205 | + { |
|
206 | + // Delete some files |
|
207 | + $filetogenerate = array( |
|
208 | + 'myobject_card.php'=>strtolower($objectname).'_card.php', |
|
209 | + 'myobject_note.php'=>strtolower($objectname).'_note.php', |
|
210 | + 'myobject_document.php'=>strtolower($objectname).'_document.php', |
|
211 | + 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', |
|
212 | + 'myobject_list.php'=>strtolower($objectname).'_list.php', |
|
213 | + 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', |
|
214 | + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', |
|
215 | + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', |
|
216 | + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', |
|
217 | + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', |
|
218 | + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', |
|
219 | + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', |
|
220 | + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', |
|
221 | + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php' |
|
222 | + ); |
|
223 | + |
|
224 | + foreach($filetogenerate as $srcfile => $destfile) |
|
225 | + { |
|
226 | + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); |
|
227 | + if ($result <= 0) |
|
228 | + { |
|
229 | + if ($result < 0) |
|
230 | + { |
|
231 | + $error++; |
|
232 | + $langs->load("errors"); |
|
233 | + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); |
|
234 | + } |
|
235 | + else // $result == 0 |
|
236 | + { |
|
237 | + setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings'); |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + if (! $error) |
|
243 | + { |
|
244 | + // Scan for object class files |
|
245 | + $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); |
|
246 | + |
|
247 | + $firstobjectname=''; |
|
248 | + foreach($listofobject as $fileobj) |
|
249 | + { |
|
250 | + if (preg_match('/^api_/',$fileobj['name'])) continue; |
|
251 | + if (preg_match('/^actions_/',$fileobj['name'])) continue; |
|
252 | + |
|
253 | + $tmpcontent=file_get_contents($fileobj['fullname']); |
|
254 | + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) |
|
255 | + { |
|
256 | + $objectnameloop = $reg[1]; |
|
257 | + if (empty($firstobjectname)) $firstobjectname = $objectnameloop; |
|
258 | + } |
|
259 | + |
|
260 | + // Regenerate left menu entry in descriptor for $objectname |
|
261 | + $stringtoadd=" |
|
262 | 262 | \t\t\$this->menu[\$r++]=array( |
263 | 263 | 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
264 | 264 | 'type'=>'left', // This is a Left menu entry |
@@ -286,123 +286,123 @@ discard block |
||
286 | 286 | 'target'=>'', |
287 | 287 | 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
288 | 288 | "; |
289 | - $stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd); |
|
290 | - $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); |
|
291 | - $stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd); |
|
289 | + $stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd); |
|
290 | + $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); |
|
291 | + $stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd); |
|
292 | 292 | |
293 | - $moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php'; |
|
293 | + $moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php'; |
|
294 | 294 | |
295 | - // TODO Allow a replace with regex using dolReplaceRegexInFile |
|
296 | - // TODO Avoid duplicate addition |
|
295 | + // TODO Allow a replace with regex using dolReplaceRegexInFile |
|
296 | + // TODO Avoid duplicate addition |
|
297 | 297 | |
298 | - dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); |
|
298 | + dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); |
|
299 | 299 | |
300 | 300 | // Add module descriptor to list of files to replace "MyObject' string with real name of object. |
301 | - $filetogenerate[]='core/modules/mod'.$module.'.class.php'; |
|
302 | - |
|
303 | - // TODO |
|
304 | - } |
|
305 | - } |
|
306 | - } |
|
307 | - |
|
308 | - if (! $error) |
|
309 | - { |
|
310 | - // Edit PHP files |
|
311 | - foreach($filetogenerate as $destfile) |
|
312 | - { |
|
313 | - $phpfileval['fullname'] = $destdir.'/'.$destfile; |
|
314 | - |
|
315 | - //var_dump($phpfileval['fullname']); |
|
316 | - $arrayreplacement=array( |
|
317 | - 'mymodule'=>strtolower($module), |
|
318 | - 'MyModule'=>$module, |
|
319 | - 'MYMODULE'=>strtoupper($module), |
|
320 | - 'My module'=>$module, |
|
321 | - 'my module'=>$module, |
|
322 | - 'mon module'=>$module, |
|
323 | - 'Mon module'=>$module, |
|
324 | - 'htdocs/modulebuilder/template/'=>strtolower($modulename), |
|
325 | - 'myobject'=>strtolower($objectname), |
|
326 | - 'MyObject'=>$objectname |
|
327 | - ); |
|
328 | - |
|
329 | - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); |
|
330 | - //var_dump($result); |
|
331 | - if ($result < 0) |
|
332 | - { |
|
333 | - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); |
|
334 | - } |
|
335 | - } |
|
336 | - } |
|
337 | - |
|
338 | - if (! $error) |
|
339 | - { |
|
340 | - // Edit the class file to write properties |
|
341 | - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); |
|
342 | - if (is_numeric($object) && $object < 0) $error++; |
|
343 | - } |
|
344 | - if (! $error) |
|
345 | - { |
|
346 | - // Edit sql with new properties |
|
347 | - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); |
|
348 | - if ($result < 0) $error++; |
|
349 | - } |
|
350 | - |
|
351 | - if (! $error) |
|
352 | - { |
|
353 | - setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); |
|
354 | - } |
|
301 | + $filetogenerate[]='core/modules/mod'.$module.'.class.php'; |
|
302 | + |
|
303 | + // TODO |
|
304 | + } |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + if (! $error) |
|
309 | + { |
|
310 | + // Edit PHP files |
|
311 | + foreach($filetogenerate as $destfile) |
|
312 | + { |
|
313 | + $phpfileval['fullname'] = $destdir.'/'.$destfile; |
|
314 | + |
|
315 | + //var_dump($phpfileval['fullname']); |
|
316 | + $arrayreplacement=array( |
|
317 | + 'mymodule'=>strtolower($module), |
|
318 | + 'MyModule'=>$module, |
|
319 | + 'MYMODULE'=>strtoupper($module), |
|
320 | + 'My module'=>$module, |
|
321 | + 'my module'=>$module, |
|
322 | + 'mon module'=>$module, |
|
323 | + 'Mon module'=>$module, |
|
324 | + 'htdocs/modulebuilder/template/'=>strtolower($modulename), |
|
325 | + 'myobject'=>strtolower($objectname), |
|
326 | + 'MyObject'=>$objectname |
|
327 | + ); |
|
328 | + |
|
329 | + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); |
|
330 | + //var_dump($result); |
|
331 | + if ($result < 0) |
|
332 | + { |
|
333 | + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); |
|
334 | + } |
|
335 | + } |
|
336 | + } |
|
337 | + |
|
338 | + if (! $error) |
|
339 | + { |
|
340 | + // Edit the class file to write properties |
|
341 | + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); |
|
342 | + if (is_numeric($object) && $object < 0) $error++; |
|
343 | + } |
|
344 | + if (! $error) |
|
345 | + { |
|
346 | + // Edit sql with new properties |
|
347 | + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); |
|
348 | + if ($result < 0) $error++; |
|
349 | + } |
|
350 | + |
|
351 | + if (! $error) |
|
352 | + { |
|
353 | + setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); |
|
354 | + } |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) |
358 | 358 | { |
359 | - $objectname = $tabobj; |
|
360 | - |
|
361 | - $srcdir = $dirread.'/'.strtolower($module); |
|
362 | - $destdir = $dirins.'/'.strtolower($module); |
|
363 | - dol_mkdir($destdir); |
|
364 | - |
|
365 | - $addfieldentry = array( |
|
366 | - 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), |
|
367 | - 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' |
|
368 | - 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), |
|
369 | - 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), |
|
370 | - 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp')); |
|
371 | - |
|
372 | - if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) |
|
373 | - { |
|
374 | - $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); |
|
375 | - } |
|
376 | - |
|
377 | - // Edit the class file to write properties |
|
378 | - if (! $error) |
|
379 | - { |
|
380 | - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); |
|
359 | + $objectname = $tabobj; |
|
360 | + |
|
361 | + $srcdir = $dirread.'/'.strtolower($module); |
|
362 | + $destdir = $dirins.'/'.strtolower($module); |
|
363 | + dol_mkdir($destdir); |
|
364 | + |
|
365 | + $addfieldentry = array( |
|
366 | + 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), |
|
367 | + 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' |
|
368 | + 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), |
|
369 | + 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), |
|
370 | + 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp')); |
|
371 | + |
|
372 | + if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) |
|
373 | + { |
|
374 | + $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); |
|
375 | + } |
|
376 | + |
|
377 | + // Edit the class file to write properties |
|
378 | + if (! $error) |
|
379 | + { |
|
380 | + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); |
|
381 | 381 | if (is_numeric($result) && $result <= 0) $error++; |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | - // Edit sql with new properties |
|
385 | - if (! $error) |
|
386 | - { |
|
387 | - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); |
|
384 | + // Edit sql with new properties |
|
385 | + if (! $error) |
|
386 | + { |
|
387 | + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); |
|
388 | 388 | if ($result <= 0) |
389 | 389 | { |
390 | 390 | $error++; |
391 | 391 | } |
392 | - } |
|
392 | + } |
|
393 | 393 | |
394 | - if (! $error) |
|
395 | - { |
|
396 | - clearstatcache(); |
|
394 | + if (! $error) |
|
395 | + { |
|
396 | + clearstatcache(); |
|
397 | 397 | |
398 | - setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); |
|
398 | + setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); |
|
399 | 399 | |
400 | - // Make a redirect to reload all data |
|
401 | - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); |
|
400 | + // Make a redirect to reload all data |
|
401 | + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); |
|
402 | 402 | |
403 | - clearstatcache(); |
|
404 | - exit; |
|
405 | - } |
|
403 | + clearstatcache(); |
|
404 | + exit; |
|
405 | + } |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) |
@@ -433,171 +433,171 @@ discard block |
||
433 | 433 | |
434 | 434 | setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); |
435 | 435 | |
436 | - // Make a redirect to reload all data |
|
437 | - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); |
|
436 | + // Make a redirect to reload all data |
|
437 | + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); |
|
438 | 438 | |
439 | - clearstatcache(); |
|
440 | - exit; |
|
439 | + clearstatcache(); |
|
440 | + exit; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | if ($dirins && $action == 'confirm_delete') |
445 | 445 | { |
446 | - if (preg_match('/\s/', $module)) |
|
447 | - { |
|
448 | - $error++; |
|
449 | - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
450 | - } |
|
451 | - |
|
452 | - if (! $error) |
|
453 | - { |
|
454 | - $modulelowercase=strtolower($module); |
|
455 | - |
|
456 | - // Dir for module |
|
457 | - $dir = $dirins.'/'.$modulelowercase; |
|
458 | - |
|
459 | - $result = dol_delete_dir_recursive($dir); |
|
460 | - |
|
461 | - if ($result > 0) |
|
462 | - { |
|
463 | - setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); |
|
464 | - } |
|
465 | - else |
|
466 | - { |
|
467 | - setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); |
|
468 | - } |
|
469 | - } |
|
470 | - |
|
471 | - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); |
|
472 | - //exit; |
|
473 | - $action = ''; |
|
474 | - $module = 'deletemodule'; |
|
446 | + if (preg_match('/\s/', $module)) |
|
447 | + { |
|
448 | + $error++; |
|
449 | + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
450 | + } |
|
451 | + |
|
452 | + if (! $error) |
|
453 | + { |
|
454 | + $modulelowercase=strtolower($module); |
|
455 | + |
|
456 | + // Dir for module |
|
457 | + $dir = $dirins.'/'.$modulelowercase; |
|
458 | + |
|
459 | + $result = dol_delete_dir_recursive($dir); |
|
460 | + |
|
461 | + if ($result > 0) |
|
462 | + { |
|
463 | + setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); |
|
464 | + } |
|
465 | + else |
|
466 | + { |
|
467 | + setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); |
|
468 | + } |
|
469 | + } |
|
470 | + |
|
471 | + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); |
|
472 | + //exit; |
|
473 | + $action = ''; |
|
474 | + $module = 'deletemodule'; |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | if ($dirins && $action == 'confirm_deleteobject' && $objectname) |
478 | 478 | { |
479 | - if (preg_match('/[^a-z0-9]/i', $objectname)) |
|
480 | - { |
|
481 | - $error++; |
|
482 | - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
483 | - } |
|
484 | - |
|
485 | - if (! $error) |
|
486 | - { |
|
487 | - $modulelowercase=strtolower($module); |
|
488 | - $objectlowercase=strtolower($objectname); |
|
489 | - |
|
490 | - // Dir for module |
|
491 | - $dir = $dirins.'/'.$modulelowercase; |
|
492 | - |
|
493 | - // Delete some files |
|
494 | - $filetogenerate = array( |
|
495 | - 'myobject_card.php'=>strtolower($objectname).'_card.php', |
|
496 | - 'myobject_note.php'=>strtolower($objectname).'_note.php', |
|
497 | - 'myobject_document.php'=>strtolower($objectname).'_document.php', |
|
498 | - 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', |
|
499 | - 'myobject_list.php'=>strtolower($objectname).'_list.php', |
|
500 | - 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', |
|
501 | - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', |
|
502 | - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', |
|
503 | - 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', |
|
504 | - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', |
|
505 | - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', |
|
506 | - 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', |
|
507 | - 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', |
|
508 | - 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php' |
|
509 | - ); |
|
510 | - |
|
511 | - $resultko = 0; |
|
512 | - foreach($filetogenerate as $filetodelete) |
|
513 | - { |
|
514 | - $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); |
|
515 | - if (! $resulttmp) $resultko++; |
|
516 | - } |
|
517 | - |
|
518 | - if ($resultko == 0) |
|
519 | - { |
|
520 | - setEventMessages($langs->trans("FilesDeleted"), null); |
|
521 | - } |
|
522 | - else |
|
523 | - { |
|
524 | - setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); |
|
529 | - //exit; |
|
530 | - $action = ''; |
|
531 | - $tabobj = 'deleteobject'; |
|
479 | + if (preg_match('/[^a-z0-9]/i', $objectname)) |
|
480 | + { |
|
481 | + $error++; |
|
482 | + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); |
|
483 | + } |
|
484 | + |
|
485 | + if (! $error) |
|
486 | + { |
|
487 | + $modulelowercase=strtolower($module); |
|
488 | + $objectlowercase=strtolower($objectname); |
|
489 | + |
|
490 | + // Dir for module |
|
491 | + $dir = $dirins.'/'.$modulelowercase; |
|
492 | + |
|
493 | + // Delete some files |
|
494 | + $filetogenerate = array( |
|
495 | + 'myobject_card.php'=>strtolower($objectname).'_card.php', |
|
496 | + 'myobject_note.php'=>strtolower($objectname).'_note.php', |
|
497 | + 'myobject_document.php'=>strtolower($objectname).'_document.php', |
|
498 | + 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', |
|
499 | + 'myobject_list.php'=>strtolower($objectname).'_list.php', |
|
500 | + 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', |
|
501 | + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', |
|
502 | + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', |
|
503 | + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', |
|
504 | + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', |
|
505 | + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', |
|
506 | + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', |
|
507 | + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', |
|
508 | + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php' |
|
509 | + ); |
|
510 | + |
|
511 | + $resultko = 0; |
|
512 | + foreach($filetogenerate as $filetodelete) |
|
513 | + { |
|
514 | + $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); |
|
515 | + if (! $resulttmp) $resultko++; |
|
516 | + } |
|
517 | + |
|
518 | + if ($resultko == 0) |
|
519 | + { |
|
520 | + setEventMessages($langs->trans("FilesDeleted"), null); |
|
521 | + } |
|
522 | + else |
|
523 | + { |
|
524 | + setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); |
|
529 | + //exit; |
|
530 | + $action = ''; |
|
531 | + $tabobj = 'deleteobject'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | if ($dirins && $action == 'generatepackage') |
536 | 536 | { |
537 | - $modulelowercase=strtolower($module); |
|
538 | - |
|
539 | - // Dir for module |
|
540 | - $dir = $dirins.'/'.$modulelowercase; |
|
541 | - // Zip file to build |
|
542 | - $FILENAMEZIP=''; |
|
543 | - |
|
544 | - // Load module |
|
545 | - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
546 | - $class='mod'.$module; |
|
547 | - |
|
548 | - if (class_exists($class)) |
|
549 | - { |
|
550 | - try { |
|
551 | - $moduleobj = new $class($db); |
|
552 | - } |
|
553 | - catch(Exception $e) |
|
554 | - { |
|
555 | - $error++; |
|
556 | - dol_print_error($e->getMessage()); |
|
557 | - } |
|
558 | - } |
|
559 | - else |
|
560 | - { |
|
561 | - $error++; |
|
562 | - $langs->load("errors"); |
|
563 | - dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); |
|
564 | - exit; |
|
565 | - } |
|
566 | - |
|
567 | - $arrayversion=explode('.',$moduleobj->version,3); |
|
568 | - if (count($arrayversion)) |
|
569 | - { |
|
570 | - $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; |
|
571 | - |
|
572 | - $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; |
|
573 | - $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; |
|
537 | + $modulelowercase=strtolower($module); |
|
538 | + |
|
539 | + // Dir for module |
|
540 | + $dir = $dirins.'/'.$modulelowercase; |
|
541 | + // Zip file to build |
|
542 | + $FILENAMEZIP=''; |
|
543 | + |
|
544 | + // Load module |
|
545 | + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
546 | + $class='mod'.$module; |
|
547 | + |
|
548 | + if (class_exists($class)) |
|
549 | + { |
|
550 | + try { |
|
551 | + $moduleobj = new $class($db); |
|
552 | + } |
|
553 | + catch(Exception $e) |
|
554 | + { |
|
555 | + $error++; |
|
556 | + dol_print_error($e->getMessage()); |
|
557 | + } |
|
558 | + } |
|
559 | + else |
|
560 | + { |
|
561 | + $error++; |
|
562 | + $langs->load("errors"); |
|
563 | + dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); |
|
564 | + exit; |
|
565 | + } |
|
566 | + |
|
567 | + $arrayversion=explode('.',$moduleobj->version,3); |
|
568 | + if (count($arrayversion)) |
|
569 | + { |
|
570 | + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; |
|
571 | + |
|
572 | + $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; |
|
573 | + $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; |
|
574 | 574 | if ($dirofmodule) |
575 | 575 | { |
576 | - if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); |
|
577 | - $result = dol_compress_dir($dir, $outputfilezip, 'zip'); |
|
576 | + if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); |
|
577 | + $result = dol_compress_dir($dir, $outputfilezip, 'zip'); |
|
578 | 578 | } |
579 | 579 | else |
580 | 580 | { |
581 | 581 | $result = -1; |
582 | 582 | } |
583 | 583 | |
584 | - if ($result > 0) |
|
585 | - { |
|
586 | - setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); |
|
587 | - } |
|
588 | - else |
|
589 | - { |
|
590 | - $error++; |
|
591 | - $langs->load("errors"); |
|
592 | - setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors'); |
|
593 | - } |
|
594 | - } |
|
595 | - else |
|
596 | - { |
|
597 | - $error++; |
|
598 | - $langs->load("errors"); |
|
599 | - setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors'); |
|
600 | - } |
|
584 | + if ($result > 0) |
|
585 | + { |
|
586 | + setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); |
|
587 | + } |
|
588 | + else |
|
589 | + { |
|
590 | + $error++; |
|
591 | + $langs->load("errors"); |
|
592 | + setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors'); |
|
593 | + } |
|
594 | + } |
|
595 | + else |
|
596 | + { |
|
597 | + $error++; |
|
598 | + $langs->load("errors"); |
|
599 | + setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors'); |
|
600 | + } |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($dirins && $action == 'generatedoc') |
@@ -673,40 +673,40 @@ discard block |
||
673 | 673 | // Save file |
674 | 674 | if ($action == 'savefile' && empty($cancel)) |
675 | 675 | { |
676 | - $relofcustom = basename($dirins); |
|
677 | - |
|
678 | - if ($relofcustom) |
|
679 | - { |
|
680 | - // Check that relative path ($file) start with name 'custom' |
|
681 | - if (! preg_match('/^'.$relofcustom.'/', $file)) $file=$relofcustom.'/'.$file; |
|
682 | - |
|
683 | - $pathoffile=dol_buildpath($file, 0); |
|
684 | - $pathoffilebackup=dol_buildpath($file.'.back', 0); |
|
685 | - |
|
686 | - // Save old version |
|
687 | - if (dol_is_file($pathoffile)) |
|
688 | - { |
|
689 | - dol_copy($pathoffile, $pathoffilebackup, 0, 1); |
|
690 | - } |
|
691 | - |
|
692 | - $content = GETPOST('editfilecontent','none'); |
|
693 | - |
|
694 | - // Save file on disk |
|
695 | - if ($content) |
|
696 | - { |
|
697 | - dol_delete_file($pathoffile); |
|
698 | - file_put_contents($pathoffile, $content); |
|
699 | - @chmod($pathoffile, octdec($newmask)); |
|
700 | - |
|
701 | - setEventMessages($langs->trans("FileSaved"), null); |
|
702 | - } |
|
703 | - else |
|
704 | - { |
|
676 | + $relofcustom = basename($dirins); |
|
677 | + |
|
678 | + if ($relofcustom) |
|
679 | + { |
|
680 | + // Check that relative path ($file) start with name 'custom' |
|
681 | + if (! preg_match('/^'.$relofcustom.'/', $file)) $file=$relofcustom.'/'.$file; |
|
682 | + |
|
683 | + $pathoffile=dol_buildpath($file, 0); |
|
684 | + $pathoffilebackup=dol_buildpath($file.'.back', 0); |
|
685 | + |
|
686 | + // Save old version |
|
687 | + if (dol_is_file($pathoffile)) |
|
688 | + { |
|
689 | + dol_copy($pathoffile, $pathoffilebackup, 0, 1); |
|
690 | + } |
|
691 | + |
|
692 | + $content = GETPOST('editfilecontent','none'); |
|
693 | + |
|
694 | + // Save file on disk |
|
695 | + if ($content) |
|
696 | + { |
|
697 | + dol_delete_file($pathoffile); |
|
698 | + file_put_contents($pathoffile, $content); |
|
699 | + @chmod($pathoffile, octdec($newmask)); |
|
700 | + |
|
701 | + setEventMessages($langs->trans("FileSaved"), null); |
|
702 | + } |
|
703 | + else |
|
704 | + { |
|
705 | 705 | setEventMessages($langs->trans("ContentCantBeEmpty"), null, 'errors'); |
706 | - //$action='editfile'; |
|
707 | - $error++; |
|
708 | - } |
|
709 | - } |
|
706 | + //$action='editfile'; |
|
707 | + $error++; |
|
708 | + } |
|
709 | + } |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | // Enable module |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | // Set dir where external modules are installed |
771 | 771 | if (! dol_is_dir($dirins)) |
772 | 772 | { |
773 | - dol_mkdir($dirins); |
|
773 | + dol_mkdir($dirins); |
|
774 | 774 | } |
775 | 775 | $dirins_ok=(dol_is_dir($dirins)); |
776 | 776 | |
@@ -827,30 +827,30 @@ discard block |
||
827 | 827 | $message=''; |
828 | 828 | if (! $dirins) |
829 | 829 | { |
830 | - $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); |
|
831 | - $allowfromweb=-1; |
|
830 | + $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); |
|
831 | + $allowfromweb=-1; |
|
832 | 832 | } |
833 | 833 | else |
834 | 834 | { |
835 | - if ($dirins_ok) |
|
836 | - { |
|
837 | - if (! is_writable(dol_osencode($dirins))) |
|
838 | - { |
|
839 | - $langs->load("errors"); |
|
840 | - $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); |
|
841 | - $allowfromweb=0; |
|
842 | - } |
|
843 | - } |
|
844 | - else |
|
845 | - { |
|
846 | - |
|
847 | - $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); |
|
848 | - $allowfromweb=0; |
|
849 | - } |
|
835 | + if ($dirins_ok) |
|
836 | + { |
|
837 | + if (! is_writable(dol_osencode($dirins))) |
|
838 | + { |
|
839 | + $langs->load("errors"); |
|
840 | + $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); |
|
841 | + $allowfromweb=0; |
|
842 | + } |
|
843 | + } |
|
844 | + else |
|
845 | + { |
|
846 | + |
|
847 | + $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); |
|
848 | + $allowfromweb=0; |
|
849 | + } |
|
850 | 850 | } |
851 | 851 | if ($message) |
852 | 852 | { |
853 | - print $message; |
|
853 | + print $message; |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>'; |
@@ -865,27 +865,27 @@ discard block |
||
865 | 865 | { |
866 | 866 | $modulelowercase=strtolower($module); |
867 | 867 | |
868 | - // Load module |
|
869 | - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
870 | - $class='mod'.$module; |
|
871 | - |
|
872 | - if (class_exists($class)) |
|
873 | - { |
|
874 | - try { |
|
875 | - $moduleobj = new $class($db); |
|
876 | - } |
|
877 | - catch(Exception $e) |
|
878 | - { |
|
879 | - $error++; |
|
880 | - print $e->getMessage(); |
|
881 | - } |
|
882 | - } |
|
883 | - else |
|
884 | - { |
|
885 | - if (empty($forceddirread)) $error++; |
|
886 | - $langs->load("errors"); |
|
887 | - print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; |
|
888 | - } |
|
868 | + // Load module |
|
869 | + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
870 | + $class='mod'.$module; |
|
871 | + |
|
872 | + if (class_exists($class)) |
|
873 | + { |
|
874 | + try { |
|
875 | + $moduleobj = new $class($db); |
|
876 | + } |
|
877 | + catch(Exception $e) |
|
878 | + { |
|
879 | + $error++; |
|
880 | + print $e->getMessage(); |
|
881 | + } |
|
882 | + } |
|
883 | + else |
|
884 | + { |
|
885 | + if (empty($forceddirread)) $error++; |
|
886 | + $langs->load("errors"); |
|
887 | + print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; |
|
888 | + } |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | print '<br>'; |
@@ -902,10 +902,10 @@ discard block |
||
902 | 902 | |
903 | 903 | foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) |
904 | 904 | { |
905 | - $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:''); |
|
906 | - $head[$h][1] = $tmpmodulewithcase; |
|
907 | - $head[$h][2] = $tmpmodulewithcase; |
|
908 | - $h++; |
|
905 | + $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:''); |
|
906 | + $head[$h][1] = $tmpmodulewithcase; |
|
907 | + $head[$h][2] = $tmpmodulewithcase; |
|
908 | + $h++; |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | $head[$h][0] = $_SERVER["PHP_SELF"].'?module=deletemodule'; |
@@ -918,671 +918,671 @@ discard block |
||
918 | 918 | |
919 | 919 | if ($module == 'initmodule') |
920 | 920 | { |
921 | - // New module |
|
922 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
923 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
924 | - print '<input type="hidden" name="action" value="initmodule">'; |
|
925 | - print '<input type="hidden" name="module" value="initmodule">'; |
|
921 | + // New module |
|
922 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
923 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
924 | + print '<input type="hidden" name="action" value="initmodule">'; |
|
925 | + print '<input type="hidden" name="module" value="initmodule">'; |
|
926 | 926 | |
927 | - print $langs->trans("EnterNameOfModuleDesc").'<br><br>'; |
|
927 | + print $langs->trans("EnterNameOfModuleDesc").'<br><br>'; |
|
928 | 928 | |
929 | - print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">'; |
|
930 | - print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
931 | - print '</form>'; |
|
929 | + print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">'; |
|
930 | + print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
931 | + print '</form>'; |
|
932 | 932 | } |
933 | 933 | elseif ($module == 'deletemodule') |
934 | 934 | { |
935 | - print '<form name="delete">'; |
|
936 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
937 | - print '<input type="hidden" name="action" value="confirm_delete">'; |
|
938 | - print '<input type="hidden" name="module" value="deletemodule">'; |
|
935 | + print '<form name="delete">'; |
|
936 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
937 | + print '<input type="hidden" name="action" value="confirm_delete">'; |
|
938 | + print '<input type="hidden" name="module" value="deletemodule">'; |
|
939 | 939 | |
940 | - print $langs->trans("EnterNameOfModuleToDeleteDesc").'<br><br>'; |
|
940 | + print $langs->trans("EnterNameOfModuleToDeleteDesc").'<br><br>'; |
|
941 | 941 | |
942 | - print '<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'" value="">'; |
|
943 | - print '<input type="submit" class="buttonDelete" value="'.$langs->trans("Delete").'"'.($dirins?'':' disabled="disabled"').'>'; |
|
944 | - print '</form>'; |
|
942 | + print '<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'" value="">'; |
|
943 | + print '<input type="submit" class="buttonDelete" value="'.$langs->trans("Delete").'"'.($dirins?'':' disabled="disabled"').'>'; |
|
944 | + print '</form>'; |
|
945 | 945 | } |
946 | 946 | elseif (! empty($module)) |
947 | 947 | { |
948 | 948 | // Tabs for module |
949 | - if (! $error) |
|
950 | - { |
|
951 | - $head2 = array(); |
|
952 | - $h=0; |
|
953 | - |
|
954 | - $modulelowercase=strtolower($module); |
|
955 | - $const_name = 'MAIN_MODULE_'.strtoupper($module); |
|
956 | - |
|
957 | - $param=''; |
|
958 | - if ($tab) $param.= '&tab='.$tab; |
|
959 | - if ($module) $param.='&module='.$module; |
|
960 | - if ($tabobj) $param.='&tabobj='.$tabobj; |
|
961 | - |
|
962 | - $urltomodulesetup='<a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($module).'">'.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").'</a>'; |
|
963 | - $linktoenabledisable=''; |
|
964 | - if (! empty($conf->global->$const_name)) // If module is already activated |
|
965 | - { |
|
966 | - $linktoenabledisable.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=reset&value=mod' . $module . $param . '">'; |
|
967 | - $linktoenabledisable.=img_picto($langs->trans("Activated"),'switch_on'); |
|
968 | - $linktoenabledisable.='</a>'; |
|
969 | - } |
|
970 | - else |
|
971 | - { |
|
972 | - $linktoenabledisable.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=set&value=mod' . $module . $param . '">'; |
|
973 | - $linktoenabledisable.=img_picto($langs->trans("Disabled"),'switch_off'); |
|
974 | - $linktoenabledisable.="</a>\n"; |
|
975 | - } |
|
976 | - if (! empty($conf->$modulelowercase->enabled)) |
|
977 | - { |
|
978 | - $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); |
|
979 | - } |
|
980 | - else |
|
981 | - { |
|
982 | - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); |
|
983 | - } |
|
984 | - |
|
985 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); |
|
986 | - $head2[$h][1] = $langs->trans("Description"); |
|
987 | - $head2[$h][2] = 'description'; |
|
988 | - $h++; |
|
989 | - |
|
990 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:''); |
|
991 | - $head2[$h][1] = $langs->trans("Specifications"); |
|
992 | - $head2[$h][2] = 'specifications'; |
|
993 | - $h++; |
|
994 | - |
|
995 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); |
|
996 | - $head2[$h][1] = $langs->trans("Languages"); |
|
997 | - $head2[$h][2] = 'languages'; |
|
998 | - $h++; |
|
999 | - |
|
1000 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1001 | - $head2[$h][1] = $langs->trans("Objects"); |
|
1002 | - $head2[$h][2] = 'objects'; |
|
1003 | - $h++; |
|
1004 | - |
|
1005 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1006 | - $head2[$h][1] = $langs->trans("Menus"); |
|
1007 | - $head2[$h][2] = 'menus'; |
|
1008 | - $h++; |
|
1009 | - |
|
1010 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1011 | - $head2[$h][1] = $langs->trans("Permissions"); |
|
1012 | - $head2[$h][2] = 'permissions'; |
|
1013 | - $h++; |
|
1014 | - |
|
1015 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1016 | - $head2[$h][1] = $langs->trans("Hooks"); |
|
1017 | - $head2[$h][2] = 'hooks'; |
|
1018 | - $h++; |
|
1019 | - |
|
1020 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1021 | - $head2[$h][1] = $langs->trans("Triggers"); |
|
1022 | - $head2[$h][2] = 'triggers'; |
|
1023 | - $h++; |
|
1024 | - |
|
1025 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1026 | - $head2[$h][1] = $langs->trans("Widgets"); |
|
1027 | - $head2[$h][2] = 'widgets'; |
|
1028 | - $h++; |
|
1029 | - |
|
1030 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1031 | - $head2[$h][1] = $langs->trans("CronList"); |
|
1032 | - $head2[$h][2] = 'cron'; |
|
1033 | - $h++; |
|
1034 | - |
|
1035 | - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1036 | - $head2[$h][1] = $langs->trans("BuildPackage"); |
|
1037 | - $head2[$h][2] = 'buildpackage'; |
|
1038 | - $h++; |
|
1039 | - |
|
1040 | - print $modulestatusinfo; |
|
1041 | - print ' '.$linktoenabledisable; |
|
1042 | - print '<br><br>'; |
|
1043 | - |
|
1044 | - if ($tab == 'description') |
|
1045 | - { |
|
1046 | - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1047 | - $pathtofilereadme = $modulelowercase.'/README.md'; |
|
1048 | - $pathtochangelog = $modulelowercase.'/ChangeLog.md'; |
|
1049 | - |
|
1050 | - if ($action != 'editfile' || empty($file)) |
|
1051 | - { |
|
1052 | - dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 |
|
1053 | - |
|
1054 | - print $langs->trans("ModuleBuilderDesc".$tab).'<br><br>'; |
|
1055 | - |
|
1056 | - print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1057 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1058 | - print '<br>'; |
|
1059 | - |
|
1060 | - print '<span class="fa fa-file"></span> '.$langs->trans("ReadmeFile").' : <strong>'.$pathtofilereadme.'</strong>'; |
|
1061 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=markdown&file='.urlencode($pathtofilereadme).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1062 | - print '<br>'; |
|
1063 | - |
|
1064 | - print '<span class="fa fa-file"></span> '.$langs->trans("ChangeLog").' : <strong>'.$pathtochangelog.'</strong>'; |
|
1065 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=markdown&file='.urlencode($pathtochangelog).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1066 | - print '<br>'; |
|
1067 | - |
|
1068 | - print '<br>'; |
|
1069 | - print '<br>'; |
|
1070 | - |
|
1071 | - print_fiche_titre($langs->trans("DescriptorFile")); |
|
1072 | - |
|
1073 | - if (! empty($moduleobj)) |
|
1074 | - { |
|
1075 | - print '<div class="underbanner clearboth"></div>'; |
|
1076 | - print '<div class="fichecenter">'; |
|
1077 | - |
|
1078 | - print '<table class="border centpercent">'; |
|
1079 | - print '<tr class="liste_titre"><td class="titlefield">'; |
|
1080 | - print $langs->trans("Parameter"); |
|
1081 | - print '</td><td>'; |
|
1082 | - print $langs->trans("Value"); |
|
1083 | - print '</td></tr>'; |
|
1084 | - |
|
1085 | - print '<tr><td>'; |
|
1086 | - print $langs->trans("Numero"); |
|
1087 | - print '</td><td>'; |
|
1088 | - print $moduleobj->numero; |
|
1089 | - print ' (<a href="'.DOL_URL_ROOT.'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info" target="_blank">'.$langs->trans("SeeIDsInUse").'</a>'; |
|
1090 | - print ' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank">'.$langs->trans("SeeReservedIDsRangeHere").'</a>)'; |
|
1091 | - print '</td></tr>'; |
|
1092 | - |
|
1093 | - print '<tr><td>'; |
|
1094 | - print $langs->trans("Name"); |
|
1095 | - print '</td><td>'; |
|
1096 | - print $moduleobj->getName(); |
|
1097 | - print '</td></tr>'; |
|
1098 | - |
|
1099 | - print '<tr><td>'; |
|
1100 | - print $langs->trans("Version"); |
|
1101 | - print '</td><td>'; |
|
1102 | - print $moduleobj->getVersion(); |
|
1103 | - print '</td></tr>'; |
|
1104 | - |
|
1105 | - print '<tr><td>'; |
|
1106 | - print $langs->trans("Family"); |
|
1107 | - //print "<br>'crm','financial','hr','projects','products','ecm','technic','interface','other'"; |
|
1108 | - print '</td><td>'; |
|
1109 | - print $moduleobj->family; |
|
1110 | - print '</td></tr>'; |
|
1111 | - |
|
1112 | - print '<tr><td>'; |
|
1113 | - print $langs->trans("EditorName"); |
|
1114 | - print '</td><td>'; |
|
1115 | - print $moduleobj->editor_name; |
|
1116 | - print '</td></tr>'; |
|
1117 | - |
|
1118 | - print '<tr><td>'; |
|
1119 | - print $langs->trans("EditorUrl"); |
|
1120 | - print '</td><td>'; |
|
1121 | - print $moduleobj->editor_url; |
|
1122 | - print '</td></tr>'; |
|
1123 | - |
|
1124 | - print '<tr><td>'; |
|
1125 | - print $langs->trans("Description"); |
|
1126 | - print '</td><td>'; |
|
1127 | - print $moduleobj->getDesc(); |
|
1128 | - print '</td></tr>'; |
|
1129 | - |
|
1130 | - print '</table>'; |
|
1131 | - |
|
1132 | - print '<br><br>'; |
|
1133 | - |
|
1134 | - // Readme file |
|
1135 | - print_fiche_titre($langs->trans("ReadmeFile")); |
|
949 | + if (! $error) |
|
950 | + { |
|
951 | + $head2 = array(); |
|
952 | + $h=0; |
|
1136 | 953 | |
1137 | - print '<div class="underbanner clearboth"></div>'; |
|
1138 | - print '<div class="fichecenter">'; |
|
954 | + $modulelowercase=strtolower($module); |
|
955 | + $const_name = 'MAIN_MODULE_'.strtoupper($module); |
|
1139 | 956 | |
1140 | - print $moduleobj->getDescLong(); |
|
957 | + $param=''; |
|
958 | + if ($tab) $param.= '&tab='.$tab; |
|
959 | + if ($module) $param.='&module='.$module; |
|
960 | + if ($tabobj) $param.='&tabobj='.$tabobj; |
|
1141 | 961 | |
1142 | - print '<br><br>'; |
|
962 | + $urltomodulesetup='<a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($module).'">'.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").'</a>'; |
|
963 | + $linktoenabledisable=''; |
|
964 | + if (! empty($conf->global->$const_name)) // If module is already activated |
|
965 | + { |
|
966 | + $linktoenabledisable.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=reset&value=mod' . $module . $param . '">'; |
|
967 | + $linktoenabledisable.=img_picto($langs->trans("Activated"),'switch_on'); |
|
968 | + $linktoenabledisable.='</a>'; |
|
969 | + } |
|
970 | + else |
|
971 | + { |
|
972 | + $linktoenabledisable.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=set&value=mod' . $module . $param . '">'; |
|
973 | + $linktoenabledisable.=img_picto($langs->trans("Disabled"),'switch_off'); |
|
974 | + $linktoenabledisable.="</a>\n"; |
|
975 | + } |
|
976 | + if (! empty($conf->$modulelowercase->enabled)) |
|
977 | + { |
|
978 | + $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); |
|
979 | + } |
|
980 | + else |
|
981 | + { |
|
982 | + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); |
|
983 | + } |
|
1143 | 984 | |
1144 | - // ChangeLog |
|
1145 | - print_fiche_titre($langs->trans("ChangeLog")); |
|
985 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); |
|
986 | + $head2[$h][1] = $langs->trans("Description"); |
|
987 | + $head2[$h][2] = 'description'; |
|
988 | + $h++; |
|
989 | + |
|
990 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:''); |
|
991 | + $head2[$h][1] = $langs->trans("Specifications"); |
|
992 | + $head2[$h][2] = 'specifications'; |
|
993 | + $h++; |
|
994 | + |
|
995 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); |
|
996 | + $head2[$h][1] = $langs->trans("Languages"); |
|
997 | + $head2[$h][2] = 'languages'; |
|
998 | + $h++; |
|
999 | + |
|
1000 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1001 | + $head2[$h][1] = $langs->trans("Objects"); |
|
1002 | + $head2[$h][2] = 'objects'; |
|
1003 | + $h++; |
|
1004 | + |
|
1005 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1006 | + $head2[$h][1] = $langs->trans("Menus"); |
|
1007 | + $head2[$h][2] = 'menus'; |
|
1008 | + $h++; |
|
1009 | + |
|
1010 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1011 | + $head2[$h][1] = $langs->trans("Permissions"); |
|
1012 | + $head2[$h][2] = 'permissions'; |
|
1013 | + $h++; |
|
1014 | + |
|
1015 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1016 | + $head2[$h][1] = $langs->trans("Hooks"); |
|
1017 | + $head2[$h][2] = 'hooks'; |
|
1018 | + $h++; |
|
1019 | + |
|
1020 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1021 | + $head2[$h][1] = $langs->trans("Triggers"); |
|
1022 | + $head2[$h][2] = 'triggers'; |
|
1023 | + $h++; |
|
1024 | + |
|
1025 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1026 | + $head2[$h][1] = $langs->trans("Widgets"); |
|
1027 | + $head2[$h][2] = 'widgets'; |
|
1028 | + $h++; |
|
1029 | + |
|
1030 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1031 | + $head2[$h][1] = $langs->trans("CronList"); |
|
1032 | + $head2[$h][2] = 'cron'; |
|
1033 | + $h++; |
|
1034 | + |
|
1035 | + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:''); |
|
1036 | + $head2[$h][1] = $langs->trans("BuildPackage"); |
|
1037 | + $head2[$h][2] = 'buildpackage'; |
|
1038 | + $h++; |
|
1039 | + |
|
1040 | + print $modulestatusinfo; |
|
1041 | + print ' '.$linktoenabledisable; |
|
1042 | + print '<br><br>'; |
|
1043 | + |
|
1044 | + if ($tab == 'description') |
|
1045 | + { |
|
1046 | + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1047 | + $pathtofilereadme = $modulelowercase.'/README.md'; |
|
1048 | + $pathtochangelog = $modulelowercase.'/ChangeLog.md'; |
|
1146 | 1049 | |
1147 | - print '<div class="underbanner clearboth"></div>'; |
|
1148 | - print '<div class="fichecenter">'; |
|
1050 | + if ($action != 'editfile' || empty($file)) |
|
1051 | + { |
|
1052 | + dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 |
|
1149 | 1053 | |
1150 | - print $moduleobj->getChangeLog(); |
|
1054 | + print $langs->trans("ModuleBuilderDesc".$tab).'<br><br>'; |
|
1151 | 1055 | |
1152 | - print '</div>'; |
|
1153 | - } |
|
1154 | - else |
|
1155 | - { |
|
1156 | - print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; |
|
1157 | - } |
|
1056 | + print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1057 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1058 | + print '<br>'; |
|
1158 | 1059 | |
1159 | - dol_fiche_end(); |
|
1160 | - } |
|
1161 | - else |
|
1162 | - { |
|
1163 | - $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 |
|
1060 | + print '<span class="fa fa-file"></span> '.$langs->trans("ReadmeFile").' : <strong>'.$pathtofilereadme.'</strong>'; |
|
1061 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=markdown&file='.urlencode($pathtofilereadme).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1062 | + print '<br>'; |
|
1164 | 1063 | |
1165 | - if ($fullpathoffile) |
|
1166 | - { |
|
1167 | - $content = file_get_contents($fullpathoffile); |
|
1168 | - } |
|
1064 | + print '<span class="fa fa-file"></span> '.$langs->trans("ChangeLog").' : <strong>'.$pathtochangelog.'</strong>'; |
|
1065 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=markdown&file='.urlencode($pathtochangelog).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1066 | + print '<br>'; |
|
1169 | 1067 | |
1170 | - // New module |
|
1171 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1172 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1173 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1174 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1175 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1176 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1068 | + print '<br>'; |
|
1069 | + print '<br>'; |
|
1070 | + |
|
1071 | + print_fiche_titre($langs->trans("DescriptorFile")); |
|
1072 | + |
|
1073 | + if (! empty($moduleobj)) |
|
1074 | + { |
|
1075 | + print '<div class="underbanner clearboth"></div>'; |
|
1076 | + print '<div class="fichecenter">'; |
|
1077 | + |
|
1078 | + print '<table class="border centpercent">'; |
|
1079 | + print '<tr class="liste_titre"><td class="titlefield">'; |
|
1080 | + print $langs->trans("Parameter"); |
|
1081 | + print '</td><td>'; |
|
1082 | + print $langs->trans("Value"); |
|
1083 | + print '</td></tr>'; |
|
1084 | + |
|
1085 | + print '<tr><td>'; |
|
1086 | + print $langs->trans("Numero"); |
|
1087 | + print '</td><td>'; |
|
1088 | + print $moduleobj->numero; |
|
1089 | + print ' (<a href="'.DOL_URL_ROOT.'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info" target="_blank">'.$langs->trans("SeeIDsInUse").'</a>'; |
|
1090 | + print ' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank">'.$langs->trans("SeeReservedIDsRangeHere").'</a>)'; |
|
1091 | + print '</td></tr>'; |
|
1092 | + |
|
1093 | + print '<tr><td>'; |
|
1094 | + print $langs->trans("Name"); |
|
1095 | + print '</td><td>'; |
|
1096 | + print $moduleobj->getName(); |
|
1097 | + print '</td></tr>'; |
|
1098 | + |
|
1099 | + print '<tr><td>'; |
|
1100 | + print $langs->trans("Version"); |
|
1101 | + print '</td><td>'; |
|
1102 | + print $moduleobj->getVersion(); |
|
1103 | + print '</td></tr>'; |
|
1104 | + |
|
1105 | + print '<tr><td>'; |
|
1106 | + print $langs->trans("Family"); |
|
1107 | + //print "<br>'crm','financial','hr','projects','products','ecm','technic','interface','other'"; |
|
1108 | + print '</td><td>'; |
|
1109 | + print $moduleobj->family; |
|
1110 | + print '</td></tr>'; |
|
1111 | + |
|
1112 | + print '<tr><td>'; |
|
1113 | + print $langs->trans("EditorName"); |
|
1114 | + print '</td><td>'; |
|
1115 | + print $moduleobj->editor_name; |
|
1116 | + print '</td></tr>'; |
|
1117 | + |
|
1118 | + print '<tr><td>'; |
|
1119 | + print $langs->trans("EditorUrl"); |
|
1120 | + print '</td><td>'; |
|
1121 | + print $moduleobj->editor_url; |
|
1122 | + print '</td></tr>'; |
|
1123 | + |
|
1124 | + print '<tr><td>'; |
|
1125 | + print $langs->trans("Description"); |
|
1126 | + print '</td><td>'; |
|
1127 | + print $moduleobj->getDesc(); |
|
1128 | + print '</td></tr>'; |
|
1129 | + |
|
1130 | + print '</table>'; |
|
1131 | + |
|
1132 | + print '<br><br>'; |
|
1133 | + |
|
1134 | + // Readme file |
|
1135 | + print_fiche_titre($langs->trans("ReadmeFile")); |
|
1136 | + |
|
1137 | + print '<div class="underbanner clearboth"></div>'; |
|
1138 | + print '<div class="fichecenter">'; |
|
1139 | + |
|
1140 | + print $moduleobj->getDescLong(); |
|
1141 | + |
|
1142 | + print '<br><br>'; |
|
1143 | + |
|
1144 | + // ChangeLog |
|
1145 | + print_fiche_titre($langs->trans("ChangeLog")); |
|
1146 | + |
|
1147 | + print '<div class="underbanner clearboth"></div>'; |
|
1148 | + print '<div class="fichecenter">'; |
|
1149 | + |
|
1150 | + print $moduleobj->getChangeLog(); |
|
1151 | + |
|
1152 | + print '</div>'; |
|
1153 | + } |
|
1154 | + else |
|
1155 | + { |
|
1156 | + print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; |
|
1157 | + } |
|
1177 | 1158 | |
1178 | - dol_fiche_head($head2, $tab, '', -1, ''); |
|
1159 | + dol_fiche_end(); |
|
1160 | + } |
|
1161 | + else |
|
1162 | + { |
|
1163 | + $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 |
|
1179 | 1164 | |
1180 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); |
|
1181 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1165 | + if ($fullpathoffile) |
|
1166 | + { |
|
1167 | + $content = file_get_contents($fullpathoffile); |
|
1168 | + } |
|
1182 | 1169 | |
1183 | - dol_fiche_end(); |
|
1170 | + // New module |
|
1171 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1172 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1173 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1174 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1175 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1176 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1184 | 1177 | |
1185 | - print '<center>'; |
|
1186 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1187 | - print ' '; |
|
1188 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1189 | - print '</center>'; |
|
1178 | + dol_fiche_head($head2, $tab, '', -1, ''); |
|
1190 | 1179 | |
1191 | - print '</form>'; |
|
1192 | - } |
|
1193 | - } |
|
1194 | - else |
|
1195 | - { |
|
1196 | - dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 |
|
1197 | - } |
|
1180 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); |
|
1181 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1182 | + |
|
1183 | + dol_fiche_end(); |
|
1184 | + |
|
1185 | + print '<center>'; |
|
1186 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1187 | + print ' '; |
|
1188 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1189 | + print '</center>'; |
|
1190 | + |
|
1191 | + print '</form>'; |
|
1192 | + } |
|
1193 | + } |
|
1194 | + else |
|
1195 | + { |
|
1196 | + dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 |
|
1197 | + } |
|
1198 | 1198 | |
1199 | 1199 | |
1200 | - if ($tab == 'specifications') |
|
1201 | - { |
|
1202 | - if ($action != 'editfile' || empty($file)) |
|
1203 | - { |
|
1204 | - print $langs->trans("SpecDefDesc").'<br>'; |
|
1205 | - print '<br>'; |
|
1200 | + if ($tab == 'specifications') |
|
1201 | + { |
|
1202 | + if ($action != 'editfile' || empty($file)) |
|
1203 | + { |
|
1204 | + print $langs->trans("SpecDefDesc").'<br>'; |
|
1205 | + print '<br>'; |
|
1206 | 1206 | |
1207 | - $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); |
|
1207 | + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); |
|
1208 | 1208 | |
1209 | - foreach ($specs as $spec) |
|
1210 | - { |
|
1211 | - $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; |
|
1209 | + foreach ($specs as $spec) |
|
1210 | + { |
|
1211 | + $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; |
|
1212 | 1212 | $format='asciidoc'; |
1213 | 1213 | if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; |
1214 | - print '<span class="fa fa-file"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1215 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1216 | - print '<br>'; |
|
1217 | - } |
|
1218 | - } |
|
1219 | - else |
|
1220 | - { |
|
1221 | - // Use MD or asciidoc |
|
1222 | - |
|
1223 | - //print $langs->trans("UseAsciiDocFormat").'<br>'; |
|
1224 | - |
|
1225 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1226 | - |
|
1227 | - $content = file_get_contents($fullpathoffile); |
|
1228 | - |
|
1229 | - // New module |
|
1230 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1231 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1232 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1233 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1234 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1235 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1236 | - |
|
1237 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1238 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1239 | - print '<br>'; |
|
1240 | - print '<center>'; |
|
1241 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1242 | - print ' '; |
|
1243 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1244 | - print '</center>'; |
|
1245 | - |
|
1246 | - print '</form>'; |
|
1247 | - } |
|
1248 | - } |
|
1249 | - |
|
1250 | - if ($tab == 'languages') |
|
1251 | - { |
|
1252 | - if ($action != 'editfile' || empty($file)) |
|
1253 | - { |
|
1254 | - print $langs->trans("LanguageDefDesc").'<br>'; |
|
1255 | - print '<br>'; |
|
1256 | - |
|
1257 | - |
|
1258 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
1259 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1260 | - print '<input type="hidden" name="action" value="addlanguage">'; |
|
1261 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1262 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1263 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1264 | - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 1); |
|
1265 | - print '<input type="submit" name="addlanguage" class="button" value="'.dol_escape_htmltag($langs->trans("AddLanguageFile")).'"><br>'; |
|
1266 | - print '</form>'; |
|
1214 | + print '<span class="fa fa-file"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1215 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1216 | + print '<br>'; |
|
1217 | + } |
|
1218 | + } |
|
1219 | + else |
|
1220 | + { |
|
1221 | + // Use MD or asciidoc |
|
1267 | 1222 | |
1268 | - print '<br>'; |
|
1269 | - print '<br>'; |
|
1223 | + //print $langs->trans("UseAsciiDocFormat").'<br>'; |
|
1270 | 1224 | |
1271 | - $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); |
|
1225 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1272 | 1226 | |
1273 | - foreach ($langfiles as $langfile) |
|
1274 | - { |
|
1275 | - $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; |
|
1276 | - print '<span class="fa fa-file"></span> '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : <strong>'.$pathtofile.'</strong>'; |
|
1277 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1278 | - print '<br>'; |
|
1279 | - } |
|
1280 | - } |
|
1281 | - else |
|
1282 | - { |
|
1283 | - // Edit text language file |
|
1284 | - |
|
1285 | - //print $langs->trans("UseAsciiDocFormat").'<br>'; |
|
1286 | - |
|
1287 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1288 | - |
|
1289 | - $content = file_get_contents($fullpathoffile); |
|
1290 | - |
|
1291 | - // New module |
|
1292 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1293 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1294 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1295 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1296 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1297 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1298 | - |
|
1299 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1300 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text')); |
|
1301 | - print '<br>'; |
|
1302 | - print '<center>'; |
|
1303 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1304 | - print ' '; |
|
1305 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1306 | - print '</center>'; |
|
1227 | + $content = file_get_contents($fullpathoffile); |
|
1307 | 1228 | |
1308 | - print '</form>'; |
|
1309 | - } |
|
1310 | - } |
|
1311 | - |
|
1312 | - if ($tab == 'objects') |
|
1313 | - { |
|
1314 | - $head3 = array(); |
|
1315 | - $h=0; |
|
1316 | - |
|
1317 | - // Dir for module |
|
1318 | - $dir = $dirread.'/'.$modulelowercase.'/class'; |
|
1319 | - |
|
1320 | - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; |
|
1321 | - $head3[$h][1] = $langs->trans("NewObject"); |
|
1322 | - $head3[$h][2] = 'newobject'; |
|
1323 | - $h++; |
|
1324 | - |
|
1325 | - // Scan for object class files |
|
1326 | - $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); |
|
1327 | - |
|
1328 | - $firstobjectname=''; |
|
1329 | - foreach($listofobject as $fileobj) |
|
1330 | - { |
|
1331 | - if (preg_match('/^api_/',$fileobj['name'])) continue; |
|
1332 | - if (preg_match('/^actions_/',$fileobj['name'])) continue; |
|
1333 | - |
|
1334 | - $tmpcontent=file_get_contents($fileobj['fullname']); |
|
1335 | - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) |
|
1336 | - { |
|
1337 | - //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); |
|
1338 | - $objectname = $reg[1]; |
|
1339 | - if (empty($firstobjectname)) $firstobjectname = $objectname; |
|
1340 | - |
|
1341 | - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; |
|
1342 | - $head3[$h][1] = $objectname; |
|
1343 | - $head3[$h][2] = $objectname; |
|
1344 | - $h++; |
|
1345 | - } |
|
1346 | - } |
|
1347 | - |
|
1348 | - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; |
|
1349 | - $head3[$h][1] = $langs->trans("DangerZone"); |
|
1350 | - $head3[$h][2] = 'deleteobject'; |
|
1351 | - $h++; |
|
1352 | - |
|
1353 | - // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. |
|
1354 | - if ($tabobj == 'newobjectifnoobj') |
|
1355 | - { |
|
1356 | - if ($firstobjectname) $tabobj=$firstobjectname; |
|
1357 | - else $tabobj = 'newobject'; |
|
1358 | - } |
|
1359 | - |
|
1360 | - dol_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 |
|
1361 | - |
|
1362 | - if ($tabobj == 'newobject') |
|
1363 | - { |
|
1364 | - // New object tab |
|
1365 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1366 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1367 | - print '<input type="hidden" name="action" value="initobject">'; |
|
1368 | - print '<input type="hidden" name="tab" value="objects">'; |
|
1369 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1370 | - |
|
1371 | - print $langs->trans("EnterNameOfObjectDesc").'<br><br>'; |
|
1372 | - |
|
1373 | - print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">'; |
|
1374 | - print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
1375 | - print '</form>'; |
|
1376 | - } |
|
1377 | - elseif ($tabobj == 'deleteobject') |
|
1378 | - { |
|
1379 | - // Delete object tab |
|
1380 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1381 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1382 | - print '<input type="hidden" name="action" value="confirm_deleteobject">'; |
|
1383 | - print '<input type="hidden" name="tab" value="objects">'; |
|
1384 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1385 | - |
|
1386 | - print $langs->trans("EnterNameOfObjectToDeleteDesc").'<br><br>'; |
|
1387 | - |
|
1388 | - print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">'; |
|
1389 | - print '<input type="submit" class="buttonDelete" name="delete" value="'.dol_escape_htmltag($langs->trans("Delete")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
1390 | - print '</form>'; |
|
1391 | - } |
|
1392 | - else |
|
1393 | - { // tabobj = module |
|
1394 | - if ($action == 'deleteproperty') |
|
1395 | - { |
|
1396 | - $formconfirm = $form->formconfirm( |
|
1397 | - $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey','alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), |
|
1398 | - $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey','alpha')), 'confirm_deleteproperty', '', 0, 1 |
|
1399 | - ); |
|
1400 | - |
|
1401 | - // Print form confirm |
|
1402 | - print $formconfirm; |
|
1403 | - } |
|
1404 | - |
|
1405 | - if ($action != 'editfile' || empty($file)) |
|
1406 | - { |
|
1407 | - try { |
|
1408 | - $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; |
|
1409 | - $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; |
|
1410 | - $pathtoagenda = strtolower($module).'/'.strtolower($tabobj).'_agenda.php'; |
|
1411 | - $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; |
|
1412 | - $pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php'; |
|
1413 | - $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; |
|
1414 | - $pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php'; |
|
1415 | - $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; |
|
1416 | - $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; |
|
1417 | - $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; |
|
1418 | - $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; |
|
1419 | - $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; |
|
1420 | - $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; |
|
1421 | - |
|
1422 | - $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); |
|
1423 | - $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); |
|
1424 | - $realpathtoagenda = dol_buildpath($pathtoagenda, 0, 1); |
|
1425 | - $realpathtocard = dol_buildpath($pathtocard, 0, 1); |
|
1426 | - $realpathtodocument = dol_buildpath($pathtodocument, 0, 1); |
|
1427 | - $realpathtolist = dol_buildpath($pathtolist, 0, 1); |
|
1428 | - $realpathtonote = dol_buildpath($pathtonote, 0, 1); |
|
1429 | - $realpathtophpunit = dol_buildpath($pathtophpunit, 0, 1); |
|
1430 | - $realpathtosql = dol_buildpath($pathtosql, 0, 1); |
|
1431 | - $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); |
|
1432 | - $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); |
|
1433 | - $realpathtolib = dol_buildpath($pathtolib, 0, 1); |
|
1434 | - $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); |
|
1435 | - |
|
1436 | - print '<div class="fichehalfleft">'; |
|
1437 | - print '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.($realpathtoclass?'':'<strike>').$pathtoclass.($realpathtoclass?'':'</strike>').'</strong>'; |
|
1438 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1439 | - print '<br>'; |
|
1440 | - print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.($realpathtoapi?'':'<strike>').$pathtoapi.($realpathtoapi?'':'</strike>').'</strong>'; |
|
1441 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1442 | - print ' <a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>'; |
|
1443 | - print '<br>'; |
|
1444 | - print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.($realpathtophpunit?'':'<strike>').$pathtophpunit.($realpathtophpunit?'':'</strike>').'</strong>'; |
|
1445 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1446 | - print '<br>'; |
|
1447 | - |
|
1448 | - print '<br>'; |
|
1449 | - |
|
1450 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForLib").' : <strong>'.($realpathtolib?'':'<strike>').$pathtolib.($realpathtodocument?'':'</strike>').'</strong>'; |
|
1451 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolib).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1452 | - print '<br>'; |
|
1453 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForPicto").' : <strong>'.($realpathtopicto?'':'<strike>').$pathtopicto.($realpathtopicto?'':'</strike>').'</strong>'; |
|
1454 | - //print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1455 | - print '<br>'; |
|
1456 | - |
|
1457 | - print '<br>'; |
|
1458 | - print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.($realpathtosql?'':'<strike>').$pathtosql.($realpathtosql?'':'</strike>').'</strong>'; |
|
1459 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1460 | - print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("DropTableIfEmpty").'</a>'; |
|
1461 | - //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1462 | - print '<br>'; |
|
1463 | - print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileExtraFields").' : <strong>'.($realpathtosqlextra?'':'<strike>').$pathtosqlextra.($realpathtosqlextra?'':'</strike>').'</strong>'; |
|
1464 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1465 | - //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1466 | - print '<br>'; |
|
1467 | - print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileKey").' : <strong>'.($realpathtosqlkey?'':'<strike>').$pathtosqlkey.($realpathtosqlkey?'':'</strike>').'</strong>'; |
|
1468 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1469 | - //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1470 | - print '<br>'; |
|
1471 | - |
|
1472 | - print '<br>'; |
|
1473 | - print '</div>'; |
|
1474 | - |
|
1475 | - $urloflist = dol_buildpath($pathtolist, 1); |
|
1476 | - $urlofcard = dol_buildpath($pathtocard, 1); |
|
1477 | - |
|
1478 | - print '<div class="fichehalfleft">'; |
|
1479 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong><a href="'.$urloflist.'" target="_test">'.($realpathtosql?'':'<strike>').$pathtolist.($realpathtosql?'':'</strike>').'</a></strong>'; |
|
1480 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolist).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1481 | - print '<br>'; |
|
1482 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForCreateEditView").' : <strong><a href="'.$urlofcard.'?action=create" target="_test">'.($realpathtocard?'':'<strike>').$pathtocard.($realpathtocard?'':'</strike>').'?action=create</a></strong>'; |
|
1483 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtocard).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1484 | - print '<br>'; |
|
1485 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForAgendaTab").' : <strong>'.($realpathtoagenda?'':'<strike>').$pathtoagenda.($realpathtoagenda?'':'</strike>').'</strong>'; |
|
1486 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoagenda).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1487 | - print '<br>'; |
|
1488 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForDocumentTab").' : <strong>'.($realpathtodocument?'':'<strike>').$pathtodocument.($realpathtodocument?'':'</strike>').'</strong>'; |
|
1489 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtodocument).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1490 | - print '<br>'; |
|
1491 | - print '<span class="fa fa-file"></span> '.$langs->trans("PageForNoteTab").' : <strong>'.($realpathtonote?'':'<strike>').$pathtonote.($realpathtonote?'':'</strike>').'</strong>'; |
|
1492 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtonote).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1493 | - print '<br>'; |
|
1494 | - |
|
1495 | - print '<br>'; |
|
1496 | - |
|
1497 | - print '</div>'; |
|
1498 | - |
|
1499 | - print '<br><br><br>'; |
|
1500 | - |
|
1501 | - if (empty($forceddirread)) |
|
1502 | - { |
|
1503 | - $result = dol_include_once($pathtoclass); |
|
1504 | - } |
|
1505 | - else |
|
1506 | - { |
|
1507 | - $result = @include_once($dirread.'/'.$pathtoclass); |
|
1508 | - } |
|
1509 | - if (class_exists($tabobj)) |
|
1510 | - { |
|
1511 | - try { |
|
1512 | - $tmpobjet = @new $tabobj($db); |
|
1513 | - } |
|
1514 | - catch(Exception $e) |
|
1515 | - { |
|
1516 | - dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); |
|
1517 | - } |
|
1518 | - } |
|
1519 | - |
|
1520 | - if (! empty($tmpobjet)) |
|
1521 | - { |
|
1522 | - $reflector = new ReflectionClass($tabobj); |
|
1523 | - $properties = $reflector->getProperties(); // Can also use get_object_vars |
|
1524 | - $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars |
|
1525 | - //$propstat = $reflector->getStaticProperties(); |
|
1526 | - |
|
1527 | - print load_fiche_titre($langs->trans("Properties"), '', ''); |
|
1528 | - |
|
1529 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1530 | - |
|
1531 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1532 | - print '<input type="hidden" name="action" value="addproperty">'; |
|
1533 | - print '<input type="hidden" name="tab" value="objects">'; |
|
1534 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread?'@'.$dirread:'')).'">'; |
|
1535 | - print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1536 | - |
|
1537 | - print '<div class="div-table-responsive">'; |
|
1538 | - print '<table class="noborder">'; |
|
1539 | - print '<tr class="liste_titre">'; |
|
1540 | - print '<td>'.$langs->trans("Property"); |
|
1541 | - print ' (<a href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank">'.$langs->trans("Example").'</a>)'; |
|
1542 | - print '</td>'; |
|
1543 | - print '<td>'; |
|
1544 | - print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); |
|
1545 | - print '</td>'; |
|
1546 | - print '<td>'.$langs->trans("Type").'</td>'; |
|
1547 | - print '<td>'.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).'</td>'; |
|
1548 | - print '<td class="center">'.$langs->trans("NotNull").'</td>'; |
|
1549 | - //print '<td>'.$langs->trans("DefaultValue").'</td>'; |
|
1550 | - print '<td class="center">'.$langs->trans("DatabaseIndex").'</td>'; |
|
1551 | - print '<td class="right">'.$langs->trans("Position").'</td>'; |
|
1552 | - print '<td class="center">'.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).'</td>'; |
|
1553 | - print '<td class="center">'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).'</td>'; |
|
1554 | - print '<td class="center">'.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).'</td>'; |
|
1555 | - print '<td class="center">'.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).'</td>'; |
|
1556 | - print '<td>'.$langs->trans("Comment").'</td>'; |
|
1557 | - print '<td></td>'; |
|
1558 | - print '</tr>'; |
|
1559 | - |
|
1560 | - $properties = dol_sort_array($tmpobjet->fields, 'position'); |
|
1561 | - |
|
1562 | - if (! empty($properties)) |
|
1563 | - { |
|
1564 | - // Line to add a property |
|
1565 | - print '<tr>'; |
|
1566 | - print '<td><input class="text" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>'; |
|
1567 | - print '<td><input class="text" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>'; |
|
1568 | - print '<td><input class="text" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>'; |
|
1569 | - print '<td><input class="text" name="proparrayofkeyval" value="'.dol_escape_htmltag(GETPOST('proparrayofkeyval','none')).'"></td>'; |
|
1570 | - print '<td class="center"><input class="text" size="2" name="propnotnull" value="'.dol_escape_htmltag(GETPOST('propnotnull','alpha')).'"></td>'; |
|
1571 | - //print '<td><input class="text" name="propdefault" value=""></td>'; |
|
1572 | - print '<td class="center"><input class="text" size="2" name="propindex" value="'.dol_escape_htmltag(GETPOST('propindex','alpha')).'"></td>'; |
|
1573 | - print '<td class="right"><input class="text right" size="2" name="propposition" value="'.dol_escape_htmltag(GETPOST('propposition','alpha')).'"></td>'; |
|
1574 | - print '<td class="center"><input class="text" size="2" name="propenabled" value="'.dol_escape_htmltag(GETPOST('propenabled','alpha')).'"></td>'; |
|
1575 | - print '<td class="center"><input class="text" size="2" name="propvisible" value="'.dol_escape_htmltag(GETPOST('propvisible','alpha')).'"></td>'; |
|
1576 | - print '<td class="center"><input class="text" size="2" name="propisameasure" value="'.dol_escape_htmltag(GETPOST('propisameasure','alpha')).'"></td>'; |
|
1577 | - print '<td class="center"><input class="text" size="2" name="propsearchall" value="'.dol_escape_htmltag(GETPOST('propsearchall','alpha')).'"></td>'; |
|
1578 | - print '<td><input class="text" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment','alpha')).'"></td>'; |
|
1579 | - print '<td align="center">'; |
|
1580 | - print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">'; |
|
1581 | - print '</td></tr>'; |
|
1582 | - |
|
1583 | - foreach($properties as $propkey => $propval) |
|
1584 | - { |
|
1585 | - /* If from Reflection |
|
1229 | + // New module |
|
1230 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1231 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1232 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1233 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1234 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1235 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1236 | + |
|
1237 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1238 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1239 | + print '<br>'; |
|
1240 | + print '<center>'; |
|
1241 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1242 | + print ' '; |
|
1243 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1244 | + print '</center>'; |
|
1245 | + |
|
1246 | + print '</form>'; |
|
1247 | + } |
|
1248 | + } |
|
1249 | + |
|
1250 | + if ($tab == 'languages') |
|
1251 | + { |
|
1252 | + if ($action != 'editfile' || empty($file)) |
|
1253 | + { |
|
1254 | + print $langs->trans("LanguageDefDesc").'<br>'; |
|
1255 | + print '<br>'; |
|
1256 | + |
|
1257 | + |
|
1258 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
1259 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1260 | + print '<input type="hidden" name="action" value="addlanguage">'; |
|
1261 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1262 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1263 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1264 | + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 1); |
|
1265 | + print '<input type="submit" name="addlanguage" class="button" value="'.dol_escape_htmltag($langs->trans("AddLanguageFile")).'"><br>'; |
|
1266 | + print '</form>'; |
|
1267 | + |
|
1268 | + print '<br>'; |
|
1269 | + print '<br>'; |
|
1270 | + |
|
1271 | + $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); |
|
1272 | + |
|
1273 | + foreach ($langfiles as $langfile) |
|
1274 | + { |
|
1275 | + $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; |
|
1276 | + print '<span class="fa fa-file"></span> '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : <strong>'.$pathtofile.'</strong>'; |
|
1277 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1278 | + print '<br>'; |
|
1279 | + } |
|
1280 | + } |
|
1281 | + else |
|
1282 | + { |
|
1283 | + // Edit text language file |
|
1284 | + |
|
1285 | + //print $langs->trans("UseAsciiDocFormat").'<br>'; |
|
1286 | + |
|
1287 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1288 | + |
|
1289 | + $content = file_get_contents($fullpathoffile); |
|
1290 | + |
|
1291 | + // New module |
|
1292 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1293 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1294 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1295 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1296 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1297 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1298 | + |
|
1299 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1300 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text')); |
|
1301 | + print '<br>'; |
|
1302 | + print '<center>'; |
|
1303 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1304 | + print ' '; |
|
1305 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1306 | + print '</center>'; |
|
1307 | + |
|
1308 | + print '</form>'; |
|
1309 | + } |
|
1310 | + } |
|
1311 | + |
|
1312 | + if ($tab == 'objects') |
|
1313 | + { |
|
1314 | + $head3 = array(); |
|
1315 | + $h=0; |
|
1316 | + |
|
1317 | + // Dir for module |
|
1318 | + $dir = $dirread.'/'.$modulelowercase.'/class'; |
|
1319 | + |
|
1320 | + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; |
|
1321 | + $head3[$h][1] = $langs->trans("NewObject"); |
|
1322 | + $head3[$h][2] = 'newobject'; |
|
1323 | + $h++; |
|
1324 | + |
|
1325 | + // Scan for object class files |
|
1326 | + $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); |
|
1327 | + |
|
1328 | + $firstobjectname=''; |
|
1329 | + foreach($listofobject as $fileobj) |
|
1330 | + { |
|
1331 | + if (preg_match('/^api_/',$fileobj['name'])) continue; |
|
1332 | + if (preg_match('/^actions_/',$fileobj['name'])) continue; |
|
1333 | + |
|
1334 | + $tmpcontent=file_get_contents($fileobj['fullname']); |
|
1335 | + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) |
|
1336 | + { |
|
1337 | + //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); |
|
1338 | + $objectname = $reg[1]; |
|
1339 | + if (empty($firstobjectname)) $firstobjectname = $objectname; |
|
1340 | + |
|
1341 | + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; |
|
1342 | + $head3[$h][1] = $objectname; |
|
1343 | + $head3[$h][2] = $objectname; |
|
1344 | + $h++; |
|
1345 | + } |
|
1346 | + } |
|
1347 | + |
|
1348 | + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; |
|
1349 | + $head3[$h][1] = $langs->trans("DangerZone"); |
|
1350 | + $head3[$h][2] = 'deleteobject'; |
|
1351 | + $h++; |
|
1352 | + |
|
1353 | + // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. |
|
1354 | + if ($tabobj == 'newobjectifnoobj') |
|
1355 | + { |
|
1356 | + if ($firstobjectname) $tabobj=$firstobjectname; |
|
1357 | + else $tabobj = 'newobject'; |
|
1358 | + } |
|
1359 | + |
|
1360 | + dol_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 |
|
1361 | + |
|
1362 | + if ($tabobj == 'newobject') |
|
1363 | + { |
|
1364 | + // New object tab |
|
1365 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1366 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1367 | + print '<input type="hidden" name="action" value="initobject">'; |
|
1368 | + print '<input type="hidden" name="tab" value="objects">'; |
|
1369 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1370 | + |
|
1371 | + print $langs->trans("EnterNameOfObjectDesc").'<br><br>'; |
|
1372 | + |
|
1373 | + print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">'; |
|
1374 | + print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
1375 | + print '</form>'; |
|
1376 | + } |
|
1377 | + elseif ($tabobj == 'deleteobject') |
|
1378 | + { |
|
1379 | + // Delete object tab |
|
1380 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1381 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1382 | + print '<input type="hidden" name="action" value="confirm_deleteobject">'; |
|
1383 | + print '<input type="hidden" name="tab" value="objects">'; |
|
1384 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1385 | + |
|
1386 | + print $langs->trans("EnterNameOfObjectToDeleteDesc").'<br><br>'; |
|
1387 | + |
|
1388 | + print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">'; |
|
1389 | + print '<input type="submit" class="buttonDelete" name="delete" value="'.dol_escape_htmltag($langs->trans("Delete")).'"'.($dirins?'':' disabled="disabled"').'>'; |
|
1390 | + print '</form>'; |
|
1391 | + } |
|
1392 | + else |
|
1393 | + { // tabobj = module |
|
1394 | + if ($action == 'deleteproperty') |
|
1395 | + { |
|
1396 | + $formconfirm = $form->formconfirm( |
|
1397 | + $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey','alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), |
|
1398 | + $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey','alpha')), 'confirm_deleteproperty', '', 0, 1 |
|
1399 | + ); |
|
1400 | + |
|
1401 | + // Print form confirm |
|
1402 | + print $formconfirm; |
|
1403 | + } |
|
1404 | + |
|
1405 | + if ($action != 'editfile' || empty($file)) |
|
1406 | + { |
|
1407 | + try { |
|
1408 | + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; |
|
1409 | + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; |
|
1410 | + $pathtoagenda = strtolower($module).'/'.strtolower($tabobj).'_agenda.php'; |
|
1411 | + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; |
|
1412 | + $pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php'; |
|
1413 | + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; |
|
1414 | + $pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php'; |
|
1415 | + $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; |
|
1416 | + $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; |
|
1417 | + $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; |
|
1418 | + $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; |
|
1419 | + $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; |
|
1420 | + $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; |
|
1421 | + |
|
1422 | + $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); |
|
1423 | + $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); |
|
1424 | + $realpathtoagenda = dol_buildpath($pathtoagenda, 0, 1); |
|
1425 | + $realpathtocard = dol_buildpath($pathtocard, 0, 1); |
|
1426 | + $realpathtodocument = dol_buildpath($pathtodocument, 0, 1); |
|
1427 | + $realpathtolist = dol_buildpath($pathtolist, 0, 1); |
|
1428 | + $realpathtonote = dol_buildpath($pathtonote, 0, 1); |
|
1429 | + $realpathtophpunit = dol_buildpath($pathtophpunit, 0, 1); |
|
1430 | + $realpathtosql = dol_buildpath($pathtosql, 0, 1); |
|
1431 | + $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); |
|
1432 | + $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); |
|
1433 | + $realpathtolib = dol_buildpath($pathtolib, 0, 1); |
|
1434 | + $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); |
|
1435 | + |
|
1436 | + print '<div class="fichehalfleft">'; |
|
1437 | + print '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.($realpathtoclass?'':'<strike>').$pathtoclass.($realpathtoclass?'':'</strike>').'</strong>'; |
|
1438 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1439 | + print '<br>'; |
|
1440 | + print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.($realpathtoapi?'':'<strike>').$pathtoapi.($realpathtoapi?'':'</strike>').'</strong>'; |
|
1441 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1442 | + print ' <a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>'; |
|
1443 | + print '<br>'; |
|
1444 | + print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.($realpathtophpunit?'':'<strike>').$pathtophpunit.($realpathtophpunit?'':'</strike>').'</strong>'; |
|
1445 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1446 | + print '<br>'; |
|
1447 | + |
|
1448 | + print '<br>'; |
|
1449 | + |
|
1450 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForLib").' : <strong>'.($realpathtolib?'':'<strike>').$pathtolib.($realpathtodocument?'':'</strike>').'</strong>'; |
|
1451 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolib).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1452 | + print '<br>'; |
|
1453 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForPicto").' : <strong>'.($realpathtopicto?'':'<strike>').$pathtopicto.($realpathtopicto?'':'</strike>').'</strong>'; |
|
1454 | + //print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1455 | + print '<br>'; |
|
1456 | + |
|
1457 | + print '<br>'; |
|
1458 | + print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.($realpathtosql?'':'<strike>').$pathtosql.($realpathtosql?'':'</strike>').'</strong>'; |
|
1459 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1460 | + print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("DropTableIfEmpty").'</a>'; |
|
1461 | + //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1462 | + print '<br>'; |
|
1463 | + print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileExtraFields").' : <strong>'.($realpathtosqlextra?'':'<strike>').$pathtosqlextra.($realpathtosqlextra?'':'</strike>').'</strong>'; |
|
1464 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1465 | + //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1466 | + print '<br>'; |
|
1467 | + print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileKey").' : <strong>'.($realpathtosqlkey?'':'<strike>').$pathtosqlkey.($realpathtosqlkey?'':'</strike>').'</strong>'; |
|
1468 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1469 | + //print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>'; |
|
1470 | + print '<br>'; |
|
1471 | + |
|
1472 | + print '<br>'; |
|
1473 | + print '</div>'; |
|
1474 | + |
|
1475 | + $urloflist = dol_buildpath($pathtolist, 1); |
|
1476 | + $urlofcard = dol_buildpath($pathtocard, 1); |
|
1477 | + |
|
1478 | + print '<div class="fichehalfleft">'; |
|
1479 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong><a href="'.$urloflist.'" target="_test">'.($realpathtosql?'':'<strike>').$pathtolist.($realpathtosql?'':'</strike>').'</a></strong>'; |
|
1480 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolist).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1481 | + print '<br>'; |
|
1482 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForCreateEditView").' : <strong><a href="'.$urlofcard.'?action=create" target="_test">'.($realpathtocard?'':'<strike>').$pathtocard.($realpathtocard?'':'</strike>').'?action=create</a></strong>'; |
|
1483 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtocard).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1484 | + print '<br>'; |
|
1485 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForAgendaTab").' : <strong>'.($realpathtoagenda?'':'<strike>').$pathtoagenda.($realpathtoagenda?'':'</strike>').'</strong>'; |
|
1486 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoagenda).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1487 | + print '<br>'; |
|
1488 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForDocumentTab").' : <strong>'.($realpathtodocument?'':'<strike>').$pathtodocument.($realpathtodocument?'':'</strike>').'</strong>'; |
|
1489 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtodocument).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1490 | + print '<br>'; |
|
1491 | + print '<span class="fa fa-file"></span> '.$langs->trans("PageForNoteTab").' : <strong>'.($realpathtonote?'':'<strike>').$pathtonote.($realpathtonote?'':'</strike>').'</strong>'; |
|
1492 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtonote).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1493 | + print '<br>'; |
|
1494 | + |
|
1495 | + print '<br>'; |
|
1496 | + |
|
1497 | + print '</div>'; |
|
1498 | + |
|
1499 | + print '<br><br><br>'; |
|
1500 | + |
|
1501 | + if (empty($forceddirread)) |
|
1502 | + { |
|
1503 | + $result = dol_include_once($pathtoclass); |
|
1504 | + } |
|
1505 | + else |
|
1506 | + { |
|
1507 | + $result = @include_once($dirread.'/'.$pathtoclass); |
|
1508 | + } |
|
1509 | + if (class_exists($tabobj)) |
|
1510 | + { |
|
1511 | + try { |
|
1512 | + $tmpobjet = @new $tabobj($db); |
|
1513 | + } |
|
1514 | + catch(Exception $e) |
|
1515 | + { |
|
1516 | + dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); |
|
1517 | + } |
|
1518 | + } |
|
1519 | + |
|
1520 | + if (! empty($tmpobjet)) |
|
1521 | + { |
|
1522 | + $reflector = new ReflectionClass($tabobj); |
|
1523 | + $properties = $reflector->getProperties(); // Can also use get_object_vars |
|
1524 | + $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars |
|
1525 | + //$propstat = $reflector->getStaticProperties(); |
|
1526 | + |
|
1527 | + print load_fiche_titre($langs->trans("Properties"), '', ''); |
|
1528 | + |
|
1529 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1530 | + |
|
1531 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1532 | + print '<input type="hidden" name="action" value="addproperty">'; |
|
1533 | + print '<input type="hidden" name="tab" value="objects">'; |
|
1534 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread?'@'.$dirread:'')).'">'; |
|
1535 | + print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1536 | + |
|
1537 | + print '<div class="div-table-responsive">'; |
|
1538 | + print '<table class="noborder">'; |
|
1539 | + print '<tr class="liste_titre">'; |
|
1540 | + print '<td>'.$langs->trans("Property"); |
|
1541 | + print ' (<a href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank">'.$langs->trans("Example").'</a>)'; |
|
1542 | + print '</td>'; |
|
1543 | + print '<td>'; |
|
1544 | + print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); |
|
1545 | + print '</td>'; |
|
1546 | + print '<td>'.$langs->trans("Type").'</td>'; |
|
1547 | + print '<td>'.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).'</td>'; |
|
1548 | + print '<td class="center">'.$langs->trans("NotNull").'</td>'; |
|
1549 | + //print '<td>'.$langs->trans("DefaultValue").'</td>'; |
|
1550 | + print '<td class="center">'.$langs->trans("DatabaseIndex").'</td>'; |
|
1551 | + print '<td class="right">'.$langs->trans("Position").'</td>'; |
|
1552 | + print '<td class="center">'.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).'</td>'; |
|
1553 | + print '<td class="center">'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).'</td>'; |
|
1554 | + print '<td class="center">'.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).'</td>'; |
|
1555 | + print '<td class="center">'.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).'</td>'; |
|
1556 | + print '<td>'.$langs->trans("Comment").'</td>'; |
|
1557 | + print '<td></td>'; |
|
1558 | + print '</tr>'; |
|
1559 | + |
|
1560 | + $properties = dol_sort_array($tmpobjet->fields, 'position'); |
|
1561 | + |
|
1562 | + if (! empty($properties)) |
|
1563 | + { |
|
1564 | + // Line to add a property |
|
1565 | + print '<tr>'; |
|
1566 | + print '<td><input class="text" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>'; |
|
1567 | + print '<td><input class="text" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>'; |
|
1568 | + print '<td><input class="text" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>'; |
|
1569 | + print '<td><input class="text" name="proparrayofkeyval" value="'.dol_escape_htmltag(GETPOST('proparrayofkeyval','none')).'"></td>'; |
|
1570 | + print '<td class="center"><input class="text" size="2" name="propnotnull" value="'.dol_escape_htmltag(GETPOST('propnotnull','alpha')).'"></td>'; |
|
1571 | + //print '<td><input class="text" name="propdefault" value=""></td>'; |
|
1572 | + print '<td class="center"><input class="text" size="2" name="propindex" value="'.dol_escape_htmltag(GETPOST('propindex','alpha')).'"></td>'; |
|
1573 | + print '<td class="right"><input class="text right" size="2" name="propposition" value="'.dol_escape_htmltag(GETPOST('propposition','alpha')).'"></td>'; |
|
1574 | + print '<td class="center"><input class="text" size="2" name="propenabled" value="'.dol_escape_htmltag(GETPOST('propenabled','alpha')).'"></td>'; |
|
1575 | + print '<td class="center"><input class="text" size="2" name="propvisible" value="'.dol_escape_htmltag(GETPOST('propvisible','alpha')).'"></td>'; |
|
1576 | + print '<td class="center"><input class="text" size="2" name="propisameasure" value="'.dol_escape_htmltag(GETPOST('propisameasure','alpha')).'"></td>'; |
|
1577 | + print '<td class="center"><input class="text" size="2" name="propsearchall" value="'.dol_escape_htmltag(GETPOST('propsearchall','alpha')).'"></td>'; |
|
1578 | + print '<td><input class="text" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment','alpha')).'"></td>'; |
|
1579 | + print '<td align="center">'; |
|
1580 | + print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">'; |
|
1581 | + print '</td></tr>'; |
|
1582 | + |
|
1583 | + foreach($properties as $propkey => $propval) |
|
1584 | + { |
|
1585 | + /* If from Reflection |
|
1586 | 1586 | if ($propval->class == $tabobj) |
1587 | 1587 | { |
1588 | 1588 | $propname=$propval->getName(); |
@@ -1596,154 +1596,154 @@ discard block |
||
1596 | 1596 | if (in_array($propname, array('fk_element', 'lines'))) continue; |
1597 | 1597 | }*/ |
1598 | 1598 | |
1599 | - $propname=$propkey; |
|
1600 | - $proplabel=$propval['label']; |
|
1601 | - $proptype=$propval['type']; |
|
1602 | - $proparrayofkeyval=$propval['arrayofkeyval']; |
|
1603 | - $propnotnull=$propval['notnull']; |
|
1604 | - $propsearchall=$propval['searchall']; |
|
1605 | - //$propdefault=$propval['default']; |
|
1606 | - $propindex=$propval['index']; |
|
1607 | - $propposition=$propval['position']; |
|
1608 | - $propenabled=$propval['enabled']; |
|
1609 | - $propvisible=$propval['visible']; |
|
1610 | - $propisameasure=$propval['isameasure']; |
|
1611 | - $propcomment=$propval['comment']; |
|
1612 | - |
|
1613 | - print '<tr class="oddeven">'; |
|
1614 | - |
|
1615 | - print '<td>'; |
|
1616 | - print $propname; |
|
1617 | - print '</td>'; |
|
1618 | - print '<td>'; |
|
1619 | - print $proplabel; |
|
1620 | - print '</td>'; |
|
1621 | - print '<td>'; |
|
1622 | - print $proptype; |
|
1623 | - print '</td>'; |
|
1624 | - print '<td>'; |
|
1625 | - if ($proparrayofkeyval) |
|
1626 | - { |
|
1627 | - print json_encode($proparrayofkeyval); |
|
1628 | - } |
|
1629 | - print '</td>'; |
|
1630 | - print '<td class="center">'; |
|
1631 | - print $propnotnull; |
|
1632 | - print '</td>'; |
|
1633 | - /*print '<td>'; |
|
1599 | + $propname=$propkey; |
|
1600 | + $proplabel=$propval['label']; |
|
1601 | + $proptype=$propval['type']; |
|
1602 | + $proparrayofkeyval=$propval['arrayofkeyval']; |
|
1603 | + $propnotnull=$propval['notnull']; |
|
1604 | + $propsearchall=$propval['searchall']; |
|
1605 | + //$propdefault=$propval['default']; |
|
1606 | + $propindex=$propval['index']; |
|
1607 | + $propposition=$propval['position']; |
|
1608 | + $propenabled=$propval['enabled']; |
|
1609 | + $propvisible=$propval['visible']; |
|
1610 | + $propisameasure=$propval['isameasure']; |
|
1611 | + $propcomment=$propval['comment']; |
|
1612 | + |
|
1613 | + print '<tr class="oddeven">'; |
|
1614 | + |
|
1615 | + print '<td>'; |
|
1616 | + print $propname; |
|
1617 | + print '</td>'; |
|
1618 | + print '<td>'; |
|
1619 | + print $proplabel; |
|
1620 | + print '</td>'; |
|
1621 | + print '<td>'; |
|
1622 | + print $proptype; |
|
1623 | + print '</td>'; |
|
1624 | + print '<td>'; |
|
1625 | + if ($proparrayofkeyval) |
|
1626 | + { |
|
1627 | + print json_encode($proparrayofkeyval); |
|
1628 | + } |
|
1629 | + print '</td>'; |
|
1630 | + print '<td class="center">'; |
|
1631 | + print $propnotnull; |
|
1632 | + print '</td>'; |
|
1633 | + /*print '<td>'; |
|
1634 | 1634 | print $propdefault; |
1635 | 1635 | print '</td>';*/ |
1636 | - print '<td class="center">'; |
|
1637 | - print $propindex?'X':''; |
|
1638 | - print '</td>'; |
|
1639 | - print '<td align="right">'; |
|
1640 | - print $propposition; |
|
1641 | - print '</td>'; |
|
1642 | - print '<td class="center">'; |
|
1643 | - print $propenabled?$propenabled:''; |
|
1644 | - print '</td>'; |
|
1645 | - print '<td class="center">'; |
|
1646 | - print $propvisible?$propvisible:''; |
|
1647 | - print '</td>'; |
|
1648 | - print '<td class="center">'; |
|
1649 | - print $propisameasure?$propisameasure:''; |
|
1650 | - print '</td>'; |
|
1651 | - print '<td class="center">'; |
|
1652 | - print $propsearchall?'X':''; |
|
1653 | - print '</td>'; |
|
1654 | - print '<td>'; |
|
1655 | - print $propcomment; |
|
1656 | - print '</td>'; |
|
1657 | - print '<td class="center">'; |
|
1658 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=deleteproperty&propertykey='.urlencode($propname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>'; |
|
1659 | - print '</td>'; |
|
1660 | - |
|
1661 | - print '</tr>'; |
|
1662 | - } |
|
1663 | - } |
|
1664 | - else |
|
1665 | - { |
|
1666 | - print '<tr><td><span class="warning">'.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').'</warning></td></tr>'; |
|
1667 | - } |
|
1668 | - print '</table>'; |
|
1636 | + print '<td class="center">'; |
|
1637 | + print $propindex?'X':''; |
|
1638 | + print '</td>'; |
|
1639 | + print '<td align="right">'; |
|
1640 | + print $propposition; |
|
1641 | + print '</td>'; |
|
1642 | + print '<td class="center">'; |
|
1643 | + print $propenabled?$propenabled:''; |
|
1644 | + print '</td>'; |
|
1645 | + print '<td class="center">'; |
|
1646 | + print $propvisible?$propvisible:''; |
|
1647 | + print '</td>'; |
|
1648 | + print '<td class="center">'; |
|
1649 | + print $propisameasure?$propisameasure:''; |
|
1650 | + print '</td>'; |
|
1651 | + print '<td class="center">'; |
|
1652 | + print $propsearchall?'X':''; |
|
1653 | + print '</td>'; |
|
1654 | + print '<td>'; |
|
1655 | + print $propcomment; |
|
1656 | + print '</td>'; |
|
1657 | + print '<td class="center">'; |
|
1658 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=deleteproperty&propertykey='.urlencode($propname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>'; |
|
1659 | + print '</td>'; |
|
1660 | + |
|
1661 | + print '</tr>'; |
|
1662 | + } |
|
1663 | + } |
|
1664 | + else |
|
1665 | + { |
|
1666 | + print '<tr><td><span class="warning">'.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').'</warning></td></tr>'; |
|
1667 | + } |
|
1668 | + print '</table>'; |
|
1669 | 1669 | print '</div>'; |
1670 | 1670 | |
1671 | - print '</form>'; |
|
1672 | - } |
|
1673 | - else |
|
1674 | - { |
|
1675 | - print '<tr><td><span class="warning">'.$langs->trans('Failed to init the object with the new.').'</warning></td></tr>'; |
|
1676 | - } |
|
1677 | - } |
|
1678 | - catch(Exception $e) |
|
1679 | - { |
|
1680 | - print $e->getMessage(); |
|
1681 | - } |
|
1682 | - } |
|
1683 | - else |
|
1684 | - { |
|
1685 | - if (empty($forceddirread)) |
|
1686 | - { |
|
1687 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1688 | - } |
|
1689 | - else |
|
1690 | - { |
|
1691 | - $fullpathoffile=$dirread.'/'.$file; |
|
1692 | - } |
|
1693 | - |
|
1694 | - $content = file_get_contents($fullpathoffile); |
|
1695 | - |
|
1696 | - // New module |
|
1697 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1698 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1699 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1700 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1701 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1702 | - print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1703 | - print '<input type="hidden" name="module" value="'.$module.($forceddirread?'@'.$dirread:'').'">'; |
|
1704 | - |
|
1705 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1706 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1707 | - print '<br>'; |
|
1708 | - print '<center>'; |
|
1709 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1710 | - print ' '; |
|
1711 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1712 | - print '</center>'; |
|
1713 | - |
|
1714 | - print '</form>'; |
|
1715 | - } |
|
1716 | - } |
|
1717 | - |
|
1718 | - dol_fiche_end(); // Level 3 |
|
1719 | - } |
|
1720 | - |
|
1721 | - if ($tab == 'menus') |
|
1722 | - { |
|
1723 | - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1724 | - |
|
1725 | - //$menus = $moduleobj->; |
|
1726 | - |
|
1727 | - if ($action != 'editfile' || empty($file)) |
|
1728 | - { |
|
1729 | - print $langs->trans("MenusDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php">'.$langs->trans('Menus').'</a>').'<br>'; |
|
1730 | - print '<br>'; |
|
1731 | - |
|
1732 | - print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1733 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1734 | - print '<br>'; |
|
1735 | - |
|
1736 | - print '<br>'; |
|
1737 | - //print load_fiche_titre($langs->trans("MenusList"), '', ''); |
|
1738 | - |
|
1739 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1740 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1741 | - print '<input type="hidden" name="action" value="addproperty">'; |
|
1742 | - print '<input type="hidden" name="tab" value="objects">'; |
|
1743 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1744 | - print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1745 | - |
|
1746 | - /* |
|
1671 | + print '</form>'; |
|
1672 | + } |
|
1673 | + else |
|
1674 | + { |
|
1675 | + print '<tr><td><span class="warning">'.$langs->trans('Failed to init the object with the new.').'</warning></td></tr>'; |
|
1676 | + } |
|
1677 | + } |
|
1678 | + catch(Exception $e) |
|
1679 | + { |
|
1680 | + print $e->getMessage(); |
|
1681 | + } |
|
1682 | + } |
|
1683 | + else |
|
1684 | + { |
|
1685 | + if (empty($forceddirread)) |
|
1686 | + { |
|
1687 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1688 | + } |
|
1689 | + else |
|
1690 | + { |
|
1691 | + $fullpathoffile=$dirread.'/'.$file; |
|
1692 | + } |
|
1693 | + |
|
1694 | + $content = file_get_contents($fullpathoffile); |
|
1695 | + |
|
1696 | + // New module |
|
1697 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1698 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1699 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1700 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1701 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1702 | + print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1703 | + print '<input type="hidden" name="module" value="'.$module.($forceddirread?'@'.$dirread:'').'">'; |
|
1704 | + |
|
1705 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1706 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1707 | + print '<br>'; |
|
1708 | + print '<center>'; |
|
1709 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1710 | + print ' '; |
|
1711 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1712 | + print '</center>'; |
|
1713 | + |
|
1714 | + print '</form>'; |
|
1715 | + } |
|
1716 | + } |
|
1717 | + |
|
1718 | + dol_fiche_end(); // Level 3 |
|
1719 | + } |
|
1720 | + |
|
1721 | + if ($tab == 'menus') |
|
1722 | + { |
|
1723 | + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1724 | + |
|
1725 | + //$menus = $moduleobj->; |
|
1726 | + |
|
1727 | + if ($action != 'editfile' || empty($file)) |
|
1728 | + { |
|
1729 | + print $langs->trans("MenusDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php">'.$langs->trans('Menus').'</a>').'<br>'; |
|
1730 | + print '<br>'; |
|
1731 | + |
|
1732 | + print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1733 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1734 | + print '<br>'; |
|
1735 | + |
|
1736 | + print '<br>'; |
|
1737 | + //print load_fiche_titre($langs->trans("MenusList"), '', ''); |
|
1738 | + |
|
1739 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1740 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1741 | + print '<input type="hidden" name="action" value="addproperty">'; |
|
1742 | + print '<input type="hidden" name="tab" value="objects">'; |
|
1743 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1744 | + print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1745 | + |
|
1746 | + /* |
|
1747 | 1747 | print '<div class="div-table-responsive">'; |
1748 | 1748 | print '<table class="noborder">'; |
1749 | 1749 | |
@@ -1814,58 +1814,58 @@ discard block |
||
1814 | 1814 | |
1815 | 1815 | print '</form>'; |
1816 | 1816 | */ |
1817 | - } |
|
1818 | - else |
|
1819 | - { |
|
1820 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1821 | - |
|
1822 | - $content = file_get_contents($fullpathoffile); |
|
1823 | - |
|
1824 | - // New module |
|
1825 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1826 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1827 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1828 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1829 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1830 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1831 | - |
|
1832 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1833 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1834 | - print '<br>'; |
|
1835 | - print '<center>'; |
|
1836 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1837 | - print ' '; |
|
1838 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1839 | - print '</center>'; |
|
1817 | + } |
|
1818 | + else |
|
1819 | + { |
|
1820 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1840 | 1821 | |
1841 | - print '</form>'; |
|
1842 | - } |
|
1843 | - } |
|
1822 | + $content = file_get_contents($fullpathoffile); |
|
1844 | 1823 | |
1845 | - if ($tab == 'permissions') |
|
1846 | - { |
|
1847 | - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1824 | + // New module |
|
1825 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1826 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1827 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1828 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1829 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1830 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1848 | 1831 | |
1849 | - //$perms = $moduleobj->; |
|
1832 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1833 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1834 | + print '<br>'; |
|
1835 | + print '<center>'; |
|
1836 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1837 | + print ' '; |
|
1838 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1839 | + print '</center>'; |
|
1850 | 1840 | |
1851 | - if ($action != 'editfile' || empty($file)) |
|
1852 | - { |
|
1853 | - print $langs->trans("PermissionsDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/perms.php">'.$langs->trans('DefaultPermissions').'</a>').'<br>'; |
|
1854 | - print '<br>'; |
|
1841 | + print '</form>'; |
|
1842 | + } |
|
1843 | + } |
|
1855 | 1844 | |
1856 | - print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1857 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1858 | - print '<br>'; |
|
1845 | + if ($tab == 'permissions') |
|
1846 | + { |
|
1847 | + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1859 | 1848 | |
1860 | - print '<br>'; |
|
1861 | - print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); |
|
1849 | + //$perms = $moduleobj->; |
|
1862 | 1850 | |
1863 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1864 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1865 | - print '<input type="hidden" name="action" value="addproperty">'; |
|
1866 | - print '<input type="hidden" name="tab" value="objects">'; |
|
1867 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1868 | - print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1851 | + if ($action != 'editfile' || empty($file)) |
|
1852 | + { |
|
1853 | + print $langs->trans("PermissionsDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/perms.php">'.$langs->trans('DefaultPermissions').'</a>').'<br>'; |
|
1854 | + print '<br>'; |
|
1855 | + |
|
1856 | + print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
1857 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1858 | + print '<br>'; |
|
1859 | + |
|
1860 | + print '<br>'; |
|
1861 | + print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); |
|
1862 | + |
|
1863 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1864 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1865 | + print '<input type="hidden" name="action" value="addproperty">'; |
|
1866 | + print '<input type="hidden" name="tab" value="objects">'; |
|
1867 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
1868 | + print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
1869 | 1869 | |
1870 | 1870 | print 'TODO...'; |
1871 | 1871 | /* |
@@ -1939,81 +1939,81 @@ discard block |
||
1939 | 1939 | |
1940 | 1940 | print '</form>'; |
1941 | 1941 | */ |
1942 | - } |
|
1943 | - else |
|
1944 | - { |
|
1945 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1946 | - |
|
1947 | - $content = file_get_contents($fullpathoffile); |
|
1948 | - |
|
1949 | - // New module |
|
1950 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1951 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1952 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1953 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1954 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1955 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1956 | - |
|
1957 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1958 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1959 | - print '<br>'; |
|
1960 | - print '<center>'; |
|
1961 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1962 | - print ' '; |
|
1963 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1964 | - print '</center>'; |
|
1942 | + } |
|
1943 | + else |
|
1944 | + { |
|
1945 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1965 | 1946 | |
1966 | - print '</form>'; |
|
1967 | - } |
|
1968 | - } |
|
1947 | + $content = file_get_contents($fullpathoffile); |
|
1948 | + |
|
1949 | + // New module |
|
1950 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1951 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1952 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1953 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1954 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1955 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
1956 | + |
|
1957 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
1958 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
1959 | + print '<br>'; |
|
1960 | + print '<center>'; |
|
1961 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
1962 | + print ' '; |
|
1963 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
1964 | + print '</center>'; |
|
1965 | + |
|
1966 | + print '</form>'; |
|
1967 | + } |
|
1968 | + } |
|
1969 | 1969 | |
1970 | - if ($tab == 'hooks') |
|
1971 | - { |
|
1972 | - if ($action != 'editfile' || empty($file)) |
|
1970 | + if ($tab == 'hooks') |
|
1971 | + { |
|
1972 | + if ($action != 'editfile' || empty($file)) |
|
1973 | 1973 | { |
1974 | 1974 | print $langs->trans("HooksDefDesc").'<br>'; |
1975 | 1975 | print '<br>'; |
1976 | 1976 | |
1977 | - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1977 | + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
1978 | 1978 | print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
1979 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1980 | - print '<br>'; |
|
1979 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1980 | + print '<br>'; |
|
1981 | 1981 | |
1982 | - $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; |
|
1982 | + $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; |
|
1983 | 1983 | print '<span class="fa fa-file"></span> '.$langs->trans("HooksFile").' : <strong>'.$pathtohook.'</strong>'; |
1984 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1985 | - print '<br>'; |
|
1984 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
1985 | + print '<br>'; |
|
1986 | 1986 | } |
1987 | 1987 | else |
1988 | 1988 | { |
1989 | - $fullpathoffile=dol_buildpath($file, 0); |
|
1990 | - |
|
1991 | - $content = file_get_contents($fullpathoffile); |
|
1992 | - |
|
1993 | - // New module |
|
1994 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1995 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1996 | - print '<input type="hidden" name="action" value="savefile">'; |
|
1997 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1998 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1999 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2000 | - |
|
2001 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2002 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2003 | - print '<br>'; |
|
2004 | - print '<center>'; |
|
2005 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2006 | - print ' '; |
|
2007 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2008 | - print '</center>'; |
|
2009 | - |
|
2010 | - print '</form>'; |
|
1989 | + $fullpathoffile=dol_buildpath($file, 0); |
|
1990 | + |
|
1991 | + $content = file_get_contents($fullpathoffile); |
|
1992 | + |
|
1993 | + // New module |
|
1994 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
1995 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1996 | + print '<input type="hidden" name="action" value="savefile">'; |
|
1997 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
1998 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
1999 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2000 | + |
|
2001 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2002 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2003 | + print '<br>'; |
|
2004 | + print '<center>'; |
|
2005 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2006 | + print ' '; |
|
2007 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2008 | + print '</center>'; |
|
2009 | + |
|
2010 | + print '</form>'; |
|
2011 | 2011 | } |
2012 | - } |
|
2012 | + } |
|
2013 | 2013 | |
2014 | - if ($tab == 'triggers') |
|
2015 | - { |
|
2016 | - require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
2014 | + if ($tab == 'triggers') |
|
2015 | + { |
|
2016 | + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
2017 | 2017 | |
2018 | 2018 | $interfaces = new Interfaces($db); |
2019 | 2019 | $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); |
@@ -2025,14 +2025,14 @@ discard block |
||
2025 | 2025 | |
2026 | 2026 | if (! empty($triggers)) |
2027 | 2027 | { |
2028 | - foreach ($triggers as $trigger) |
|
2029 | - { |
|
2030 | - $pathtofile = $trigger['relpath']; |
|
2031 | - |
|
2032 | - print '<span class="fa fa-file"></span> '.$langs->trans("TriggersFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2033 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2034 | - print '<br>'; |
|
2035 | - } |
|
2028 | + foreach ($triggers as $trigger) |
|
2029 | + { |
|
2030 | + $pathtofile = $trigger['relpath']; |
|
2031 | + |
|
2032 | + print '<span class="fa fa-file"></span> '.$langs->trans("TriggersFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2033 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2034 | + print '<br>'; |
|
2035 | + } |
|
2036 | 2036 | } |
2037 | 2037 | else |
2038 | 2038 | { |
@@ -2041,34 +2041,34 @@ discard block |
||
2041 | 2041 | } |
2042 | 2042 | else |
2043 | 2043 | { |
2044 | - $fullpathoffile=dol_buildpath($file, 0); |
|
2045 | - |
|
2046 | - $content = file_get_contents($fullpathoffile); |
|
2047 | - |
|
2048 | - // New module |
|
2049 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2050 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2051 | - print '<input type="hidden" name="action" value="savefile">'; |
|
2052 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2053 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2054 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2055 | - |
|
2056 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2057 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2058 | - print '<br>'; |
|
2059 | - print '<center>'; |
|
2060 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2061 | - print ' '; |
|
2062 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2063 | - print '</center>'; |
|
2064 | - |
|
2065 | - print '</form>'; |
|
2044 | + $fullpathoffile=dol_buildpath($file, 0); |
|
2045 | + |
|
2046 | + $content = file_get_contents($fullpathoffile); |
|
2047 | + |
|
2048 | + // New module |
|
2049 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2050 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2051 | + print '<input type="hidden" name="action" value="savefile">'; |
|
2052 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2053 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2054 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2055 | + |
|
2056 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2057 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2058 | + print '<br>'; |
|
2059 | + print '<center>'; |
|
2060 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2061 | + print ' '; |
|
2062 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2063 | + print '</center>'; |
|
2064 | + |
|
2065 | + print '</form>'; |
|
2066 | 2066 | } |
2067 | - } |
|
2067 | + } |
|
2068 | 2068 | |
2069 | - if ($tab == 'widgets') |
|
2070 | - { |
|
2071 | - require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; |
|
2069 | + if ($tab == 'widgets') |
|
2070 | + { |
|
2071 | + require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; |
|
2072 | 2072 | |
2073 | 2073 | $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); |
2074 | 2074 | |
@@ -2076,260 +2076,260 @@ discard block |
||
2076 | 2076 | { |
2077 | 2077 | if (! empty($widget)) |
2078 | 2078 | { |
2079 | - foreach ($widgets as $widget) |
|
2080 | - { |
|
2081 | - $pathtofile = $widget['relpath']; |
|
2082 | - |
|
2083 | - print '<span class="fa fa-file"></span> '.$langs->trans("WidgetFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2084 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2085 | - print '<br>'; |
|
2086 | - } |
|
2087 | - } |
|
2088 | - else |
|
2089 | - { |
|
2090 | - print $langs->trans("NoWidget"); |
|
2091 | - } |
|
2079 | + foreach ($widgets as $widget) |
|
2080 | + { |
|
2081 | + $pathtofile = $widget['relpath']; |
|
2082 | + |
|
2083 | + print '<span class="fa fa-file"></span> '.$langs->trans("WidgetFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2084 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2085 | + print '<br>'; |
|
2086 | + } |
|
2087 | + } |
|
2088 | + else |
|
2089 | + { |
|
2090 | + print $langs->trans("NoWidget"); |
|
2091 | + } |
|
2092 | 2092 | } |
2093 | 2093 | else |
2094 | 2094 | { |
2095 | - $fullpathoffile=dol_buildpath($file, 0); |
|
2096 | - |
|
2097 | - $content = file_get_contents($fullpathoffile); |
|
2098 | - |
|
2099 | - // New module |
|
2100 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2101 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2102 | - print '<input type="hidden" name="action" value="savefile">'; |
|
2103 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2104 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2105 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2106 | - |
|
2107 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2108 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2109 | - print '<br>'; |
|
2110 | - print '<center>'; |
|
2111 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2112 | - print ' '; |
|
2113 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2114 | - print '</center>'; |
|
2115 | - |
|
2116 | - print '</form>'; |
|
2095 | + $fullpathoffile=dol_buildpath($file, 0); |
|
2096 | + |
|
2097 | + $content = file_get_contents($fullpathoffile); |
|
2098 | + |
|
2099 | + // New module |
|
2100 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2101 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2102 | + print '<input type="hidden" name="action" value="savefile">'; |
|
2103 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2104 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2105 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2106 | + |
|
2107 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2108 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2109 | + print '<br>'; |
|
2110 | + print '<center>'; |
|
2111 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2112 | + print ' '; |
|
2113 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2114 | + print '</center>'; |
|
2115 | + |
|
2116 | + print '</form>'; |
|
2117 | 2117 | } |
2118 | - } |
|
2118 | + } |
|
2119 | 2119 | |
2120 | - if ($tab == 'cron') |
|
2121 | - { |
|
2122 | - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
2120 | + if ($tab == 'cron') |
|
2121 | + { |
|
2122 | + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; |
|
2123 | 2123 | |
2124 | - $cronjobs = $moduleobj->cronjobs; |
|
2124 | + $cronjobs = $moduleobj->cronjobs; |
|
2125 | 2125 | |
2126 | - if ($action != 'editfile' || empty($file)) |
|
2127 | - { |
|
2128 | - print $langs->trans("CronJobDefDesc", '<a href="'.DOL_URL_ROOT.'/cron/list.php?status=-2">'.$langs->trans('CronList').'</a>').'<br>'; |
|
2129 | - print '<br>'; |
|
2126 | + if ($action != 'editfile' || empty($file)) |
|
2127 | + { |
|
2128 | + print $langs->trans("CronJobDefDesc", '<a href="'.DOL_URL_ROOT.'/cron/list.php?status=-2">'.$langs->trans('CronList').'</a>').'<br>'; |
|
2129 | + print '<br>'; |
|
2130 | 2130 | |
2131 | - print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2132 | - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2133 | - print '<br>'; |
|
2131 | + print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>'; |
|
2132 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
|
2133 | + print '<br>'; |
|
2134 | 2134 | |
2135 | - print '<br>'; |
|
2136 | - print load_fiche_titre($langs->trans("CronJobProfiles"), '', ''); |
|
2135 | + print '<br>'; |
|
2136 | + print load_fiche_titre($langs->trans("CronJobProfiles"), '', ''); |
|
2137 | + |
|
2138 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2139 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2140 | + print '<input type="hidden" name="action" value="addproperty">'; |
|
2141 | + print '<input type="hidden" name="tab" value="objects">'; |
|
2142 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2143 | + print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
2144 | + |
|
2145 | + print '<div class="div-table-responsive">'; |
|
2146 | + print '<table class="noborder">'; |
|
2147 | + |
|
2148 | + print '<tr class="liste_titre">'; |
|
2149 | + print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2150 | + print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); |
|
2151 | + print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); |
|
2152 | + print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2153 | + print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2154 | + print "</tr>\n"; |
|
2155 | + |
|
2156 | + if (count($cronjobs)) |
|
2157 | + { |
|
2158 | + foreach ($cronjobs as $cron) |
|
2159 | + { |
|
2160 | + print '<tr class="oddeven">'; |
|
2161 | + |
|
2162 | + print '<td>'; |
|
2163 | + print $cron['label']; |
|
2164 | + print '</td>'; |
|
2165 | + |
|
2166 | + print '<td>'; |
|
2167 | + if ($cron['jobtype']=='method') |
|
2168 | + { |
|
2169 | + $text=$langs->trans("CronClass"); |
|
2170 | + $texttoshow=$langs->trans('CronModule').': '.$module.'<br>'; |
|
2171 | + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>'; |
|
2172 | + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>'; |
|
2173 | + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; |
|
2174 | + $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters']; |
|
2175 | + $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); |
|
2176 | + } |
|
2177 | + elseif ($cron['jobtype']=='command') |
|
2178 | + { |
|
2179 | + $text=$langs->trans('CronCommand'); |
|
2180 | + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); |
|
2181 | + $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters']; |
|
2182 | + $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); |
|
2183 | + } |
|
2184 | + print $form->textwithpicto($text, $texttoshow, 1); |
|
2185 | + print '</td>'; |
|
2186 | + |
|
2187 | + print '<td>'; |
|
2188 | + if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); |
|
2189 | + if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); |
|
2190 | + if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); |
|
2191 | + if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); |
|
2192 | + print '</td>'; |
|
2193 | + |
|
2194 | + print '<td>'; |
|
2195 | + print $cron['status']; |
|
2196 | + print '</td>'; |
|
2197 | + |
|
2198 | + print '<td>'; |
|
2199 | + if (!empty($cron['comment'])) {print $cron['comment'];} |
|
2200 | + print '</td>'; |
|
2201 | + |
|
2202 | + print '</tr>'; |
|
2203 | + } |
|
2204 | + } |
|
2205 | + else |
|
2206 | + { |
|
2207 | + print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>'; |
|
2208 | + } |
|
2137 | 2209 | |
2138 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2139 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2140 | - print '<input type="hidden" name="action" value="addproperty">'; |
|
2141 | - print '<input type="hidden" name="tab" value="objects">'; |
|
2142 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2143 | - print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">'; |
|
2210 | + print '</table>'; |
|
2211 | + print '</div>'; |
|
2144 | 2212 | |
2145 | - print '<div class="div-table-responsive">'; |
|
2146 | - print '<table class="noborder">'; |
|
2213 | + print '</form>'; |
|
2214 | + } |
|
2215 | + else |
|
2216 | + { |
|
2217 | + $fullpathoffile=dol_buildpath($file, 0); |
|
2147 | 2218 | |
2148 | - print '<tr class="liste_titre">'; |
|
2149 | - print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2150 | - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); |
|
2151 | - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); |
|
2152 | - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2153 | - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); |
|
2154 | - print "</tr>\n"; |
|
2219 | + $content = file_get_contents($fullpathoffile); |
|
2155 | 2220 | |
2156 | - if (count($cronjobs)) |
|
2157 | - { |
|
2158 | - foreach ($cronjobs as $cron) |
|
2159 | - { |
|
2160 | - print '<tr class="oddeven">'; |
|
2221 | + // New module |
|
2222 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2223 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2224 | + print '<input type="hidden" name="action" value="savefile">'; |
|
2225 | + print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2226 | + print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2227 | + print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2161 | 2228 | |
2162 | - print '<td>'; |
|
2163 | - print $cron['label']; |
|
2164 | - print '</td>'; |
|
2229 | + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2230 | + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2231 | + print '<br>'; |
|
2232 | + print '<center>'; |
|
2233 | + print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2234 | + print ' '; |
|
2235 | + print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2236 | + print '</center>'; |
|
2165 | 2237 | |
2166 | - print '<td>'; |
|
2167 | - if ($cron['jobtype']=='method') |
|
2168 | - { |
|
2169 | - $text=$langs->trans("CronClass"); |
|
2170 | - $texttoshow=$langs->trans('CronModule').': '.$module.'<br>'; |
|
2171 | - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>'; |
|
2172 | - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>'; |
|
2173 | - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; |
|
2174 | - $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters']; |
|
2175 | - $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); |
|
2176 | - } |
|
2177 | - elseif ($cron['jobtype']=='command') |
|
2178 | - { |
|
2179 | - $text=$langs->trans('CronCommand'); |
|
2180 | - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); |
|
2181 | - $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters']; |
|
2182 | - $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); |
|
2183 | - } |
|
2184 | - print $form->textwithpicto($text, $texttoshow, 1); |
|
2185 | - print '</td>'; |
|
2238 | + print '</form>'; |
|
2239 | + } |
|
2240 | + } |
|
2186 | 2241 | |
2187 | - print '<td>'; |
|
2188 | - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); |
|
2189 | - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); |
|
2190 | - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); |
|
2191 | - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); |
|
2192 | - print '</td>'; |
|
2242 | + if ($tab == 'buildpackage') |
|
2243 | + { |
|
2244 | + if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) |
|
2245 | + { |
|
2246 | + print img_warning().' '.$langs->trans("ErrNoZipEngine"); |
|
2247 | + print '<br>'; |
|
2248 | + } |
|
2193 | 2249 | |
2194 | - print '<td>'; |
|
2195 | - print $cron['status']; |
|
2196 | - print '</td>'; |
|
2250 | + $modulelowercase=strtolower($module); |
|
2197 | 2251 | |
2198 | - print '<td>'; |
|
2199 | - if (!empty($cron['comment'])) {print $cron['comment'];} |
|
2200 | - print '</td>'; |
|
2252 | + // Zip file to build |
|
2253 | + $FILENAMEZIP=''; |
|
2201 | 2254 | |
2202 | - print '</tr>'; |
|
2203 | - } |
|
2204 | - } |
|
2205 | - else |
|
2206 | - { |
|
2207 | - print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>'; |
|
2208 | - } |
|
2255 | + // Load module |
|
2256 | + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
2257 | + $class='mod'.$module; |
|
2209 | 2258 | |
2210 | - print '</table>'; |
|
2211 | - print '</div>'; |
|
2259 | + if (class_exists($class)) |
|
2260 | + { |
|
2261 | + try { |
|
2262 | + $moduleobj = new $class($db); |
|
2263 | + } |
|
2264 | + catch(Exception $e) |
|
2265 | + { |
|
2266 | + $error++; |
|
2267 | + dol_print_error($e->getMessage()); |
|
2268 | + } |
|
2269 | + } |
|
2270 | + else |
|
2271 | + { |
|
2272 | + $error++; |
|
2273 | + $langs->load("errors"); |
|
2274 | + dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); |
|
2275 | + exit; |
|
2276 | + } |
|
2212 | 2277 | |
2213 | - print '</form>'; |
|
2214 | - } |
|
2215 | - else |
|
2216 | - { |
|
2217 | - $fullpathoffile=dol_buildpath($file, 0); |
|
2218 | - |
|
2219 | - $content = file_get_contents($fullpathoffile); |
|
2220 | - |
|
2221 | - // New module |
|
2222 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
2223 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
2224 | - print '<input type="hidden" name="action" value="savefile">'; |
|
2225 | - print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">'; |
|
2226 | - print '<input type="hidden" name="tab" value="'.$tab.'">'; |
|
2227 | - print '<input type="hidden" name="module" value="'.$module.'">'; |
|
2228 | - |
|
2229 | - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); |
|
2230 | - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); |
|
2231 | - print '<br>'; |
|
2232 | - print '<center>'; |
|
2233 | - print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; |
|
2234 | - print ' '; |
|
2235 | - print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; |
|
2236 | - print '</center>'; |
|
2278 | + $arrayversion=explode('.',$moduleobj->version,3); |
|
2279 | + if (count($arrayversion)) |
|
2280 | + { |
|
2281 | + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; |
|
2282 | + $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; |
|
2237 | 2283 | |
2238 | - print '</form>'; |
|
2239 | - } |
|
2240 | - } |
|
2241 | - |
|
2242 | - if ($tab == 'buildpackage') |
|
2243 | - { |
|
2244 | - if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) |
|
2245 | - { |
|
2246 | - print img_warning().' '.$langs->trans("ErrNoZipEngine"); |
|
2247 | - print '<br>'; |
|
2248 | - } |
|
2249 | - |
|
2250 | - $modulelowercase=strtolower($module); |
|
2251 | - |
|
2252 | - // Zip file to build |
|
2253 | - $FILENAMEZIP=''; |
|
2254 | - |
|
2255 | - // Load module |
|
2256 | - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); |
|
2257 | - $class='mod'.$module; |
|
2258 | - |
|
2259 | - if (class_exists($class)) |
|
2260 | - { |
|
2261 | - try { |
|
2262 | - $moduleobj = new $class($db); |
|
2263 | - } |
|
2264 | - catch(Exception $e) |
|
2265 | - { |
|
2266 | - $error++; |
|
2267 | - dol_print_error($e->getMessage()); |
|
2268 | - } |
|
2269 | - } |
|
2270 | - else |
|
2271 | - { |
|
2272 | - $error++; |
|
2273 | - $langs->load("errors"); |
|
2274 | - dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); |
|
2275 | - exit; |
|
2276 | - } |
|
2277 | - |
|
2278 | - $arrayversion=explode('.',$moduleobj->version,3); |
|
2279 | - if (count($arrayversion)) |
|
2280 | - { |
|
2281 | - $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; |
|
2282 | - $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; |
|
2283 | - |
|
2284 | - $FILENAMEDOC=$modulelowercase.'.html'; |
|
2285 | - $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; |
|
2286 | - } |
|
2287 | - |
|
2288 | - print '<br>'; |
|
2289 | - |
|
2290 | - print '<span class="fa fa-file"></span> '. $langs->trans("PathToModulePackage") . ' : '; |
|
2291 | - if (! dol_is_file($outputfilezip)) print '<strong>'.$langs->trans("FileNotYetGenerated").'</strong>'; |
|
2292 | - else { |
|
2293 | - $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; |
|
2294 | - print '<strong><a href="'.DOL_URL_ROOT.'/document.php?modulepart=packages&file='.urlencode($relativepath).'">'.$outputfilezip.'</a></strong>'; |
|
2295 | - print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; |
|
2296 | - } |
|
2297 | - print '</strong><br>'; |
|
2298 | - |
|
2299 | - print '<br>'; |
|
2300 | - |
|
2301 | - print '<form name="generatepackage">'; |
|
2302 | - print '<input type="hidden" name="action" value="generatepackage">'; |
|
2303 | - print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; |
|
2304 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2305 | - print '<input type="submit" class="button" name="generatepackage" value="'.$langs->trans("BuildPackage").'">'; |
|
2306 | - print '</form>'; |
|
2307 | - |
|
2308 | - print '<br><br><br>'; |
|
2309 | - |
|
2310 | - print '<span class="fa fa-file"></span> '. $langs->trans("PathToModuleDocumentation") . ' : '; |
|
2311 | - if (! dol_is_file($outputfiledoc)) print '<strong>'.$langs->trans("FileNotYetGenerated").'</strong>'; |
|
2312 | - else { |
|
2313 | - print '<strong>'.$outputfiledoc.'</strong>'; |
|
2314 | - print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; |
|
2315 | - } |
|
2316 | - print '</strong><br>'; |
|
2317 | - |
|
2318 | - print '<br>'; |
|
2319 | - |
|
2320 | - print '<form name="generatedoc">'; |
|
2321 | - print '<input type="hidden" name="action" value="generatedoc">'; |
|
2322 | - print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; |
|
2323 | - print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2324 | - print '<input type="submit" class="button" name="generatedoc" value="'.$langs->trans("BuildDocumentation").'">'; |
|
2325 | - print '</form>'; |
|
2326 | - } |
|
2327 | - |
|
2328 | - if ($tab != 'description') |
|
2329 | - { |
|
2330 | - dol_fiche_end(); |
|
2331 | - } |
|
2332 | - } |
|
2284 | + $FILENAMEDOC=$modulelowercase.'.html'; |
|
2285 | + $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; |
|
2286 | + } |
|
2287 | + |
|
2288 | + print '<br>'; |
|
2289 | + |
|
2290 | + print '<span class="fa fa-file"></span> '. $langs->trans("PathToModulePackage") . ' : '; |
|
2291 | + if (! dol_is_file($outputfilezip)) print '<strong>'.$langs->trans("FileNotYetGenerated").'</strong>'; |
|
2292 | + else { |
|
2293 | + $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; |
|
2294 | + print '<strong><a href="'.DOL_URL_ROOT.'/document.php?modulepart=packages&file='.urlencode($relativepath).'">'.$outputfilezip.'</a></strong>'; |
|
2295 | + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; |
|
2296 | + } |
|
2297 | + print '</strong><br>'; |
|
2298 | + |
|
2299 | + print '<br>'; |
|
2300 | + |
|
2301 | + print '<form name="generatepackage">'; |
|
2302 | + print '<input type="hidden" name="action" value="generatepackage">'; |
|
2303 | + print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; |
|
2304 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2305 | + print '<input type="submit" class="button" name="generatepackage" value="'.$langs->trans("BuildPackage").'">'; |
|
2306 | + print '</form>'; |
|
2307 | + |
|
2308 | + print '<br><br><br>'; |
|
2309 | + |
|
2310 | + print '<span class="fa fa-file"></span> '. $langs->trans("PathToModuleDocumentation") . ' : '; |
|
2311 | + if (! dol_is_file($outputfiledoc)) print '<strong>'.$langs->trans("FileNotYetGenerated").'</strong>'; |
|
2312 | + else { |
|
2313 | + print '<strong>'.$outputfiledoc.'</strong>'; |
|
2314 | + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; |
|
2315 | + } |
|
2316 | + print '</strong><br>'; |
|
2317 | + |
|
2318 | + print '<br>'; |
|
2319 | + |
|
2320 | + print '<form name="generatedoc">'; |
|
2321 | + print '<input type="hidden" name="action" value="generatedoc">'; |
|
2322 | + print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; |
|
2323 | + print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
|
2324 | + print '<input type="submit" class="button" name="generatedoc" value="'.$langs->trans("BuildDocumentation").'">'; |
|
2325 | + print '</form>'; |
|
2326 | + } |
|
2327 | + |
|
2328 | + if ($tab != 'description') |
|
2329 | + { |
|
2330 | + dol_fiche_end(); |
|
2331 | + } |
|
2332 | + } |
|
2333 | 2333 | } |
2334 | 2334 | |
2335 | 2335 | dol_fiche_end(); // End modules |