25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL',
'1');
50function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
52 print
'<html><title>Build an import example file</title><body>';
63function llxFooter($comment =
'', $zone =
'private', $disabledoutputofmessages = 0)
65 print
'</body></html>';
69require
'../main.inc.php';
70require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
71require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
72require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.php';
74$datatoimport =
GETPOST(
'datatoimport');
78$langs->load(
"exports");
81if (empty($datatoimport)) {
85 print
'<div class="error">Bad value for datatoimport.</div>';
91$filename = $langs->transnoentitiesnoconv(
"ExampleOfImportFile").
'_'.$datatoimport.
'.'.$format;
93$objimport =
new Import($db);
94$objimport->load_arrays($user, $datatoimport);
96$fieldstarget = $objimport->array_import_fields[0];
97$valuestarget = $objimport->array_import_examplevalues[0];
100if (GETPOSTISSET(
"attachment")) {
101 $attachment =
GETPOST(
"attachment");
105if (GETPOSTISSET(
"contenttype")) {
106 $contenttype =
GETPOST(
"contenttype");
109$outputencoding =
'UTF-8';
112 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
115 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
120$headerlinefields = array();
121$contentlinevalues = array();
123foreach ($fieldstarget as $code => $label) {
124 $withoutstar = preg_replace(
'/\*/',
'', $fieldstarget[$code]);
125 $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ?
'*' :
'').
' ('.$code.
')';
126 $contentlinevalues[] = (isset($valuestarget[$code]) ? $valuestarget[$code] :
'');
131print $objimport->build_example_file($format, $headerlinefields, $contentlinevalues, $datatoimport);
if(!defined( 'NOTOKENRENEWAL')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
This file is a wrapper, so empty header.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.