abstract public class ProducerList extends Producer {
- public String listTemplate;
- public String whereClause;
- public String orderBy;
- public String fileDesc;
- protected HashMap additional = new HashMap();
+ public String listTemplate;
+ public String whereClause;
+ public String orderBy;
+ public String fileDesc;
+ protected HashMap additional = new HashMap();
- public void handle(PrintWriter htmlout, EntityUsers user, boolean sync, boolean force)
- throws StorageObjectException, ModuleException {
- handleIt(htmlout,user,force);
- }
+ public void handle(PrintWriter htmlout, EntityUsers user, boolean sync, boolean force)
+ throws StorageObjectException, ModuleException {
+ handleIt(htmlout,user,force);
+ }
- public void handleIt(PrintWriter htmlout, EntityUsers user, boolean force)
- throws StorageObjectException, ModuleException {
+ public void handleIt(PrintWriter htmlout, EntityUsers user, boolean force)
+ throws StorageObjectException, ModuleException {
- logHTML(htmlout, "Producer.List: started");
+ logHTML(htmlout, "Producer.List: started");
int newsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Newswire"));
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
- String htmlFileName = "";
- String currentMediaId;
- EntityContent currentContent;
- EntityList list;
- EntityGruppen userEntity=null;
- SimpleHash imageHash = new SimpleHash();
- int size = 0;
- int listSize = 0;
-
- int maxItemsOnPage = Integer.parseInt(MirConfig.getProp("Lists.Max.Items"));
-
- try {
- listSize = contentModule.getSize(whereClause);
- } catch (Exception e) {
- logHTML(htmlout,e.toString());
- }
-
- int modRest = listSize % maxItemsOnPage;
- int numberOfPages = (listSize - modRest) / maxItemsOnPage;
- boolean first=true;
- for (int i = 0;i < numberOfPages+1;i ++) {
- //break the loop, if only athe actuell pages should be produced
- if (force == false && i==3) {
- break;
- }
- //break, if only the first page has to be produced
- if (force == false && modRest != 0 && first==false){
- break;
- }
-
-
- if (first==true) {
- //get the data for the first page
- size=maxItemsOnPage + modRest;
- list = contentModule.getContent(whereClause, orderBy, 0, size, userEntity);
- first=false;
- } else {
- //get the data for the other pages
- list = contentModule.getContent(whereClause, orderBy, size, maxItemsOnPage, userEntity);
- size = size + maxItemsOnPage;
- }
-
- //now produce the pages
- if (list!=null || force==true) {
- SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(list);
- //first we try to get the images
- SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(list);
- if(list!=null){
- for (int k=0; k < list.size();k++) {
- currentContent = (EntityContent)list.elementAt(k);
+ long sessionConnectTime = 0;
+ long startTime = (new java.util.Date()).getTime();
+ String htmlFileName = "";
+ String currentMediaId;
+ EntityContent currentContent;
+ EntityList list;
+ EntityGruppen userEntity=null;
+ SimpleHash imageHash = new SimpleHash();
+ int size = 0;
+ int listSize = 0;
+
+ int maxItemsOnPage = Integer.parseInt(MirConfig.getProp("Lists.Max.Items"));
+
+ try {
+ listSize = contentModule.getSize(whereClause);
+ } catch (Exception e) {
+ logHTML(htmlout,e.toString());
+ }
+
+ int modRest = listSize % maxItemsOnPage;
+ int numberOfPages = (listSize - modRest) / maxItemsOnPage;
+ boolean first=true;
+ for (int i = 0;i < numberOfPages+1;i ++) {
+ //break the loop, if only athe actuell pages should be produced
+ if (force == false && i==3) {
+ break;
+ }
+ //break, if only the first page has to be produced
+ if (force == false && modRest != 0 && first==false){
+ break;
+ }
+
+
+ if (first==true) {
+ //get the data for the first page
+ size=maxItemsOnPage + modRest;
+ list = contentModule.getContent(whereClause, orderBy, 0, size, userEntity);
+ first=false;
+ } else {
+ //get the data for the other pages
+ list = contentModule.getContent(whereClause, orderBy, size, maxItemsOnPage, userEntity);
+ size = size + maxItemsOnPage;
+ }
+
+ //now produce the pages
+ if (list!=null || force==true) {
+ SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(list);
+ //first we try to get the images
+ SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(list);
+ if(list!=null){
+ for (int k=0; k < list.size();k++) {
+ currentContent = (EntityContent)list.elementAt(k);
//images to content
- EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(currentContent);
- if (currentMedia!=null && currentMedia.getCount()>=1) {
- SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
- mergeData.put("to_media", mediaList);
- }
+ EntityList currentMedia = DatabaseContentToMedia.getInstance().getImages(currentContent);
+ if (currentMedia!=null && currentMedia.getCount()>=1) {
+ SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+ mergeData.put("to_media", mediaList);
+ }
//content to html
if(currentContent.getValue("is_html").equals("0")){
String temp = (String)currentContent.getValue("description");
currentContent.setValueForProperty("description",temp);
}
}
- }
- mergeData.put("images", imageHash);
- }
-
- //process hashmap additional and add to mergedata
- if (additional != null) {
- Set set = additional.keySet();
- for (Iterator it = set.iterator();it.hasNext();) {
- String key = (String)it.next();
- mergeData.put(key,(TemplateModel)additional.get(key));
- }
- }
-
- if (i==0){
- htmlFileName = producerDocRoot + "/" + fileDesc + ".shtml";
- mergeData.put("filename",fileDesc + ".shtml");
- mergeData.put("previousPage","");
- if(numberOfPages<=1){
- mergeData.put("nextPage","");
- } else {
- mergeData.put("nextPage",fileDesc + (numberOfPages-1) + ".shtml");
- }
- } else {
- if (i==1 && numberOfPages > 2){
- mergeData.put("previousPage",fileDesc + ".shtml");
- mergeData.put("nextPage",fileDesc + (numberOfPages-2) + ".shtml");
- } else {
- if (i==(numberOfPages-1)){
- mergeData.put("previousPage",fileDesc + (numberOfPages-i+1) + ".shtml");
- mergeData.put("nextPage","");
- } else {
- mergeData.put("previousPage",fileDesc + (numberOfPages-(i-1)) + ".shtml");
- mergeData.put("nextPage",fileDesc + (numberOfPages-(i+1)) + ".shtml");
- }
- }
- htmlFileName = producerDocRoot + "/" + fileDesc + (numberOfPages-i) + ".shtml";
- mergeData.put("filename",fileDesc + (numberOfPages-i) + ".shtml");
- }
-
- //producing the html-files
- boolean retVal = produce(listTemplate, htmlFileName, mergeData, htmlout);
- } //end if
- }//end for
-
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.List finished: " + sessionConnectTime + " ms.");
- } //end handle
-
- abstract public void setAdditional(String key, TemplateModel value);
+ }
+ }
+
+ //process hashmap additional and add to mergedata
+ if (additional != null) {
+ Set set = additional.keySet();
+ for (Iterator it = set.iterator();it.hasNext();) {
+ String key = (String)it.next();
+ mergeData.put(key,(TemplateModel)additional.get(key));
+ }
+ }
+
+ if (i==0){
+ htmlFileName = producerDocRoot + "/" + fileDesc + ".shtml";
+ mergeData.put("filename",fileDesc + ".shtml");
+ mergeData.put("previousPage","");
+ if(numberOfPages<=1){
+ mergeData.put("nextPage","");
+ } else {
+ mergeData.put("nextPage",fileDesc + (numberOfPages-1) + ".shtml");
+ }
+ } else {
+ if (i==1 && numberOfPages > 2){
+ mergeData.put("previousPage",fileDesc + ".shtml");
+ mergeData.put("nextPage",fileDesc + (numberOfPages-2) + ".shtml");
+ } else {
+ if (i==(numberOfPages-1)){
+ mergeData.put("previousPage",fileDesc + (numberOfPages-i+1) + ".shtml");
+ mergeData.put("nextPage","");
+ } else {
+ mergeData.put("previousPage",fileDesc + (numberOfPages-(i-1)) + ".shtml");
+ mergeData.put("nextPage",fileDesc + (numberOfPages-(i+1)) + ".shtml");
+ }
+ }
+ htmlFileName = producerDocRoot + "/" + fileDesc + (numberOfPages-i) + ".shtml";
+ mergeData.put("filename",fileDesc + (numberOfPages-i) + ".shtml");
+ }
+
+ //producing the html-files
+ boolean retVal = produce(listTemplate, htmlFileName, mergeData, htmlout);
+ } //end if
+ }//end for
+
+ sessionConnectTime = new java.util.Date().getTime() - startTime;
+ logHTML(htmlout, "Producer.List finished: " + sessionConnectTime + " ms.");
+ } //end handle
+
+ abstract public void setAdditional(String key, TemplateModel value);
}
public class ProducerTopics extends ProducerList {
- public String where;
+ public String where;
- public void setAdditional(String key, TemplateModel value) {
- additional.put(key,value);
- }
+ 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 {
handle(htmlout,user,force,sync);
}
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
- throws StorageObjectException, ModuleException {
+ public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
+ throws StorageObjectException, ModuleException {
- orderBy="date desc, webdb_create desc";
- listTemplate = MirConfig.getProp("Producer.TopicList.Template");
+ orderBy="date desc, webdb_create desc";
+ listTemplate = MirConfig.getProp("Producer.TopicList.Template");
EntityList topicsEntityList;
if(where==null){
} else {
topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
}
- SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
+ SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList);
- for(int i=0; i < topicsEntityList.size(); i++){
+ for(int i=0; i < topicsEntityList.size(); i++){
- EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
- EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
+ EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
+ EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
String whereClauseSpecial=null;
if (contentEntityList!=null || force==true) {
// 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)));
- }
+ if(entityList != null && entityList.size()==1){
+ currentContent = (EntityContent)entityList.elementAt(0);
+ SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent);
+ // get the images
+ EntityList currentMedia = DatabaseContentToMedia.getInstance().getImages(currentContent);
+ if (currentMedia!=null && currentMedia.getCount()>=1) {
+ SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+ specialHash.put("to_media",mediaList);
}
- setAdditional("specialimage",imageHash);
+ setAdditional("special",specialHash);
}
- 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
+ }
+
+ 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());
+ }
+ }
+}