26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
53function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
55 print
'<html><title>Build an import example file</title><body>';
68function llxFooter($comment =
'', $zone =
'private', $disabledoutputofmessages = 0)
70 print
'</body></html>';
74require
'../main.inc.php';
75require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
76require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
77require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.class.php';
87$datatoimport =
GETPOST(
'datatoimport');
91$langs->load(
"exports");
94if (empty($datatoimport)) {
98 print
'<div class="error">Bad value for datatoimport.</div>';
104$filename = $langs->transnoentitiesnoconv(
"ExampleOfImportFile").
'_'.$datatoimport.
'.'.$format;
107$objimport->load_arrays($user, $datatoimport);
109$fieldstarget = $objimport->array_import_fields[0];
110$valuestarget = $objimport->array_import_examplevalues[0];
113if (GETPOSTISSET(
"attachment")) {
114 $attachment =
GETPOST(
"attachment");
117$contenttype = dol_mimetype($format);
118if (GETPOSTISSET(
"contenttype")) {
119 $contenttype =
GETPOST(
"contenttype");
122$outputencoding =
'UTF-8';
125 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
128 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
133$headerlinefields = array();
134$contentlinevalues = array();
136foreach ($fieldstarget as $code => $label) {
137 $withoutstar = preg_replace(
'/\*/',
'', $fieldstarget[$code]);
138 $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ?
'*' :
'').
' ('.$code.
')';
139 $contentlinevalues[] = (isset($valuestarget[$code]) ? $valuestarget[$code] :
'');
144print $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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
This file is a wrapper, so empty footer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.