--- /dev/null
+package mircoders.producer;
+
+import java.io.*;
+import java.lang.*;
+import java.util.*;
+import java.sql.*;
+
+import freemarker.template.*;
+
+import webdb.misc.*;
+import webdb.storage.*;
+import webdb.module.*;
+import webdb.entity.*;
+
+import mir.module.*;
+import mir.entity.*;
+import mir.storage.*;
+
+
+
+public class ProducerTopics extends ProducerList {
+
+ public String where;
+
+ public void setAdditional(String key, TemplateModel value) {
+ additional.put(key,value);
+ }
+
+ public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
+ throws StorageObjectException, ModuleException {
+ where=id;
+ handle(htmlout,user,force,sync);
+ }
+
+ public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
+ throws StorageObjectException, ModuleException {
+
+ orderBy="date desc, webdb_create desc";
+ listTemplate = Configuration.getProperty("Producer.TopicList.Template");
+
+ EntityList topicsEntityList;
+ if(where==null){
+ topicsEntityList = topicsModule.getByWhereClause("","title", -1);
+ } else {
+ topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
+ }
+ SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
+
+ for(int i=0; i < topicsEntityList.size(); i++){
+
+ EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
+ EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
+ String whereClauseSpecial=null;
+
+ if (contentEntityList!=null || force==true) {
+ if (contentEntityList!=null){
+ boolean first=true;
+ whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
+ whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
+ for(int j=0; j < contentEntityList.size(); j++){
+ if(first==false) {
+ whereClause += ",";
+ whereClauseSpecial += ",";
+ }
+ EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
+ whereClause += currentContent.getId();
+ whereClauseSpecial += currentContent.getId();
+
+ setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+
+ first = false;
+ }
+ whereClause += ")";
+ whereClauseSpecial += ")";
+ }
+
+ if(contentEntityList==null && force==true){
+ //hihi, das ist eigentlich boese
+ whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
+ }
+
+ fileDesc = currentTopic.getValue("filename");
+
+ // get the startarticle
+ EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
+ SimpleList specialList = HTMLTemplateProcessor.makeSimpleList(entityList);
+ String currentMediaId = null;
+ SimpleHash imageHash = new SimpleHash();
+ EntityContent currentContent;
+ if(entityList != null){
+ for (int k=0; k < entityList.size();k++) {
+ currentContent = (EntityContent)entityList.elementAt(k);
+ currentMediaId = currentContent.getValue("to_media");
+ if (currentMediaId!=null && !currentMediaId.equals("")) {
+ imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
+ }
+ }
+ setAdditional("specialimage",imageHash);
+ }
+ setAdditional("special",specialList);
+
+ //set the list of topics
+ setAdditional("topicslist",topicsList);
+
+ handleIt(htmlout,user,force);
+ }
+ }
+ }
+
+ public static void main(String argv[]){
+ try {
+ new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
+ } catch(Exception e) {
+ System.err.println(e.toString());
+ }
+ }
+}
\ No newline at end of file