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 String currentMediaId = null;
86 SimpleHash imageHash = new SimpleHash();
87 EntityContent currentContent;
88 if(entityList != null && entityList.size()==1){
89 currentContent = (EntityContent)entityList.elementAt(0);
90 SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent);
92 EntityList currentMedia = DatabaseContentToMedia.getInstance().getImages(currentContent);
93 if (currentMedia!=null && currentMedia.getCount()>=1) {
94 SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
95 specialHash.put("to_media",mediaList);
97 setAdditional("special",specialHash);
100 //set the list of topics
101 setAdditional("topicslist",topicsList);
103 handleIt(htmlout,user,force);
108 public static void main(String argv[]){
110 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
111 } catch(Exception e) {
112 System.err.println(e.toString());