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 89 l3Symbol( String name, //the name of symbol
90 90 String chapter, //the chapter of symbol
91 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 96 public type L3Stat:
... ... @@ -119,7 +119,7 @@ public type L3:
119 119 String appHash, //unique id of the application
120 120 SQLite3DataBase symbol_db, //SQLite database which contain symbols, chapter and description
121 121 String defaultLangCode,//current selected language
122   - SQLite3DataBase defaultLangDb, //SQLite database of current language
  122 + SQLite3DataBase defaultLangDb, //SQLite database of current language
123 123 String currentLangCode,//current selected language
124 124 SQLite3DataBase currentLangDb //SQLite database of current language
125 125 ).
... ... @@ -129,16 +129,16 @@ public type L3Properties:
129 129 ( String appName, //name of application
130 130 String appHash, //unique id of the application
131 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 136 public type L3LangDicProperty:
137 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 142 Int creation_date,
143 143 Int last_update
144 144 ).
... ... @@ -524,7 +524,7 @@ public define Bool
524 524  
525 525  
526 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 528 * creation or updating a false value is return.
529 529 * @param lang_db database in which we want put the text
530 530 * @param symbolic_name name of which symbol we want to put the text
... ... @@ -647,7 +647,7 @@ define Bool
647 647 SQLite3DataBase lang_db,
648 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 651 error(n) then print("del_symbol "+symbolic_name+" ERROR "+code(n)+"\n");false
652 652 else
653 653 true.
... ... @@ -847,7 +847,7 @@ define Int
847 847 String collection_name,
848 848 List(String) lang_list,
849 849 String symbolic_name,
850   - Int current
  850 + Int current
851 851 ) =
852 852  
853 853 if lang_list is
... ... @@ -869,7 +869,7 @@ define Int
869 869  
870 870  
871 871 * Description *
872   - Create the 2 principals tables used by symbol database
  872 + Create the 2 main tables used by symbol database
873 873 these tables are :
874 874  
875 875 TABLE [info] which record
... ... @@ -897,7 +897,7 @@ define Bool create_symbol_tables(SQLite3DataBase db) =
897 897 true.
898 898  
899 899 * Description *
900   - Create the 2 principals tables used by symbol database
  900 + Create the 2 main tables used by symbol database
901 901 these tables are :
902 902  
903 903 TABLE [info] which record
... ... @@ -963,6 +963,8 @@ define List(String) construct_collection_list(List(String) file_list)=
963 963 public define List(String) l3_get_all_dic =
964 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 1044 l3_get_all_dic =
1043 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 1051 public define Int
1046 1052 l3_get_all_dic =
1047 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 1059 define Bool create_L3_default_dir(One none) =
1050 1060 if make_directory(dic_path, default_directory_mode) is
1051 1061 {
... ...