mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 02:42:33 +01:00
Fix translation of label in export
This commit is contained in:
@@ -77,7 +77,7 @@ class ExportTsv extends ModeleExports
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
$this->db = $db;
|
||||
|
||||
$this->id = 'tsv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
@@ -218,8 +218,6 @@ class ExportTsv extends ModeleExports
|
||||
public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
|
||||
{
|
||||
// phpcs:enable
|
||||
$outputlangs->charset_output = getDolGlobalString('EXPORT_TSV_FORCE_CHARSET');
|
||||
|
||||
$selectlabel = array();
|
||||
foreach ($array_selected_sorted as $code => $value) {
|
||||
if (strpos($code, ' as ') == 0) {
|
||||
@@ -232,8 +230,12 @@ class ExportTsv extends ModeleExports
|
||||
continue;
|
||||
}
|
||||
|
||||
$newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
|
||||
$newvalue = $this->tsv_clean($newvalue, $outputlangs->charset_output);
|
||||
$newvalue = $array_export_fields_label[$code];
|
||||
if ($newvalue) {
|
||||
$newvalue = $outputlangs->transnoentitiesnoconv($newvalue);
|
||||
}
|
||||
|
||||
$newvalue = $this->tsv_clean($newvalue, getDolGlobalString('EXPORT_TSV_FORCE_CHARSET'));
|
||||
|
||||
fwrite($this->handle, $newvalue.$this->separator);
|
||||
$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
|
||||
@@ -347,9 +349,17 @@ class ExportTsv extends ModeleExports
|
||||
* @param string $charset Input AND Output character set
|
||||
* @return string Value cleaned
|
||||
*/
|
||||
public function tsv_clean($newvalue, $charset)
|
||||
public function tsv_clean($newvalue, $charset = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if (empty($charset)) {
|
||||
$charset = getDolGlobalString('EXPORT_TSV_FORCE_CHARSET');
|
||||
}
|
||||
|
||||
$newvalue = $langs->convToOutputCharset($newvalue, 'UTF-8', $charset); // newvalue is now encoded into $charset
|
||||
|
||||
|
||||
// Rule Dolibarr: No HTML
|
||||
$newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
|
||||
|
||||
@@ -194,8 +194,6 @@ class ExportCsv extends ModeleExports
|
||||
public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
|
||||
{
|
||||
// phpcs:enable
|
||||
$outputlangs->charset_output = getDolGlobalString('EXPORT_CSV_FORCE_CHARSET');
|
||||
|
||||
$selectlabel = array();
|
||||
foreach ($array_selected_sorted as $code => $value) {
|
||||
if (strpos($code, ' as ') == 0) {
|
||||
@@ -209,10 +207,13 @@ class ExportCsv extends ModeleExports
|
||||
}
|
||||
|
||||
$newvalue = $array_export_fields_label[$code];
|
||||
if ($newvalue) {
|
||||
$newvalue = $outputlangs->transnoentitiesnoconv($newvalue);
|
||||
}
|
||||
|
||||
// Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES)
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$newvalue = csvClean($newvalue, $outputlangs->charset_output, $this->separator);
|
||||
$newvalue = csvClean($newvalue, getDolGlobalString('EXPORT_CSV_FORCE_CHARSET'), $this->separator);
|
||||
|
||||
fwrite($this->handle, $newvalue.$this->separator);
|
||||
$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
|
||||
|
||||
@@ -80,7 +80,7 @@ class Export
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $array_export_label = array(); // Tableau de "libelle de lots"
|
||||
public $array_export_label = array(); // Array of "Translation key" to use for each export profile
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
@@ -117,7 +117,7 @@ class Export
|
||||
/**
|
||||
* @var array<array<array{rule:string,file:string,classfile:string,class:string,method:string,method_params:string[]}>>
|
||||
*/
|
||||
public $array_export_special = array(); // array of special operations to do on field
|
||||
public $array_export_special = array(); // array of special operations to do on fields
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
@@ -269,13 +269,13 @@ class Export
|
||||
$this->array_export_perms[$i] = $bool;
|
||||
// Icon
|
||||
$this->array_export_icon[$i] = (isset($module->export_icon[$r]) ? $module->export_icon[$r] : $module->picto);
|
||||
// Code of the export dataset / Code du dataset export
|
||||
// Code of the export dataset
|
||||
$this->array_export_code[$i] = $module->export_code[$r];
|
||||
// Define a key for sort
|
||||
$this->array_export_code_for_sort[$i] = $module->module_position.'_'.$module->export_code[$r]; // Add a key into the module
|
||||
// Export Dataset Label / Libelle du dataset export
|
||||
// Export Dataset Label
|
||||
$this->array_export_label[$i] = $module->getExportDatasetLabel($r);
|
||||
// Table of fields to export / Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
// Table of fields to export
|
||||
$this->array_export_fields[$i] = $module->export_fields_array[$r];
|
||||
// Table of fields to be filtered (key=field, value1=data type) Verifies that the module has filters
|
||||
$this->array_export_TypeFields[$i] = (isset($module->export_TypeFields_array[$r]) ? $module->export_TypeFields_array[$r] : '');
|
||||
@@ -283,7 +283,7 @@ class Export
|
||||
$this->array_export_entities[$i] = $module->export_entities_array[$r];
|
||||
// Table of entities requiring to abandon DISTINCT (key=entity, valeur=field id child records)
|
||||
$this->array_export_dependencies[$i] = (!empty($module->export_dependencies_array[$r]) ? $module->export_dependencies_array[$r] : '');
|
||||
// Table of special field operations / Tableau des operations speciales sur champ
|
||||
// Table of special field operations
|
||||
$this->array_export_special[$i] = (!empty($module->export_special_array[$r]) ? $module->export_special_array[$r] : '');
|
||||
// Array of examples
|
||||
$this->array_export_examplevalues[$i] = (!empty($module->export_examplevalues_array[$r]) ? $module->export_examplevalues_array[$r] : null);
|
||||
|
||||
@@ -149,6 +149,7 @@ $entitytolang = array(
|
||||
'inventory_line' => 'InventoryLine'
|
||||
);
|
||||
|
||||
|
||||
$array_selected = isset($_SESSION["export_selected_fields"]) ? $_SESSION["export_selected_fields"] : array();
|
||||
$array_filtervalue = isset($_SESSION["export_filtered_fields"]) ? $_SESSION["export_filtered_fields"] : array();
|
||||
$datatoexport = GETPOST("datatoexport", "aZ09");
|
||||
@@ -163,6 +164,7 @@ $field = GETPOST("field", "alpha");
|
||||
$objexport = new Export($db);
|
||||
$objexport->load_arrays($user, $datatoexport);
|
||||
|
||||
|
||||
$objmodelexport = new ModeleExports($db);
|
||||
$form = new Form($db);
|
||||
$htmlother = new FormOther($db);
|
||||
|
||||
Reference in New Issue
Block a user