diff --git a/web_controllers/fs/fs_core.anubis b/web_controllers/fs/fs_core.anubis new file mode 100644 index 0000000..f9fc0ab --- /dev/null +++ b/web_controllers/fs/fs_core.anubis @@ -0,0 +1,59 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 17/04/2020 + * Time: 15:06 + * © David RENÉ + */ + + +read hayamiki_lib/controller/hk_sql_utils.anubis +read database/generated/fs_file.anubis + +public define String app_fs = get_current_directory + "/fs/". + +public define One + set_file + ( + SQLite3DataBase db, + String res_model, // product_item + DB_id res_id, // 5 + String res_name, // toto + String res_type, // "64x64" + String name, // name of the file 'toto.jpg.64x64.png' + String path // path from "app_fs" where the file is located + )= + with id = get_DB_id_by_clause(db, "fs_file", "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'"), + with fields = (List(SQLite3_update_field)) + [ field("write_date", bind_Datetime(":v_write_date", db_now)), + field("res_model", bind_String(":v_res_model", res_model)), + field("res_id", bind_Int(":v_res_id", to_Int(res_id))), + field("res_name", bind_String(":v_res_name", res_name)), + field("res_field", bind_String(":v_res_field", res_type)), + field("name", bind_String(":v_name", name)), + field("path", bind_String(":v_path", path)) + ], + forget(insert_or_update(db, "fs_file", id, fields)) +. + +public define Maybe(String) + get_file + ( + SQLite3DataBase db, + String res_model, + DB_id res_id, + String res_type + )= + with clause = "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'", + + if get_fs_file_by_clause(db, "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'") is + { + failure then + println("get_file FAILURE ["+clause+"]"); + //println("failure"); + failure, + success(the_file) then + //println("success ["+app_fs+the_file.path+the_file.name+"]"); + success(app_fs+the_file.path+the_file.name) + } +. diff --git a/web_controllers/language/language_management.anubis b/web_controllers/language/language_management.anubis new file mode 100644 index 0000000..3bebda4 --- /dev/null +++ b/web_controllers/language/language_management.anubis @@ -0,0 +1,36 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 17/04/2020 + * Time: 15:00 + * © David RENÉ + */ + +read locale/L3.anubis +read xlib/web/CXM_web_session.anubis +read app/app_loggers.anubis + +public define String default_language = "en". + +public define (String symbolic_name) -> String + make_translate_function + ( + WEB_Session _session + ) = + with lang = _session.language, + app_dictionnary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""), + if l3_load_base(app_dictionnary) is + { + failure then logError(debug_log,"Can't load translation dictionnary for '"+app_dictionnary+"'"); + (String symbolic_name) |-> "<" + symbolic_name + ">", + success(L3 local) then + + //now we set the current language + with _l3_object = l3_set_current(local, lang), + l3_object = l3_set_default(_l3_object, default_language), + if lang = "symb" then + (String symbolic_name) |-> "[" + l3_get_text(l3_object, symbolic_name) + "]" + else + (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name) + } +. -- libgit2 0.21.4