예제 #1
0
 public function action()
 {
     $id = $this->isG('id', '请选择要删除的数据!');
     $field = \Model\Field::findField($id);
     if (empty($field)) {
         $this->error('不存在的字段');
     }
     $removeFieldResult = \Model\Field::removeField($id);
     if (empty($removeFieldResult)) {
         $this->error('删除失败');
     }
     $model = \Model\ModelManage::findModel($field['field_model_id']);
     $alertTableFieldResult = \Model\Field::alertTableField($model['model_name'], $field['field_name']);
     if (empty($alertTableFieldResult)) {
         $log = new \Expand\Log();
         $failLog = "Delete Field: " . strtolower($model['model_name']) . "_{$field['field_name']}, Model:{$model['model_name']}  " . date("Y-m-d H:i:s");
         $log->creatLog('fieldError', $failLog);
         $this->error('移除数据库表字段失败,具体信息请查阅程序日志');
     }
     $this->success('删除成功');
 }
예제 #2
0
 /**
  * 删除字段
  */
 public function fieldAction()
 {
     $id = $this->isG('id', $GLOBALS['_LANG']['COMMON']['DELETE_ID']);
     $field = \Model\Field::findField($id);
     if (empty($field)) {
         $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_FIELD']);
     }
     $removeFieldResult = \Model\Field::removeField($id);
     if (empty($removeFieldResult)) {
         $this->error($GLOBALS['_LANG']['COMMON']['DELETE_ERROR']);
     }
     $model = \Model\Model::findModel($field['model_id']);
     $alertTableFieldResult = \Model\Field::alertTableField($model['model_name'], $field['field_name']);
     if (empty($alertTableFieldResult)) {
         $log = new \Expand\Log();
         $failLog = "Delete Field: " . strtolower($model['model_name']) . "_{$field['field_name']}, Model:{$model['model_name']}  " . date("Y-m-d H:i:s");
         $log->creatLog('fieldError', $failLog);
         $this->error($GLOBALS['_LANG']['MODEL']['ALERT_TABLE_FIELD_ERROR']);
     }
     $this->success($GLOBALS['_LANG']['COMMON']['DELETE_SUCCESS']);
 }
예제 #3
0
 /**
  * 字段添加/编辑
  */
 public function fieldAction()
 {
     $fieldId = $this->g('id');
     $modelId = $this->isG('model', '请选择模型');
     $model = \Model\ModelManage::findModel($modelId);
     if (empty($fieldId)) {
         $this->assign('method', 'POST');
         $this->assign('title', "添加字段 - {$model['lang_key']}");
     } else {
         $field = \Model\Field::findField($fieldId);
         if (empty($field)) {
             $this->error('不存在的字段');
         }
         $this->assign($field);
         $this->assign('method', 'PUT');
         $this->assign('title', "编辑字段 - {$model['lang_key']}");
     }
     $fieldTypeOption = \Model\Option::findOption('fieldType');
     $this->assign('fieldTypeList', json_decode($fieldTypeOption['value'], true));
     $this->assign('modelId', $modelId);
     $this->layout();
 }
예제 #4
0
 /**
  * 字段添加/编辑
  */
 public function fieldAction()
 {
     $fieldId = $this->g('id');
     $modelId = $this->isG('model', $GLOBALS['_LANG']['MODEL']['SELECT_MODEL_ID']);
     $model = \Model\Model::findModel($modelId);
     if (empty($fieldId)) {
         $this->assign('method', 'POST');
         $this->assign('title', $GLOBALS['_LANG']['MODEL']['FIELD_ADD'] . " - {$model['lang_key']}");
     } else {
         $field = \Model\Field::findField($fieldId);
         if (empty($field)) {
             $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_FIELD']);
         }
         $this->assign($field);
         $this->assign('method', 'PUT');
         $this->assign('title', "{$GLOBALS['_LANG']['MODEL']['FIELD_EDIT']} - {$model['lang_key']}");
     }
     $fieldTypeOption = \Model\Option::findOption('fieldType');
     $this->assign('fieldTypeList', json_decode($fieldTypeOption['value'], true));
     $this->assign('modelId', $modelId);
     $this->layout();
 }