1 package mircoders.producer;
8 import freemarker.template.*;
11 import webdb.storage.*;
12 import webdb.module.*;
13 import webdb.entity.*;
21 public class ProducerTopics extends ProducerList {
25 public void setAdditional(String key, TemplateModel value) {
26 additional.put(key,value);
29 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
30 throws StorageObjectException, ModuleException {
32 handle(htmlout,user,force,sync);
35 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
36 throws StorageObjectException, ModuleException {
38 orderBy="date desc, webdb_create desc";
39 listTemplate = Configuration.getProperty("Producer.TopicList.Template");
41 EntityList topicsEntityList;
43 topicsEntityList = topicsModule.getByWhereClause("","title", -1);
45 topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
47 SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
49 for(int i=0; i < topicsEntityList.size(); i++){
51 EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
52 EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
53 String whereClauseSpecial=null;
55 if (contentEntityList!=null || force==true) {
56 if (contentEntityList!=null){
58 whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
59 whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
60 for(int j=0; j < contentEntityList.size(); j++){
63 whereClauseSpecial += ",";
65 EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
66 whereClause += currentContent.getId();
67 whereClauseSpecial += currentContent.getId();
69 setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
74 whereClauseSpecial += ")";
77 if(contentEntityList==null && force==true){
78 //hihi, das ist eigentlich boese
79 whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
82 fileDesc = currentTopic.getValue("filename");
84 // get the startarticle
85 EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
86 SimpleList specialList = HTMLTemplateProcessor.makeSimpleList(entityList);
87 String currentMediaId = null;
88 SimpleHash imageHash = new SimpleHash();
89 EntityContent currentContent;
90 if(entityList != null){
91 for (int k=0; k < entityList.size();k++) {
92 currentContent = (EntityContent)entityList.elementAt(k);
93 currentMediaId = currentContent.getValue("to_media");
94 if (currentMediaId!=null && !currentMediaId.equals("")) {
95 imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
98 setAdditional("specialimage",imageHash);
100 setAdditional("special",specialList);
102 //set the list of topics
103 setAdditional("topicslist",topicsList);
105 handleIt(htmlout,user,force);
110 public static void main(String argv[]){
112 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
113 } catch(Exception e) {
114 System.err.println(e.toString());