* [bug#123200,done,1h] add getFieldMap.
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
<?php
|
||||
global $config;
|
||||
$config->pivot = new stdclass();
|
||||
$config->pivot->widthInput = 128;
|
||||
$config->pivot->widthDate = 248;
|
||||
$config->pivot->objectTableFieldMap = array();
|
||||
$config->pivot->objectTableFieldMap['user.gender'] = array('module' => 'user', 'variable' => 'genderList');
|
||||
|
||||
if($config->edition != 'open')
|
||||
{
|
||||
$config->pivot->objectTableFieldMap['feedback.solution'] = array('module' => 'feedback', 'variable' => 'solutionList');
|
||||
}
|
||||
|
||||
$config->pivot->maxFeatureItem = 5;
|
||||
|
||||
|
||||
@@ -150,8 +150,8 @@ class pivot extends control
|
||||
$datas = $this->pivot->getDrillDatas($drill, $drillFields);
|
||||
|
||||
$result = $this->pivot->processColData($drill->object, $cols, $datas);
|
||||
$cols = $result['cols'];
|
||||
$datas = $result['data'];
|
||||
$cols = $result['cols'];
|
||||
$datas = $result['data'];
|
||||
|
||||
$this->view->cols = $cols;
|
||||
$this->view->datas = $datas;
|
||||
|
||||
+11
-2
@@ -2639,7 +2639,7 @@ class pivotModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processColData($object, $cols, $data)
|
||||
public function processColData(string $object, array $cols, array $data): array
|
||||
{
|
||||
$objectFieldMap = $this->config->pivot->objectTableFieldMap;
|
||||
foreach($cols as $field => $col)
|
||||
@@ -2647,12 +2647,21 @@ class pivotModel extends model
|
||||
$objectField = $object . '.' . $field;
|
||||
if(!isset($objectFieldMap[$objectField])) continue;
|
||||
|
||||
$fieldMap = $objectFieldMap[$objectField];
|
||||
$fieldMap = $this->getFieldMap($objectFieldMap[$objectField]);
|
||||
foreach($data as $index => $obj) $data[$index]->$field = zget($fieldMap, $obj->$field, $obj->$field);
|
||||
}
|
||||
|
||||
return array('cols' => $cols, 'data' => $data);
|
||||
}
|
||||
|
||||
public function getFieldMap(array $moduleAndVar)
|
||||
{
|
||||
$module = $moduleAndVar['module'];
|
||||
$variable = $moduleAndVar['variable'];
|
||||
$this->app->loadLang($module);
|
||||
|
||||
return $this->lang->$module->$variable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user