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';
82$datatoimport =
GETPOST(
'datatoimport');
86$langs->load(
"exports");
89if (empty($datatoimport)) {
93 print
'<div class="error">Bad value for datatoimport.</div>';
99$filename = $langs->transnoentitiesnoconv(
"ExampleOfImportFile").
'_'.$datatoimport.
'.'.$format;
101$objimport =
new Import($db);
102$objimport->load_arrays($user, $datatoimport);
104$fieldstarget = $objimport->array_import_fields[0];
105$valuestarget = $objimport->array_import_examplevalues[0];
108if (GETPOSTISSET(
"attachment")) {
109 $attachment =
GETPOST(
"attachment");
113if (GETPOSTISSET(
"contenttype")) {
114 $contenttype =
GETPOST(
"contenttype");
117$outputencoding =
'UTF-8';
120 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
123 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
128$headerlinefields = array();
129$contentlinevalues = array();
131foreach ($fieldstarget as $code => $label) {
132 $withoutstar = preg_replace(
'/\*/',
'', $fieldstarget[$code]);
133 $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ?
'*' :
'').
' ('.$code.
')';
134 $contentlinevalues[] = (isset($valuestarget[$code]) ? $valuestarget[$code] :
'');
139print $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.