* Finish initFieldList.

This commit is contained in:
tanghucheng
2022-07-05 17:24:15 +08:00
parent 0eb70c1f5e
commit 030fa6d1bd
3 changed files with 174 additions and 49 deletions
+80 -40
View File
@@ -1,44 +1,84 @@
<?php
/**
* Export datas.
*
* @access public
* @return void
*/
public function export()
{
}
/**
* Export Template.
*
* @access public
* @return void
*/
public function exportTemplate()
{
}
/**
* Import.
*
* @access public
* @return void
*/
public function import()
{
}
/**
* Show Import datas .
*
* @access public
* @return void
*/
public function showImport()
class port extends control
{
/**
* Export datas.
*
* @access public
* @return void
*/
public function export($model = '', $params = '')
{
$fieldList = $this->initFieldList($model);
}
/**
* Init FieldList .
*
* @param int $model
* @access public
* @return void
*/
public function initFieldList($model)
{
$portFieldList = $this->config->port->fieldList;
$this->loadModel($model);
$fields = isset($this->config->$model->exportFields) ? $this->config->$model->exportFields : '';
if(empty($fields)) return false;
$fields = explode(',', $fields);
/* build module fieldList. */
foreach ($fields as $field)
{
$field = trim($field);
$modelFieldList = isset($this->config->$model->fieldList[$field]) ? $this->config->$model->fieldList[$field] : array();
foreach ($portFieldList as $portField => $value)
{
$funcName = 'init' . ucfirst($portField);
if(!array_key_exists($portField, $modelFieldList)) $modelFieldList[$portField] = $this->port->$funcName($model, $field);
}
$this->config->$model->fieldList[$field] = $modelFieldList;
}
a($this->config->$model->fieldList);
}
/**
* Export Template.
*
* @access public
* @return void
*/
public function exportTemplate()
{
}
/**
* Import.
*
* @access public
* @return void
*/
public function import()
{
}
/**
* Show Import datas .
*
* @access public
* @return void
*/
public function showImport()
{
}
}
+10 -9
View File
@@ -1,11 +1,12 @@
<?php
$lang->importexport = new stdclass();
$lang->port = new stdclass();
$lang->importexport->default->key['id'] = '编号';
$lang->importexport->default->key['type'] = '类型';
$lang->importexport->default->key['project'] = '所属项目';
$lang->importexport->default->key['execution'] = '所属执行';
$lang->importexport->default->key['product'] = '所属产品';
$lang->importexport->default->key['code'] = '代号';
$lang->importexport->default->key['name'] = '名称';
$lang->importexport->default->key['title'] = '标题';
$lang->port->reservedWord['id'] = '编号';
$lang->port->reservedWord['type'] = '类型';
$lang->port->reservedWord['project'] = '所属项目';
$lang->port->reservedWord['execution'] = '所属执行';
$lang->port->reservedWord['product'] = '所属产品';
$lang->port->reservedWord['code'] = '代号';
$lang->port->reservedWord['name'] = '名称';
$lang->port->reservedWord['title'] = '标题';
$lang->port->reservedWord['asdawdadw'] = '测试字段';
+84
View File
@@ -0,0 +1,84 @@
<?php
class portModel extends model
{
/**
* Init Title.
*
* @param int $model
* @param int $field
* @access public
* @return void
*/
public function initTitle($model, $field)
{
$title = $field;
$this->app->loadLang($model);
if(array_key_exists($field, $this->lang->$model))
{
$title = $this->lang->$model->$field;
}
elseif(array_key_exists($field . 'AB', $this->lang->$model))
{
$title = $this->lang->$model->$field . 'AB';
}
elseif(array_key_exists($field, $this->lang->port->reservedWord))
{
$title = $this->lang->port->reservedWord[$field];
}
return $title;
}
public function initWidth($model, $field)
{
return '120px';
}
public function initControl($model, $field)
{
return 'select';
}
public function initValues($model, $field)
{
return 'value';
}
public function initSort($model, $field)
{
return 'no';
}
/**
* Init Required.
*
* @param int $model
* @param int $field
* @access public
* @return void
*/
public function initRequired($model, $field)
{
if(empty($this->config->$model->create->requiredFields)) return 'no';
$requiredFields = "," . $this->config->$model->create->requiredFields . ",";
if(strpos($requiredFields, $field) !== false) return 'yes';
return 'no';
}
public function initFixed($model, $field)
{
return 'left';
}
public function initClass($model, $field)
{
return '';
}
}