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 MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {
14 protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
16 public void initializeGenerationValueSet(Map aValueSet) {
17 // ML: these config settings will be included more beautifully as soon as the new config system is in place
19 Map configMap = new HashMap();
20 Map utilityMap = new HashMap();
22 configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
23 configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
24 configMap.put("productionHost", MirGlobal.getConfigProperty("Producer.ProductionHost"));
25 configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
26 configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
27 configMap.put("now", StringUtil.date2readableDateTime(new GregorianCalendar()));
28 configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
29 configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
30 configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
31 configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
32 configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
33 configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
35 utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
37 aValueSet.put("config", configMap);
38 aValueSet.put("utility", utilityMap);
40 EntityList topicList=null;
41 EntityList entityList=null;
42 EntityList parentList=null;
43 EntityList languageList=null;
46 ModuleLinksImcs linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
47 ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
48 ModuleLanguage languageModule = new ModuleLanguage(DatabaseLanguage.getInstance());
50 topicList = topicsModule.getTopicsList();
51 entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
52 parentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
53 languageList = languageModule.getByWhereClause("", "id", -1);
56 logger.printError("initializeGenerationValueSet: Exception "+t.getMessage());
59 aValueSet.put("topics", topicList);
60 aValueSet.put("imclist", entityList);
61 aValueSet.put("parentlist", parentList);
63 Map articleTypeMap = new HashMap();
64 articleTypeMap.put("openposting", "0");
65 articleTypeMap.put("newswire", "1");
66 articleTypeMap.put("feature", "2");
67 articleTypeMap.put("topicspecial", "3");
68 articleTypeMap.put("startspecial", "4");
69 aValueSet.put("articletype", articleTypeMap);
72 public PrintWriter openWriter(String anIdentifier) throws MirLocalizerFailure {
77 file = new File( anIdentifier );
78 dir = new File(file.getParent());
79 if (dir!=null && !dir.exists()){
83 return new PrintWriter(
84 new OutputStreamWriter(
85 new FileOutputStream(file), MirGlobal.getConfigProperty("Mir.DefaultEncoding")
90 throw new MirLocalizerFailure("Failure while opening a PrintWriter",t);
94 public void closeWriter(PrintWriter aWriter) {
98 public String filterText(String aText) {
99 return StringUtil.createHTML(
100 StringUtil.deleteForbiddenTags(aText),
101 MirGlobal.getConfigProperty("Producer.ImageRoot"),
102 MirGlobal.getConfigProperty("Producer.MailLinkName"),
103 MirGlobal.getConfigProperty("Producer.ExtLinkName"),
104 MirGlobal.getConfigProperty("Producer.IntLinkName")