/** * @param string $key * @throws Exception */ static function save_md_data($key) { if (!isset(self::$_action_list[$key])) { self::_error_and_redirect('不存在此页', '/'); } $actions = self::$_action_list[$key]; $content = Lib_Request::post_var('content'); if (trim($content) == '') { Lib_Request::flash('error', '提交内容为空'); Module_HttpRequest_Router::redirect_to($actions[self::URL]); } $keyword = $actions[self::KEYWORD]; $model_option = new Model_Option(); $content = str_replace("\r", '', $content); $content = str_replace("\n", '\\n', $content); //$content = htmlentities($content); $result = $model_option->update_option_by_keyword($keyword, $content); if ($result['errno'] != Const_Err_Base::ERR_OK) { self::_error_and_redirect(Lib_Helper::format_err_struct($result), $actions[self::URL]); } else { $help2opcode = ['help_index' => Module_OperationRecord_Main::OPCODE_HELP_INFO, 'help_dev' => Module_OperationRecord_Main::OPCODE_HELP_DEVELOP, 'help_todo' => Module_OperationRecord_Main::OPCODE_HELP_TODO, 'internal_api' => Module_OperationRecord_Main::OPCODE_HELP_INTERNAL, 'open_api' => Module_OperationRecord_Main::OPCODE_HELP_OPEN]; $opcode = isset($help2opcode[$keyword]) ? $help2opcode[$keyword] : Module_OperationRecord_Main::OPCODE_HELP_INFO; Module_OperationRecord_Main::add_record($opcode); Lib_Request::flash('保存成功'); Module_HttpRequest_Router::redirect_to($actions[self::URL]); } }
/** * @param string $url * @param int $id * @return array */ private static function _get_flow_data($url, $id = null) { $data = []; $name = Lib_Request::post_var('name'); $main = Lib_Request::post_var('main'); $stuff = Lib_Request::post_var('stuff'); $config = Lib_Request::post_var('config'); $name = trim($name); $main = trim($main); $stuff = trim($stuff); $config = trim($config); $flow_model = new Model_FlowInfo(); $flash_error = function ($msg, $url) { Lib_Request::flash('error', $msg); Module_HttpRequest_Router::redirect_to($url); }; if (empty($name)) { $flash_error('流程名称不能为空', $url); } if (!empty($id)) { $cond = ['name' => $name, '_id' => ['$ne' => intval($id)]]; } else { $cond = ['name' => $name]; } $flow_info = $flow_model->get_flow_by_cond($cond); if ($flow_info['errno'] == Const_Err_Base::ERR_OK && !empty($flow_info['data'])) { $flash_error('流程名称存在', $url); } if (empty($main)) { $flash_error('主流程不能为空', $url); } $mains = self::_get_array_by_str($main); $stuffs = self::_get_array_by_str($stuff); $configs = self::_get_array_by_str($config); $data = ['name' => $name, 'flow' => [Module_FlowManager_Main::FLOW_TYPE_MAIN => $mains, Module_FlowManager_Main::FLOW_TYPE_STUFF => $stuffs, Module_FlowManager_Main::FLOW_TYPE_CONFIG => $configs]]; return $data; }