Added extended useList options, including raw output
This commit is contained in:
parent
3c7968161a
commit
19c3c19a00
|
|
@ -538,7 +538,7 @@ class ImportExportController extends ControllerBehavior
|
||||||
|
|
||||||
protected function checkUseListExportMode()
|
protected function checkUseListExportMode()
|
||||||
{
|
{
|
||||||
if (!$listDefinition = $this->getConfig('export[useList]')) {
|
if (!$useList = $this->getConfig('export[useList]')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -546,6 +546,13 @@ class ImportExportController extends ControllerBehavior
|
||||||
throw new ApplicationException(Lang::get('backend::lang.import_export.behavior_missing_uselist_error'));
|
throw new ApplicationException(Lang::get('backend::lang.import_export.behavior_missing_uselist_error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_array($useList)) {
|
||||||
|
$listDefinition = array_get($useList, 'definition');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$listDefinition = $useList;
|
||||||
|
}
|
||||||
|
|
||||||
$this->exportFromList($listDefinition);
|
$this->exportFromList($listDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -594,12 +601,20 @@ class ImportExportController extends ControllerBehavior
|
||||||
/*
|
/*
|
||||||
* Add records
|
* Add records
|
||||||
*/
|
*/
|
||||||
|
$getter = $this->getConfig('export[useList][raw]', false)
|
||||||
|
? 'getColumnValueRaw'
|
||||||
|
: 'getColumnValue';
|
||||||
|
|
||||||
$model = $widget->prepareModel();
|
$model = $widget->prepareModel();
|
||||||
$results = $model->get();
|
$results = $model->get();
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$record = [];
|
$record = [];
|
||||||
foreach ($columns as $column) {
|
foreach ($columns as $column) {
|
||||||
$record[] = $widget->getColumnValue($result, $column);
|
$value = $widget->$getter($result, $column);
|
||||||
|
if (is_array($value)) {
|
||||||
|
$value = implode('|', $value);
|
||||||
|
}
|
||||||
|
$record[] = $value;
|
||||||
}
|
}
|
||||||
$csv->insertOne($record);
|
$csv->insertOne($record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -761,9 +761,10 @@ class Lists extends WidgetBase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up the column value
|
* Returns a raw column value
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getColumnValue($record, $column)
|
public function getColumnValueRaw($record, $column)
|
||||||
{
|
{
|
||||||
$columnName = $column->columnName;
|
$columnName = $column->columnName;
|
||||||
|
|
||||||
|
|
@ -810,6 +811,17 @@ class Lists extends WidgetBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a column value, with filters applied
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getColumnValue($record, $column)
|
||||||
|
{
|
||||||
|
$value = $this->getColumnValueRaw($record, $column);
|
||||||
|
|
||||||
if (method_exists($this, 'eval'. studly_case($column->type) .'TypeValue')) {
|
if (method_exists($this, 'eval'. studly_case($column->type) .'TypeValue')) {
|
||||||
$value = $this->{'eval'. studly_case($column->type) .'TypeValue'}($record, $column, $value);
|
$value = $this->{'eval'. studly_case($column->type) .'TypeValue'}($record, $column, $value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue