Commit 05d869779065ee36734b8216085147bb8df5753a

Authored by totoro
1 parent 0b1b6bb0

[+] add "pattern" parameter in l3_get_all_dic. This allow to limit the search to…

… dictionaries which match with pattern. Useful in real-time search with ajax
Showing 1 changed file with 24 additions and 14 deletions   Show diff stats
anubis_dev/library/locale/L3.anubis
@@ -89,8 +89,8 @@ public type L3SymbolFull: //define the symbol attributes with all pr @@ -89,8 +89,8 @@ public type L3SymbolFull: //define the symbol attributes with all pr
89 l3Symbol( String name, //the name of symbol 89 l3Symbol( String name, //the name of symbol
90 String chapter, //the chapter of symbol 90 String chapter, //the chapter of symbol
91 String description, //the description of the content text define by the symbol 91 String description, //the description of the content text define by the symbol
92 - Int creation_date, //creation date of this symbol  
93 - Int last_update //update date of this symbol 92 + Int creation_date, //creation date of this symbol
  93 + Int last_update //update date of this symbol
94 ). 94 ).
95 95
96 public type L3Stat: 96 public type L3Stat:
@@ -119,7 +119,7 @@ public type L3: @@ -119,7 +119,7 @@ public type L3:
119 String appHash, //unique id of the application 119 String appHash, //unique id of the application
120 SQLite3DataBase symbol_db, //SQLite database which contain symbols, chapter and description 120 SQLite3DataBase symbol_db, //SQLite database which contain symbols, chapter and description
121 String defaultLangCode,//current selected language 121 String defaultLangCode,//current selected language
122 - SQLite3DataBase defaultLangDb, //SQLite database of current language 122 + SQLite3DataBase defaultLangDb, //SQLite database of current language
123 String currentLangCode,//current selected language 123 String currentLangCode,//current selected language
124 SQLite3DataBase currentLangDb //SQLite database of current language 124 SQLite3DataBase currentLangDb //SQLite database of current language
125 ). 125 ).
@@ -129,16 +129,16 @@ public type L3Properties: @@ -129,16 +129,16 @@ public type L3Properties:
129 ( String appName, //name of application 129 ( String appName, //name of application
130 String appHash, //unique id of the application 130 String appHash, //unique id of the application
131 String default_lang, 131 String default_lang,
132 - Int creation_date,  
133 - Int last_update 132 + Int creation_date,
  133 + Int last_update
134 ). 134 ).
135 135
136 public type L3LangDicProperty: 136 public type L3LangDicProperty:
137 l3LangDicProperty 137 l3LangDicProperty
138 - ( String appName, //name of application  
139 - String appHash, //unique id of the application  
140 - String lang_code,  
141 - String userdef, 138 + ( String appName, //name of application
  139 + String appHash, //unique id of the application
  140 + String lang_code,
  141 + String userdef,
142 Int creation_date, 142 Int creation_date,
143 Int last_update 143 Int last_update
144 ). 144 ).
@@ -524,7 +524,7 @@ public define Bool @@ -524,7 +524,7 @@ public define Bool
524 524
525 525
526 /** put text translation into symbol entry in the given database. If the symbol 526 /** put text translation into symbol entry in the given database. If the symbol
527 - * doesn't exist in datadabe, it's created before. But if any occures during the 527 + * doesn't exist in datadase, it's created before. But if any occures during the
528 * creation or updating a false value is return. 528 * creation or updating a false value is return.
529 * @param lang_db database in which we want put the text 529 * @param lang_db database in which we want put the text
530 * @param symbolic_name name of which symbol we want to put the text 530 * @param symbolic_name name of which symbol we want to put the text
@@ -647,7 +647,7 @@ define Bool @@ -647,7 +647,7 @@ define Bool
647 SQLite3DataBase lang_db, 647 SQLite3DataBase lang_db,
648 String symbolic_name, 648 String symbolic_name,
649 ) = 649 ) =
650 - if sql_query(lang_db, "DELETE FROM symbol WHERE name = " + db_make_sql_string(symbolic_name) + ";") is 650 + if sqlite3_query(lang_db, "DELETE FROM symbol WHERE name = @name;", [bind_String("@name",symbolic_name)]) is
651 error(n) then print("del_symbol "+symbolic_name+" ERROR "+code(n)+"\n");false 651 error(n) then print("del_symbol "+symbolic_name+" ERROR "+code(n)+"\n");false
652 else 652 else
653 true. 653 true.
@@ -847,7 +847,7 @@ define Int @@ -847,7 +847,7 @@ define Int
847 String collection_name, 847 String collection_name,
848 List(String) lang_list, 848 List(String) lang_list,
849 String symbolic_name, 849 String symbolic_name,
850 - Int current 850 + Int current
851 ) = 851 ) =
852 852
853 if lang_list is 853 if lang_list is
@@ -869,7 +869,7 @@ define Int @@ -869,7 +869,7 @@ define Int
869 869
870 870
871 * Description * 871 * Description *
872 - Create the 2 principals tables used by symbol database 872 + Create the 2 main tables used by symbol database
873 these tables are : 873 these tables are :
874 874
875 TABLE [info] which record 875 TABLE [info] which record
@@ -897,7 +897,7 @@ define Bool create_symbol_tables(SQLite3DataBase db) = @@ -897,7 +897,7 @@ define Bool create_symbol_tables(SQLite3DataBase db) =
897 true. 897 true.
898 898
899 * Description * 899 * Description *
900 - Create the 2 principals tables used by symbol database 900 + Create the 2 main tables used by symbol database
901 these tables are : 901 these tables are :
902 902
903 TABLE [info] which record 903 TABLE [info] which record
@@ -963,6 +963,8 @@ define List(String) construct_collection_list(List(String) file_list)= @@ -963,6 +963,8 @@ define List(String) construct_collection_list(List(String) file_list)=
963 public define List(String) l3_get_all_dic = 963 public define List(String) l3_get_all_dic =
964 construct_collection_list(directory_list( dic_path, "*.L3.symb")). 964 construct_collection_list(directory_list( dic_path, "*.L3.symb")).
965 965
  966 +public define List(String) l3_get_all_dic(String pattern) =
  967 + construct_collection_list(directory_list( dic_path, "*"+pattern+"*.L3.symb")).
966 968
967 969
968 970
@@ -1042,10 +1044,18 @@ public define List(L3Properties) @@ -1042,10 +1044,18 @@ public define List(L3Properties)
1042 l3_get_all_dic = 1044 l3_get_all_dic =
1043 construct_dic_list(directory_list( dic_path, "*.L3.symb")). 1045 construct_dic_list(directory_list( dic_path, "*.L3.symb")).
1044 1046
  1047 +public define List(L3Properties)
  1048 + l3_get_all_dic(String pattern) =
  1049 + construct_dic_list(directory_list( dic_path, "*"+pattern+"*.L3.symb")).
  1050 +
1045 public define Int 1051 public define Int
1046 l3_get_all_dic = 1052 l3_get_all_dic =
1047 length(directory_list( dic_path, "*.L3.symb")). 1053 length(directory_list( dic_path, "*.L3.symb")).
1048 1054
  1055 +public define Int
  1056 + l3_get_all_dic(String pattern) =
  1057 + length(directory_list( dic_path, "*"+pattern+"*.L3.symb")).
  1058 +
1049 define Bool create_L3_default_dir(One none) = 1059 define Bool create_L3_default_dir(One none) =
1050 if make_directory(dic_path, default_directory_mode) is 1060 if make_directory(dic_path, default_directory_mode) is
1051 { 1061 {