mutlifile-upload in openmir
authoridfx <idfx>
Tue, 18 Sep 2001 17:41:08 +0000 (17:41 +0000)
committeridfx <idfx>
Tue, 18 Sep 2001 17:41:08 +0000 (17:41 +0000)
source/mircoders/producer/ProducerContent.java
source/mircoders/producer/ProducerList.java
source/mircoders/producer/ProducerTopics.java
templates-dist/producer/topiclist.template

index 2d58b07..bf4df63 100755 (executable)
@@ -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());
 
index da5ea9b..27d10d0 100755 (executable)
@@ -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);
 }
index 75356d4..7b8ac84 100755 (executable)
@@ -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());
+    }
+  }
+}
index 0e6b03b..54f3090 100755 (executable)
@@ -57,7 +57,7 @@
                       <td> 
                         <h3>${special.title}</h3>
                         <h4><i>${special.creator}, ${special.webdb_create_formatted}</i></h4>
-                        <p> <if special.to_media && special.to_media["is_published"]=="1"> 
+                        <p> <if special.to_media && special.to_media[0]["is_published"]=="1"> 
                           <img src="${special.to_media[0]["icon_path"]}" width="${special.to_media[0]["icon_width"]}" height="${special.to_media[0]["icon_height"]}" alt="" align="left" vspace="8" hspace="8"> 
                           </if> ${special.description} </p>
                         <p align="right">[<a href="${producerDocRoot}${special.publish_path}${special.id}.shtml">read</a>]</p>