1 package mircoders.localizer.basic;
5 import freemarker.template.utility.*;
8 import mircoders.module.*;
9 import mircoders.storage.*;
10 import mircoders.localizer.*;
11 import mircoders.global.*;
13 public class MirBasicProducerToolLocalizer implements MirProducerToolLocalizer {
15 public void initializeGenerationValueSet(Map aValueSet) {
16 // ML: these config settings will be included more beautifully as soon as the new config system is in place
18 Map configMap = new HashMap();
20 configMap.put("producerDocRoot", "");//MirGlobal.getConfigProperty("Producer.DocRoot"));
21 configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
22 configMap.put("productionHost", MirGlobal.getConfigProperty("Producer.ProductionHost"));
23 configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
24 configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
25 configMap.put("now", StringUtil.date2readableDateTime(new GregorianCalendar()));
26 configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
27 configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
28 configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
29 configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
30 configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
31 configMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
32 configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
34 aValueSet.put("config", configMap);
36 EntityList topicList=null;
37 EntityList entityList=null;
38 EntityList parentList=null;
39 EntityList languageList=null;
42 ModuleLinksImcs linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
43 ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
44 ModuleLanguage languageModule = new ModuleLanguage(DatabaseLanguage.getInstance());
46 topicList = topicsModule.getTopicsList();
47 entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
48 parentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
49 languageList = languageModule.getByWhereClause("", "id", -1);
52 System.out.println("initializeGenerationValueSet: Exception "+t.getMessage());
53 t.printStackTrace(System.out);
56 aValueSet.put("topics", topicList);
57 aValueSet.put("imclist", entityList);
58 aValueSet.put("parentlist", parentList);
61 public PrintWriter openWriter(String anIdentifier) throws MirLocalizerFailure {
66 file = new File( anIdentifier );
67 dir = new File(file.getParent());
68 if (dir!=null && !dir.exists()){
72 return new PrintWriter(
73 new OutputStreamWriter(
74 new FileOutputStream(file), MirGlobal.getConfigProperty("Mir.DefaultEncoding")
79 throw new MirLocalizerFailure("Failure while opening a PrintWriter",t);
83 public void closeWriter(PrintWriter aWriter) {
87 public String filterText(String aText) {
88 return StringUtil.createHTML(
89 StringUtil.deleteForbiddenTags(aText),
90 MirGlobal.getConfigProperty("Producer.ImageRoot"),
91 MirGlobal.getConfigProperty("Producer.MailLinkName"),
92 MirGlobal.getConfigProperty("Producer.ExtLinkName"),
93 MirGlobal.getConfigProperty("Producer.IntLinkName")