From: idfx Date: Tue, 18 Sep 2001 17:41:08 +0000 (+0000) Subject: mutlifile-upload in openmir X-Git-Tag: prexmlproducerconfig~472 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=70f9cdbf12f09467b18095aa005a9eee6bafa359;p=mir.git mutlifile-upload in openmir --- diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index 2d58b076..bf4df631 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -142,13 +142,7 @@ public class ProducerContent extends Producer { SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia); mergeData.put("to_media", mediaList); } - /** - currentMediaId = currentContent.getValue("to_media"); - if (currentMediaId!=null && !currentMediaId.equals("")) { - imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); - } - mergeData.put("images", imageHash); - */ + // get the comments for the article mergeData.put("comments", currentContent.getComments()); diff --git a/source/mircoders/producer/ProducerList.java b/source/mircoders/producer/ProducerList.java index da5ea9b0..27d10d0c 100755 --- a/source/mircoders/producer/ProducerList.java +++ b/source/mircoders/producer/ProducerList.java @@ -20,80 +20,80 @@ import mircoders.storage.*; 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"); @@ -109,53 +109,52 @@ abstract public class ProducerList extends Producer { 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); } diff --git a/source/mircoders/producer/ProducerTopics.java b/source/mircoders/producer/ProducerTopics.java index 75356d46..7b8ac841 100755 --- a/source/mircoders/producer/ProducerTopics.java +++ b/source/mircoders/producer/ProducerTopics.java @@ -19,11 +19,11 @@ import mircoders.storage.*; 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 { @@ -31,11 +31,11 @@ public class ProducerTopics extends ProducerList { 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){ @@ -43,12 +43,12 @@ public class ProducerTopics extends ProducerList { } 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) { @@ -82,35 +82,34 @@ public class ProducerTopics extends ProducerList { // 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()); + } + } +} diff --git a/templates-dist/producer/topiclist.template b/templates-dist/producer/topiclist.template index 0e6b03b8..54f3090b 100755 --- a/templates-dist/producer/topiclist.template +++ b/templates-dist/producer/topiclist.template @@ -57,7 +57,7 @@

${special.title}

${special.creator}, ${special.webdb_create_formatted}

-

+

${special.description}

[read]