1 package mircoders.producer;
5 import java.lang.reflect.*;
9 import freemarker.template.*;
17 import mircoders.entity.*;
18 import mircoders.storage.*;
22 public class ProducerTopics extends ProducerList {
25 String currentMediaId;
26 EntityList upMediaEntityList;
27 EntityList imageEntityList;
28 EntityList currentMediaList;
30 EntityMedia uploadedMedia;
31 Class mediaHandlerClass=null;
32 MirMedia mediaHandler=null;
33 String mediaHandlerName=null;
34 Database mediaStorage=null;
38 public void setAdditional(String key, TemplateModel value) {
39 additional.put(key,value);
42 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
43 throws StorageObjectException, ModuleException {
45 handle(htmlout,user,force,sync);
48 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
49 throws StorageObjectException, ModuleException {
51 orderBy="date desc, webdb_create desc";
52 listTemplate = MirConfig.getProp("Producer.TopicList.Template");
54 EntityList topicsEntityList;
56 topicsEntityList = topicsModule.getByWhereClause("","title", -1);
58 topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
60 SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
62 for(int i=0; i < topicsEntityList.size(); i++){
64 EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
67 EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
68 String whereClauseSpecial=null;
70 if (contentEntityList!=null || force==true) {
71 if (contentEntityList!=null){
73 whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
74 whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
75 for(int j=0; j < contentEntityList.size(); j++){
78 whereClauseSpecial += ",";
80 EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
81 whereClause += currentContent.getId();
82 whereClauseSpecial += currentContent.getId();
84 setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
89 whereClauseSpecial += ")";
92 if(contentEntityList==null && force==true){
93 //hihi, das ist eigentlich boese
94 whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
97 fileDesc = currentTopic.getValue("filename");
99 // get the startarticle
100 EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
101 String currentMediaId = null;
102 SimpleHash imageHash = new SimpleHash();
103 EntityContent currentContent;
104 if(entityList != null && entityList.size()==1){
105 currentContent = (EntityContent)entityList.elementAt(0);
107 SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent);
108 setAdditional("special",specialHash);
109 } catch (Exception e) {
110 theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
111 logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
115 //set the list of topics
116 setAdditional("topicslist",topicsList);
118 handleIt(htmlout,user,force);
120 } catch (Exception e) {
121 logHTML(htmlout,"ProducerTopics: problem with topic id: "
122 +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
127 public static void main(String argv[]){
129 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
130 } catch(Exception e) {
131 System.err.println(e.toString());