N°865: exports (csv, xslx, pdf) LocalizeOutput option lost

- it happens when the export has more thant one chunk, stating the 2d chunk.
- this option is now persisted and restored on each chunk

SVN:trunk[5771]
This commit is contained in:
Bruno Da Silva
2018-05-04 12:49:27 +00:00
parent 7bdad90564
commit 1063697e85

View File

@@ -73,6 +73,8 @@ class BulkExportResult extends DBObject
MetaModel::Init_AddAttribute(new AttributeString("temp_file_path", array("allowed_values"=>null, "sql"=>"temp_file_path", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeString("temp_file_path", array("allowed_values"=>null, "sql"=>"temp_file_path", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLongText("search", array("allowed_values"=>null, "sql"=>"search", "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeLongText("search", array("allowed_values"=>null, "sql"=>"search", "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLongText("status_info", array("allowed_values"=>null, "sql"=>"status_info", "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeLongText("status_info", array("allowed_values"=>null, "sql"=>"status_info", "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBoolean("localize_output", array("allowed_values"=>null, "sql"=>"localize_output", "default_value"=>true, "is_null_allowed"=>true, "depends_on"=>array())));
} }
/** /**
@@ -152,12 +154,15 @@ abstract class BulkExport
$this->bLocalizeOutput = false; $this->bLocalizeOutput = false;
} }
/** /**
* Find the first class capable of exporting the data in the given format * Find the first class capable of exporting the data in the given format
* @param string $sFormatCode The lowercase format (e.g. html, csv, spreadsheet, xlsx, xml, json, pdf...) *
* @param DBSearch $oSearch The search/filter defining the set of objects to export or null when listing the supported formats * @param string $sFormatCode The lowercase format (e.g. html, csv, spreadsheet, xlsx, xml, json, pdf...)
* @return BulkExport|NULL * @param DBSearch $oSearch The search/filter defining the set of objects to export or null when listing the supported formats
*/ *
* @return BulkExport|null
* @throws ReflectionException
*/
static public function FindExporter($sFormatCode, $oSearch = null) static public function FindExporter($sFormatCode, $oSearch = null)
{ {
foreach(get_declared_classes() as $sPHPClass) foreach(get_declared_classes() as $sPHPClass)
@@ -179,11 +184,16 @@ abstract class BulkExport
return null; return null;
} }
/** /**
* Find the exporter corresponding to the given persistent token * Find the exporter corresponding to the given persistent token
* @param int $iPersistentToken The identifier of the BulkExportResult object storing the information *
* @return iBulkExport|NULL * @param int $iPersistentToken The identifier of the BulkExportResult object storing the information
*/ *
* @return iBulkExport|null
* @throws ArchivedObjectException
* @throws CoreException
* @throws ReflectionException
*/
static public function FindExporterFromToken($iPersistentToken = null) static public function FindExporterFromToken($iPersistentToken = null)
{ {
$oBulkExporter = null; $oBulkExporter = null;
@@ -200,6 +210,10 @@ abstract class BulkExport
$oBulkExporter->SetObjectList($oSearch); $oBulkExporter->SetObjectList($oSearch);
$oBulkExporter->SetChunkSize($oInfo->Get('chunk_size')); $oBulkExporter->SetChunkSize($oInfo->Get('chunk_size'));
$oBulkExporter->SetStatusInfo(json_decode($oInfo->Get('status_info'), true)); $oBulkExporter->SetStatusInfo(json_decode($oInfo->Get('status_info'), true));
$oBulkExporter->SetLocalizeOutput($oInfo->Get('localize_output'));
$oBulkExporter->sTmpFile = $oInfo->Get('temp_file_path'); $oBulkExporter->sTmpFile = $oInfo->Get('temp_file_path');
$oBulkExporter->oBulkExportResult = $oInfo; $oBulkExporter->oBulkExportResult = $oInfo;
} }
@@ -259,6 +273,14 @@ abstract class BulkExport
$this->iChunkSize = $iChunkSize; $this->iChunkSize = $iChunkSize;
} }
/**
* @param $bLocalizeOutput
*/
public function SetLocalizeOutput($bLocalizeOutput)
{
$this->bLocalizeOutput = $bLocalizeOutput;
}
/** /**
* (non-PHPdoc) * (non-PHPdoc)
* @see iBulkExport::SetObjectList() * @see iBulkExport::SetObjectList()
@@ -321,8 +343,9 @@ abstract class BulkExport
$this->oBulkExportResult->Set('format', $this->sFormatCode); $this->oBulkExportResult->Set('format', $this->sFormatCode);
$this->oBulkExportResult->Set('search', $this->oSearch->serialize()); $this->oBulkExportResult->Set('search', $this->oSearch->serialize());
$this->oBulkExportResult->Set('chunk_size', $this->iChunkSize); $this->oBulkExportResult->Set('chunk_size', $this->iChunkSize);
$this->oBulkExportResult->Set('temp_file_path', $this->sTmpFile); $this->oBulkExportResult->Set('temp_file_path', $this->sTmpFile);
} $this->oBulkExportResult->Set('localize_output', $this->bLocalizeOutput);
}
$this->oBulkExportResult->Set('status_info', json_encode($this->GetStatusInfo())); $this->oBulkExportResult->Set('status_info', json_encode($this->GetStatusInfo()));
utils::PushArchiveMode(false); utils::PushArchiveMode(false);
$ret = $this->oBulkExportResult->DBWrite(); $ret = $this->oBulkExportResult->DBWrite();