正文开始 这里没有高深的技术,只是很简洁的代码。 //提交: 添加/修改 分类 case 'modify_class': $t_id = $this->getOption('t_id', 0, 'trim'); //分类ID $modify = $this->getOption('modify'); //编辑方式 $t_root = $this->getOption('t_root', 0, 'trim'); //父分类id $t_typename = $this->getOption('t_typename', 0, 'trim'); //新分类名字 if(!$t_typename) { return message::getMsgJson('0065');//缺少数据id } if($modify == 'edit' && !$t_id) { return message::getMsgJson('0065');//缺少数据id } $t_typename = urldecode($t_typename); $newData = array( 't_typename' => $t_typename, 't_root' => $t_root ); if($modify == 'edit') { if($db->update("scs_helptype", $t_id, $newData, 't_id')) { return message::getMsgJson('0043');//返回‘修改成功’ } else { return message::getMsgJson('0044');//返回‘修改失败’ } } else if ($modify == 'add') { if($db->InsertRecord('scs_helptype',$newData)) { return message::getMsgJson('0113');//返回‘添加成功’ } else { return message::getMsgJson('0114');//返回‘添加失败’ } } break; //模版输出: 添加 修改 case 'modify_question': $modify = $this->getOption('modify'); //所有分类 $allTypeData = ask::getAllType($db); $allTypeArray = str::makeTreesData($allTypeData, 't_id', 't_title', 't_root', $canNull=false); $newTypeData = []; foreach($allTypeArray as $n => $v) { if($n == 0) { unset($allTypeArray[$n]); continue; } $newTypeData[ask::getTypeName($n)] = $v; } if($modify == 'add') { $arr = array( 'q_number' => 0, 'q_multi_answer' => 0, 'q_title' => '', 'q_type_id2' => 0, 'q_need_audit' => 0, 'allTypeArray' => json_encode($newTypeData), 'q_content' => '', 'q_content_hide' => '', 'modify' => $modify, ); } else { $q_number = $this->getOption('q_number'); if(!$q_number) { message::Show(message::getMessage('0065'));//缺少数据id exit; } $questionsInfo = $db->getOne('c_questions', 'q_id,q_number,q_title,q_type_id2,q_adduid,q_multi_answer,q_need_audit,q_status,q_content,q_content_hide ', "q_number='{$q_number}'"); if(!$questionsInfo) { message::Show('问题不存在'); exit; } if($questionsInfo['q_adduid'] != $userid) { message::Show('您身份已经切换,请刷新'); exit; } if($questionsInfo['q_status'] != ask::$questionFirstStatus) { message::Show('需求已启动 不能再编辑,返回'); exit; } $arr = $questionsInfo; $arr2 = array( 'modify' => $modify, 'allTypeArray' => json_encode($newTypeData), ); $arr = array_merge($arr, $arr2); } $htmlname = 'manage/question/f_modify_question.php'; break; 正文结束 |
PHP接口(interface)和抽象类(abstract) | php正则复习总结 |