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 handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
39 throws StorageObjectException, ModuleException {
41 handle(htmlout,user,force,sync);
44 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
45 throws StorageObjectException, ModuleException
47 long startTime = System.currentTimeMillis();
49 logHTML(htmlout, "Producer.Topics: started");
51 /** @todo should be done in static */
52 listTemplate = MirConfig.getProp("Producer.TopicList.Template");
54 orderBy="date desc, webdb_create desc";
55 EntityList topicsEntityList;
57 topicsEntityList = topicsModule.getByWhereClause("","title", -1);
59 topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
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",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 setAdditional("special",currentContent);
108 } catch (Exception e) {
109 theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
110 logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
114 //set the list of topics
115 setAdditional("topicslist",topicsEntityList);
117 handleIt(htmlout,user,force);
120 } catch (Exception e) {
121 theLog.printError("ProducerTopics: problem with start special media: "
122 +e.toString()+" <font color=\"red\">skipping</font>");
123 logHTML(htmlout,"ProducerTopics: problem with topic id: "
124 +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
127 logHTMLFinish(htmlout, "Topics", pageCount, startTime, System.currentTimeMillis());
130 public static void main(String argv[]){
132 new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
133 } catch(Exception e) {
134 System.err.println(e.toString());