/* * Created by PyramIDE. * User: フランスのトトロ aka (David RENÉ) * Date: 18/04/2020 * Time: 00:50 * © David RENÉ */ read system/logger.anubis read language_web_action_name.anubis read hayamiki_lib/model/types/hk_database.anubis read hayamiki_lib/view/view_table_manager_types.anubis read xlib/web/controllers_web_site.anubis read xlib/web_controllers/language/language_management.anubis read xlib/web/plugin/plugin.anubis define WEB_Action do_change_language = web_action( do_change_language, http_https, (WEB_Session _session) |-> true, (WEB_Session _session) |-> // since _session is web_session(id, _old_lang, fields, current, previous, draw), //increment 1 to message TTL with step = get_Int(fields, "AWS_SESSION_STEP",0), replace_Int(fields, "PAGE_MESSAGE_TTL", step+1); if web_arg_value(*current.lwa, "language_code") is { not_found then redirect_to_previous, //http_answer(web_session(id, _old_lang, fields, previous, previous), plain_text(http_no_content, "")) // found(language_code) then //http_answer(web_session(id, language_code, fields, previous, previous), plain_text(http_no_content, "")) with new_web_session = web_session(id, language_code, fields, draw, previous, draw), // println("------- language change. New web session ---------"); // println(dump(new_web_session)); // println("--------------------------------------------------"); redirect(new_web_session) } ) . public define HTTP_Answer ajax_translate_to_json ( WEB_Session _session, String symbolic_names //list of symbolic names to translate separated by comma i.e. "JAN,FEB" ) = with _T = make_translate_function(_session), //construct a list of json_member with "symbolic_name: translated value" with translated_list = map((String symbolic) |-> json_member(symbolic, json_string(_T(symbolic))), split_by_token(symbolic_names,',')), json(http_ok, json_object(translated_list)) . define WEB_Action ajax_translate_json = web_action( ajax_translate_json, https, (WEB_Session _session) |-> true, (WEB_Session _session) |-> //here the function really call for creating domain name since _session is web_session(id, lang, _, web_request, _, _draw), if web_arg_value(*web_request.lwa, "to_translate") is { not_found then redirect_to_previous found(symbolic_names) then ajax(ajax_translate_to_json(_session, symbolic_names)) } ) . public define List(WEB_Action) make_language_actions = [ //action lors de la demande de création d'un user dans un domaine do_change_language, ajax_translate_json ]. public define WEB_Controller get_lang_controller = web_controller("language", var(make_language_actions)) . public define List(WEB_Controller) plugin_get_controller ( SQLite3DataBase db, HK_Database hk_db, VTM _vtm, (LogLevel, String) -> One logger ) = [get_lang_controller] . define Maybe(HTML_Partial_Content) plugin_get_typed_content ( SQLite3DataBase db, WEB_Session _session, String type )= println("plugin_get_typed_content for L3 type "+type); if type = "LEFT_MENU" then failure else if type = "TOOLBAR" then failure else if type = "CONTROL_PANEL" then failure else failure . global define WEB_Plugin l3_lib = web_plugin( "L3", "BASE", plugin_get_controller, plugin_get_typed_content ) .