Initial revision
[mir.git] / source / mircoders / producer / ProducerFeature.java
1 package mircoders.producer;
2
3 import java.io.*;
4 import java.lang.*;
5 import java.util.*;
6 import java.sql.*;
7
8 import freemarker.template.*;
9
10 import webdb.misc.*;
11 import webdb.storage.*;
12 import webdb.module.*;
13 import webdb.entity.*;
14
15 import mir.module.*;
16 import mir.entity.*;
17 import mir.storage.*;
18
19
20
21 public class ProducerFeature extends ProducerList {
22
23
24         public void setAdditional(String key, TemplateModel value) {
25                 additional.put(key,value);
26         }
27
28         public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
29                 throws StorageObjectException, ModuleException {
30                 orderBy="date desc";
31                 listTemplate = Configuration.getProperty("Producer.FeatureList.Template");
32                 EntityList featureEntityList = featureModule.getByWhereClause("","title", -1);
33                 SimpleList featureList = HTMLTemplateProcessor.makeSimpleList(featureEntityList);
34                 boolean first=true;
35                 whereClause="is_published!=true AND to_article_type=0 AND id IN (";
36                 for(int i=0; i < featureEntityList.size(); i++){
37                         if(first==false) {
38                                 whereClause += ",";
39                         }
40
41                         EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i);
42                         EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
43                         whereClause += currentTopic.getId();
44                         fileDesc = currentTopic.getValue("filename").trim();
45                         setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
46
47                         first = false;
48                 }
49                 whereClause += ")";
50                 handleIt(htmlout,user,force);
51         }
52
53         public static void main(String argv[]){
54                 try {
55                         new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
56                 } catch(Exception e) {
57                         System.err.println(e.toString());
58                 }
59         }
60 }