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 long startTime = System.currentTimeMillis();
53 logHTML(htmlout, "Producer.List: started");
55 /** @todo should be done in static */
56 listTemplate = MirConfig.getProp("Producer.TopicList.Template");
58 orderBy="date desc, webdb_create desc";
59 EntityList topicsEntityList;
61 topicsEntityList = topicsModule.getByWhereClause("","title", -1);
63 topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
66 for(int i=0; i < topicsEntityList.size(); i++){
68 EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
71 EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
72 String whereClauseSpecial=null;
74 if (contentEntityList!=null || force==true) {
75 if (contentEntityList!=null){
77 whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
78 whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
79 for(int j=0; j < contentEntityList.size(); j++){
82 whereClauseSpecial += ",";
84 EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
85 whereClause += currentContent.getId();
86 whereClauseSpecial += currentContent.getId();
88 setAdditional("topic",currentTopic);
93 whereClauseSpecial += ")";
96 if(contentEntityList==null && force==true){
97 //hihi, das ist eigentlich boese
98 whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
101 fileDesc = currentTopic.getValue("filename");
103 // get the startarticle
104 EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
105 String currentMediaId = null;
106 SimpleHash imageHash = new SimpleHash();
107 EntityContent currentContent;
108 if(entityList != null && entityList.size()==1){
109 currentContent = (EntityContent)entityList.elementAt(0);
111 setAdditional("special",currentContent);
112 } catch (Exception e) {
113 theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
114 logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
118 //set the list of topics
119 setAdditional("topicslist",topicsEntityList);
121 handleIt(htmlout,user,force);
124 } catch (Exception e) {
125 theLog.printError("ProducerTopics: problem with start special media: "
126 +e.toString()+" <font color=\"red\">skipping</font>");
127 logHTML(htmlout,"ProducerTopics: problem with topic id: "
128 +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
131 logHTMLFinish(htmlout, "Topics", pageCount, startTime, System.currentTimeMillis());
134 public static void main(String argv[]){
136 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
137 } catch(Exception e) {
138 System.err.println(e.toString());