docomentataion
[mir.git] / source / mircoders / producer / ProducerTopics.java
index 1d1c9b4..199ab76 100755 (executable)
@@ -35,6 +35,8 @@ public class ProducerTopics extends ProducerList {
   String              tinyIcon;
   String              iconAlt;
 
+  /** @todo couldn't this be in Producer.java and should be named addAdditional,
+   *  and should be thrown away afterwards? */
   public void setAdditional(String key, TemplateModel value) {
     additional.put(key,value);
   }
@@ -46,18 +48,22 @@ public class ProducerTopics extends ProducerList {
   }
 
   public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
-    throws StorageObjectException, ModuleException {
+    throws StorageObjectException, ModuleException
+  {
+    long startTime = System.currentTimeMillis();
+    int pageCount =0;
+    logHTML(htmlout, "Producer.Topics: started");
 
-    orderBy="date desc, webdb_create desc";
+    /** @todo should be done in static */
     listTemplate = MirConfig.getProp("Producer.TopicList.Template");
 
+    orderBy="date desc, webdb_create desc";
     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++){
 
@@ -81,7 +87,7 @@ public class ProducerTopics extends ProducerList {
             whereClause += currentContent.getId();
             whereClauseSpecial += currentContent.getId();
 
-            setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+            setAdditional("topic",currentTopic);
 
             first = false;
           }
@@ -104,8 +110,7 @@ public class ProducerTopics extends ProducerList {
         if(entityList != null && entityList.size()==1){
           currentContent = (EntityContent)entityList.elementAt(0);
           try {
-              SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent);
-              setAdditional("special",specialHash);
+              setAdditional("special",currentContent);
           } catch (Exception e) {
             theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
             logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
@@ -113,15 +118,19 @@ public class ProducerTopics extends ProducerList {
         }
 
         //set the list of topics
-        setAdditional("topicslist",topicsList);
+        setAdditional("topicslist",topicsEntityList);
 
         handleIt(htmlout,user,force);
+        pageCount++;
       }
       } catch (Exception e) {
+        theLog.printError("ProducerTopics: problem with start special media: "
+        +e.toString()+" <font color=\"red\">skipping</font>");
         logHTML(htmlout,"ProducerTopics: problem with topic id: "
         +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
       }
     }
+    logHTMLFinish(htmlout, "Topics", pageCount, startTime, System.currentTimeMillis());
   }
 
   public static void main(String argv[]){