namespace Holo.Managers { using Holo; using Microsoft.VisualBasic; using System; using System.Collections; using System.Text; public static class stringManager { private static string filterCensor; internal static string langExt; private static Hashtable langStrings; private static string[] swearWords; public static string filterSwearwords(string Text) { if (Config.enableWordFilter) { for (int i = 0; i < swearWords.Length; i++) { Text = Strings.Replace(Text, swearWords[i], filterCensor, 1, -1, CompareMethod.Text); } } return Text; } public static string getString(string stringID) { try { return langStrings[stringID].ToString(); } catch { return stringID; } } public static string getStringPart(string Input, int startIndex, int Length) { try { return Input.Substring(startIndex, Length); } catch { return ""; } } public static void Init(string langExtension) { langExt = langExtension; langStrings = new Hashtable(); Out.WriteLine("Carico istuzioni da tabella system_strings per la lingua '" + langExtension + "' ..."); string[] strArray = DB.runReadColumn("SELECT stringid FROM system_strings ORDER BY id ASC", 0); string[] strArray2 = DB.runReadColumn("SELECT var_" + langExt + " FROM system_strings ORDER BY id ASC", 0); for (int i = 0; i < strArray.Length; i++) { if (strArray[i] != "") { if (strArray2[i] == "") { strArray2[i] = strArray[i]; } langStrings.Add(strArray[i], strArray2[i]); } } Out.WriteLine("Caricate " + langStrings.Count + " istruzioni da tabella system_strings."); if (Config.getTableEntry("welcomemessage_enable") == "1") { if (getString("welcomemessage_text") != "") { Config.enableWelcomeMessage = true; Out.WriteLine("Messaggio di benvenuto abilitato."); } else { Out.WriteLine("Il messaggio di benvenuto \x00e8 solitamente consigliato tenerlo abilitato."); } } else { Out.WriteLine("Messaggio di benvenuto disabilitato."); } } public static void initFilter() { if (Config.getTableEntry("wordfilter_enable") == "1") { Out.WriteLine("Carico censura parola..."); swearWords = DB.runReadColumn("SELECT word FROM wordfilter", 0); filterCensor = Config.getTableEntry("wordfilter_censor"); if ((swearWords.Length == 0) || (filterCensor == "")) { Out.WriteLine("La censura delle parole \x00e8 consigliato tenerlo abilitato."); } else { Config.enableWordFilter = true; Out.WriteLine(string.Concat(new object[] { "Censura parola abilitato, ", swearWords.Length, " parole trovate, censura: ", filterCensor })); } } else { Out.WriteLine("Censura parola disabilitato."); } } public static string wrapParameters(string[] s, int startIndex) { StringBuilder builder = new StringBuilder(); for (int i = startIndex; i < s.Length; i++) { builder.Append(" " + s[i]); } return builder.ToString().Substring(1); } } }