1 package mircoders.producer;
8 import freemarker.template.*;
15 import mircoders.entity.*;
16 import mircoders.storage.*;
20 public class ProducerTopics extends ProducerList {
24 public void setAdditional(String key, TemplateModel value) {
25 additional.put(key,value);
28 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
29 throws StorageObjectException, ModuleException {
31 handle(htmlout,user,force,sync);
34 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
35 throws StorageObjectException, ModuleException {
37 orderBy="date desc, webdb_create desc";
38 listTemplate = MirConfig.getProp("Producer.TopicList.Template");
40 EntityList topicsEntityList;
42 topicsEntityList = topicsModule.getByWhereClause("","title", -1);
44 topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
46 SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
48 for(int i=0; i < topicsEntityList.size(); i++){
50 EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
51 EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
52 String whereClauseSpecial=null;
54 if (contentEntityList!=null || force==true) {
55 if (contentEntityList!=null){
57 whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
58 whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
59 for(int j=0; j < contentEntityList.size(); j++){
62 whereClauseSpecial += ",";
64 EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
65 whereClause += currentContent.getId();
66 whereClauseSpecial += currentContent.getId();
68 setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
73 whereClauseSpecial += ")";
76 if(contentEntityList==null && force==true){
77 //hihi, das ist eigentlich boese
78 whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
81 fileDesc = currentTopic.getValue("filename");
83 // get the startarticle
84 EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
85 SimpleList specialList = HTMLTemplateProcessor.makeSimpleList(entityList);
86 String currentMediaId = null;
87 SimpleHash imageHash = new SimpleHash();
88 EntityContent currentContent;
89 if(entityList != null){
90 for (int k=0; k < entityList.size();k++) {
91 currentContent = (EntityContent)entityList.elementAt(k);
92 currentMediaId = currentContent.getValue("to_media");
93 if (currentMediaId!=null && !currentMediaId.equals("")) {
94 imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
97 setAdditional("specialimage",imageHash);
99 setAdditional("special",specialList);
101 //set the list of topics
102 setAdditional("topicslist",topicsList);
104 handleIt(htmlout,user,force);
109 public static void main(String argv[]){
111 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
112 } catch(Exception e) {
113 System.err.println(e.toString());