mutlifile-upload in openmir
authoridfx <idfx>
Tue, 18 Sep 2001 16:45:32 +0000 (16:45 +0000)
committeridfx <idfx>
Tue, 18 Sep 2001 16:45:32 +0000 (16:45 +0000)
13 files changed:
source/mir/misc/Configuration.java
source/mir/misc/MirConfig.java
source/mir/misc/MpRequest.java [new file with mode: 0755]
source/mir/misc/WebdbMultipartRequest.java
source/mir/servlet/ServletModuleDispatch.java
source/mircoders/producer/ProducerContent.java
source/mircoders/servlet/ServletModuleImages.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/storage/DatabaseContentToMedia.java
templates-dist/de/open/posting.template
templates-dist/en/open/posting.template
templates-dist/producer/content.template
templates-dist/producer/startpage.template

index 43bd06f..d7e208a 100755 (executable)
@@ -1,8 +1,3 @@
-/*
- * put your module comment here
- */
-
-
 package  mir.misc;
 
 import  java.net.*;
@@ -16,9 +11,7 @@ import  java.lang.*;
  *
  */
 public class Configuration {
-
-  private static int      instances=0;
-
+  
   private static HashMap  confs = new HashMap(); // key: conffilename, confHash
   private String          confFilename;
   
@@ -31,7 +24,7 @@ public class Configuration {
   }
 
   protected static Enumeration getResourceKeys() {
-    return conf.getKeys(); 
+    return conf.getKeys();
   }
 
 
@@ -106,22 +99,11 @@ public class Configuration {
   }
 
   /**
-   * Liefert Hashtabel mit den Konfigurationen
+   * Liefert Hashtable mit den Konfigurationen
    * @return
    */
   public static HashMap getConfs(){
     return confs;
   }
 
-
-  /**
-   * Finalize Methode
-   */
-  protected void finalize(){
-    instances --;
-    try {
-      super.finalize();
-    } catch (Throwable t) {}
-  }
-
 } //end of class
index 2aa322c..07676e7 100755 (executable)
@@ -1,8 +1,3 @@
-/*
- * put your module comment here
- */
-
-
 package  mir.misc;
 
 import  javax.servlet.http.*;
@@ -14,7 +9,7 @@ import  com.javaexchange.dbConnectionBroker.*;
 
 /**
  * Title:        Mir
- * Description:  Class that allows access to all Mir 
+ * Description:  Class that allows access to all Mir
  *               config values
  * Copyright:    Copyright (c) 2001
  * Company:      Indymedia
@@ -25,7 +20,7 @@ import  com.javaexchange.dbConnectionBroker.*;
 
 /**
  * This class is a layer above the Configuration
- * It manages access to config variables that are 
+ * It manages access to config variables that are
  * both generated on the fly and found in the config file.
  */
 
@@ -33,27 +28,26 @@ public class MirConfig extends Configuration {
  
   private static HashMap configHash = new HashMap();
   private static HashMap brokerHash = new HashMap();
-
   private static int      instances=0;
 
   /**
    * Initializes Configuration hash that contains all values.
-   * loads the config.properties file and any other values
-   * @param Uri, the root Uri of the install
-   * @param Home, The absolute path if the install root.
-   * @param Name, The name of the servlet (usually "Mir")
+   * loads the properties-file and any other values
+   * @param uri, the root Uri of the install
+   * @param home, The absolute path if the install root.
+   * @param name, The name of the servlet (usually "Mir")
    * @param confName, the name of the config file to load.
    */
-  public static void initConfig(String Home, String Uri, String Name, String confName) {
+  public static void initConfig(String home, String uri, String name, String confName) {
     initConfResource(confName);
 
-    configHash.put("Home", Home);
-    configHash.put("RootUri", Uri);
-    configHash.put("ServletName", Name);
+    configHash.put("Home", home);
+    configHash.put("RootUri", uri);
+    configHash.put("ServletName", name);
    
-    Enumeration ResKeys = getResourceKeys();
-    while(ResKeys.hasMoreElements()) {
-      String keyNm = (String)ResKeys.nextElement();
+    Enumeration resKeys = getResourceKeys();
+    while(resKeys.hasMoreElements()) {
+      String keyNm = (String)resKeys.nextElement();
       configHash.put(keyNm, getProperty(keyNm));
     }
   }
@@ -136,5 +130,4 @@ public class MirConfig extends Configuration {
     } catch (Throwable t) {}
   }
 
-
 }
diff --git a/source/mir/misc/MpRequest.java b/source/mir/misc/MpRequest.java
new file mode 100755 (executable)
index 0000000..fc191e2
--- /dev/null
@@ -0,0 +1,43 @@
+  /**
+   *  Datamodel of a MulitpartRequest
+   *  (inner class)
+   */
+
+package mir.misc;
+
+
+public class MpRequest{
+  byte[] uploadData=null;
+  String fileName=null;
+  String fileContentType=null;
+  
+  public MpRequest(byte[] i_uploadData, String i_fileName, String i_contentType){
+    setFilename(i_fileName);
+    setContentType(i_contentType);
+    setMedia(i_uploadData);
+  }
+
+  public byte[] getMedia() {
+    return uploadData;
+  }
+
+  public String getFilename() {
+    return fileName;
+  }
+  
+  public String getContentType() {
+    return fileContentType;
+  }
+  
+  public void setMedia(byte[] i_uploadData) {
+    uploadData=i_uploadData;
+  }
+
+  public void setFilename(String i_fileName) {
+    fileName=i_fileName;
+  }
+  
+  public void setContentType(String i_contentType) {
+    fileContentType=i_contentType;
+  }
+}
index c889c91..8e61acd 100755 (executable)
@@ -21,14 +21,13 @@ public class WebdbMultipartRequest
   HttpServletRequest    req=null;
   HashMap               parameters = new HashMap();
   MultipartParser       mp=null;
-  byte[]                uploadData=null;
-  String                fileName=null;
-  String                fileContentType=null;
+  public static ArrayList requestList;
 
   public WebdbMultipartRequest(HttpServletRequest theReq) throws IOException
   {
     req=theReq;
     mp = new MultipartParser(req, 1024*8192); // maximum eight megabyte
+    requestList = new ArrayList();
     _evaluateRequest();
   }
 
@@ -37,21 +36,11 @@ public class WebdbMultipartRequest
     return parameters;
   }
 
-  public byte[] getMedia() {
-    return uploadData;
-  }
-
-  public String getFilename() {
-    return fileName;
-  }
-  
-  public String getContentType() {
-    return fileContentType;
-  }
 
   private void _evaluateRequest() throws IOException{
 
     Part part;
+    int i = 0;
     while ((part = mp.readNextPart()) != null) {
       String name = part.getName();
       if (part.isParam()) {
@@ -63,14 +52,15 @@ public class WebdbMultipartRequest
       else if (part.isFile()) {
         // nur das erste uploadfile beruecksichtigen
         FilePart filePart = (FilePart) part;
-        fileName = filePart.getFileName();
-        fileContentType = filePart.getContentType();
-        if (fileName != null) {
+        String fn = filePart.getFileName();
+        if (filePart.getFileName() != null) {
           ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
           filePart.writeTo(byteStream);
-          uploadData=byteStream.toByteArray();
+          requestList.add(i,new MpRequest(byteStream.toByteArray(),filePart.getFileName(),filePart.getContentType()));
+          i++;
         }
       }
     } // while */
   }
+  
 }
index 8490f10..a8efff3 100755 (executable)
@@ -16,60 +16,60 @@ import  mir.misc.*;
  */
 public final class ServletModuleDispatch {
 
-       static Logfile theLog;
+  static Logfile theLog;
 
-       static {
-               theLog = Logfile.getInstance("/tmp/smod.dispatch");
-       }
+  static {
+    theLog = Logfile.getInstance("/tmp/smod.dispatch");
+  }
 
-       /**
-        * privater Konstruktor, um versehentliche Instantiierung zu verhindern
-        */
-       private ServletModuleDispatch () {
-       }
+  /**
+   * privater Konstruktor, um versehentliche Instantiierung zu verhindern
+   */
+  private ServletModuleDispatch () {
+  }
 
-       /**
-        *  Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
-        *  mit dem per HttpServletRequest angegebenen Paramter <code>do</code> auf.
-        *  Ist kein Parameter angegeben, so wird versucht, in die <code>defaultAction</code>
-        *  des ServletModules zu springen.
-        *
-        * @param req Http-Request, das vom Dispatcher an die Methode des
-        *    ServletModules durchgereicht wird
-        * @param res Http-Response, die vom Dispatcher an die Methode des
-        *    ServletModules durchgereicht wird
-        * @param sMod ServletModule, an das dispatched wird.
-        * @param mod Name des Modules als String (für Logfile)
-        */
+  /**
+   *  Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
+   *  mit dem per HttpServletRequest angegebenen Paramter <code>do</code> auf.
+   *  Ist kein Parameter angegeben, so wird versucht, in die <code>defaultAction</code>
+   *  des ServletModules zu springen.
+   *
+   * @param req Http-Request, das vom Dispatcher an die Methode des
+   *    ServletModules durchgereicht wird
+   * @param res Http-Response, die vom Dispatcher an die Methode des
+   *    ServletModules durchgereicht wird
+   * @param sMod ServletModule, an das dispatched wird.
+   * @param mod Name des Modules als String (für Logfile)
+   */
 
-       public static void dispatch(ServletModule sMod, HttpServletRequest req,
-               HttpServletResponse res) throws ServletModuleException
-       {
-                       //sMod.predeliver(req,res);
+  public static void dispatch(ServletModule sMod, HttpServletRequest req,
+    HttpServletResponse res) throws ServletModuleException
+  {
+      //sMod.predeliver(req,res);
 
-                       String doParam = req.getParameter("do");
-                       theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam);
-                       if (doParam == null) {
-                               if (sMod.defaultAction() != null) doParam = sMod.defaultAction();
-                               else throw new ServletModuleException("no parameter do supplied!");
-                       }
+      String doParam = req.getParameter("do");
+      theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam);
+      if (doParam == null) {
+        if (sMod.defaultAction() != null) doParam = sMod.defaultAction();
+        else throw new ServletModuleException("no parameter do supplied!");
+      }
 
-                       Class[] params= { HttpServletRequest.class, HttpServletResponse.class};
+      Class[] params= { HttpServletRequest.class, HttpServletResponse.class};
 
-                       try {
-                               Method method = sMod.getClass().getMethod(doParam,params);
-                               if (method != null) {
-                                       method.invoke(sMod,new Object[] {req,res} );
-                                       return;
-                               }
-                               else theLog.printDebugInfo("method lookup unsuccesful");
-                       }
-                       catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
-                       catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
-                       catch ( InvocationTargetException e) {throw new ServletModuleException("target method exception!" + e.getTargetException().toString());}
-                       catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
-//                     catch ( Exception e ) { throw new ServletModuleException(e.toString()); }
+      try {
+        Method method = sMod.getClass().getMethod(doParam,params);
+        if (method != null) {
+          method.invoke(sMod,new Object[] {req,res} );
+          return;
+        }
+        else theLog.printDebugInfo("method lookup unsuccesful");
+      }
+      catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
+      catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
+      catch ( InvocationTargetException e) {e.printStackTrace();throw new ServletModuleException("target method exception!" + e.getTargetException().toString());}
+      catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
+//      catch ( Exception e ) { throw new ServletModuleException(e.toString()); }
 
-                       throw new ServletModuleException("delivery failed! -- ");
-       }
-}
\ No newline at end of file
+      throw new ServletModuleException("delivery failed! -- ");
+  }
+}
index ceb8e7f..2d58b07 100755 (executable)
@@ -137,18 +137,18 @@ public class ProducerContent extends Producer {
         SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues);
 
         // get the images
-                               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);
+        }
+        /**
         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 8e4d19e..8ead0ef 100755 (executable)
@@ -32,297 +32,303 @@ import mircoders.module.*;
 public class ServletModuleImages extends mir.servlet.ServletModule
 {
 
-       private static ModuleMediafolder mediafolderModule;
-       private static DatabaseRights dbRights;
-       private static DatabaseImageFormat dbImageFormat;
-       private static DatabaseImageType dbImageType;
-       private static DatabaseImageColor dbImageColor;
-       private static DatabaseImageLayout dbImageLayout;
-
-       // Singelton / Kontruktor
-       private static ServletModuleImages instance = new ServletModuleImages();
-       public static ServletModule getInstance() { return instance; }
-
-
-       private ServletModuleImages() {
-               theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Bilder.Logfile"));
-               templateListString = MirConfig.getProp("ServletModule.Bilder.ListTemplate");
-               templateObjektString = MirConfig.getProp("ServletModule.Bilder.ObjektTemplate");
-               templateConfirmString = MirConfig.getProp("ServletModule.Bilder.ConfirmTemplate");
-               try {
-                       mainModule = new ModuleImages(DatabaseImages.getInstance());
-                       mediafolderModule = new ModuleMediafolder(DatabaseMediafolder.getInstance());
-                       dbRights = DatabaseRights.getInstance();
-                       dbImageFormat = DatabaseImageFormat.getInstance();
-                       dbImageColor = DatabaseImageColor.getInstance();
-                       dbImageType = DatabaseImageType.getInstance();
-                       dbImageLayout = DatabaseImageLayout.getInstance();
-               }
-               catch (StorageObjectException e) {
-                       theLog.printDebugInfo("servletmodulebilder konnte nicht initialisiert werden");
-               }
-       }
-
-
-       public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
-       {
-               try {
-                       WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
-                       HashMap parameters = mp.getParameters();
-                       byte[] imageData=mp.getMedia();
-                       String fileName=mp.getFilename();
-
-                       EntityUsers   user = _getUser(req);
-                       parameters.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
-                       parameters.put("to_publisher", user.getId());
-                       parameters.put("is_produced", "0");
-                       if (!parameters.containsKey("is_published"))
-                               parameters.put("is_published","0");
-
-                       String id = mainModule.add(parameters);
-                       EntityImage entImage = (EntityImage)mainModule.getById(id);
-
-                       if (imageData!=null && fileName!=null) {
-                               int fileType = -1;
-                               if (fileName.toLowerCase().endsWith(".jpg")) fileType=0;
-                               if (fileName.toLowerCase().endsWith(".gif")) fileType=1;
-                               if (fileType>=0)
-                                       entImage.setImage(imageData, fileType);
-                               else
-                                       theLog.printError("Wrong file uploaded!");
-                       }
-                       _edit(id, req, res);
-               }
-               catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
-               catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
-
-       }
-
-       public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
-       {
-
-               try {
-                       WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
-                       HashMap parameters = mp.getParameters();
-                       byte[] imageData=mp.getMedia();
-                       String fileName=mp.getFilename();
-
-                       EntityUsers   user = _getUser(req);
-                       parameters.put("to_publisher", user.getId());
-                       parameters.put("is_produced", "0");
-                       if (!parameters.containsKey("is_published"))
-                               parameters.put("is_published","0");
-
-                       String id = mainModule.set(parameters);
-                       EntityImage entImage = (EntityImage)mainModule.getById(id);
-
-                       if (imageData!=null && fileName!=null) {
-                               int fileType = -1;
-                               if (fileName.toLowerCase().endsWith(".jpg")) fileType=0;
-                               if (fileName.toLowerCase().endsWith(".gif")) fileType=1;
-                               if (fileType>=0)
-                                       entImage.setImage(imageData, fileType);
-                               else
-                                       theLog.printError("Wrong file uploaded!");
-                       }
-                       _edit(id, req, res);
-               }
-               catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
-               catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
-
-       }
-
-
-       public void showimg(HttpServletRequest req, HttpServletResponse res)
-               throws ServletModuleException
-       {
-               String idParam = req.getParameter("id");
-               if (idParam!=null && !idParam.equals("")) {
-                       try {
-                               EntityImage entImage =(EntityImage)mainModule.getById(idParam);
-                               res.setContentType("image/jpeg"); // testweise
-                               ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
-                               byte[] outbytes = entImage.getImage();
-                               out.write(outbytes);
-                               out.close();
-                       }
-
-                       catch (IOException e) {throw new ServletModuleException(e.toString());}
-                       catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-                       catch (Exception e) {throw new ServletModuleException(e.toString());}
-               }
-               else theLog.printDebugInfo("id nicht angeben.");
-               // darf keine exception werfen
-       }
-
-       public void showicon(HttpServletRequest req, HttpServletResponse res)
-               throws ServletModuleException
-       {
-               String idParam = req.getParameter("id");
-               if (idParam!=null && !idParam.equals("")) {
-                       try {
-                               EntityImage entImage =(EntityImage)mainModule.getById(idParam);
-                               res.setContentType("image/jpeg"); // testweise
-                               ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
-                               byte[] outbytes = entImage.getIcon();
-                               out.write(outbytes);
-                               out.close();
-                       }
-
-                       catch (IOException e) {throw new ServletModuleException(e.toString());}
-                       catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-                       catch (Exception e) {throw new ServletModuleException(e.toString());}
-               }
-               else throw new ServletModuleException("id nicht angeben.");
-       }
-
-       public void list(HttpServletRequest req, HttpServletResponse res)
-               throws ServletModuleException
-       {
-                       // Parameter auswerten
-                       SimpleHash mergeData = new SimpleHash();
-                       String query_text = req.getParameter("query_text");
-                       mergeData.put("query_text",query_text);
-                       if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text));
-                       String query_field = req.getParameter("query_field");
-                       mergeData.put("query_field",query_field);
-                       String query_is_published = req.getParameter("query_is_published");
-                       mergeData.put("query_is_published",query_is_published);
-                       String query_media_folder = req.getParameter("query_media_folder");
-                       mergeData.put("query_media_folder",query_media_folder);
-                       String offset = req.getParameter("offset");
-                       if (offset==null || offset.equals("")) offset="0";
-                       mergeData.put("offset",offset);
-
-                       String order = req.getParameter("order");
-                       if (order==null) order="webdb_lastchange desc";
-
-                       // if in connection mode to content
-                       String cid = req.getParameter("cid");
-                       mergeData.put("cid",cid);
-
-
-                       // sql basteln
-                       String whereClause=""; boolean isFirst=true;
-                       if (query_text!=null && !query_text.equalsIgnoreCase("")) {
-                               whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;}
-                       if (query_is_published != null && !query_is_published.equals("")) {
-                               if (isFirst==false) whereClause+=" and ";
-                               whereClause += "is_published='"+query_is_published+"'";
-                               isFirst=false;
-                       }
-                       if (query_media_folder != null && !query_media_folder.equals("")) {
-                               if (isFirst==false) whereClause+=" and ";
-                               whereClause += "to_media_folder='"+query_media_folder+"'";
-                       }
-                       //theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset);
-
-                       // fetch und ausliefern
-                       try {
-                               mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
-                               mergeData.put("mediafolderHashdata", mediafolderModule.getHashData());
-                               if (query_text!=null || query_is_published!=null || query_media_folder!=null) {
-                                       EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue(),10);
-                                       if (theList != null) {
-                                               mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList));
-                                               if(theList.getOrder()!=null) {
-                                                       mergeData.put("order", theList.getOrder());
-                                                       mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
-                                               }
-                                               mergeData.put("count", (new Integer(theList.getCount())).toString());
-                                               mergeData.put("from", (new Integer(theList.getFrom())).toString());
-                                               mergeData.put("to", (new Integer(theList.getTo())).toString());
-                                               if (theList.hasNextBatch())
-                                                       mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
-                                               if (theList.hasPrevBatch())
-                                                       mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
-                                       }
-                               }
-                               // raus damit
-                               HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
-                       }
-                       catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-                       catch (IOException e) {throw new ServletModuleException(e.toString());}
-                       catch (Exception e) {throw new ServletModuleException(e.toString());}
-       }
-
-
-       public void add(HttpServletRequest req, HttpServletResponse res)
-       throws ServletModuleException
-       {
-               try {
-                       SimpleHash mergeData = new SimpleHash();
-                       mergeData.put("new", "1");
-                       mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
-                       deliver(req, res, mergeData, templateObjektString);
-               }
-               catch (Exception e) { throw new ServletModuleException(e.toString());}
-       }
-
-       public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
-       {
-               String        idParam = req.getParameter("id");
-               _edit(idParam, req, res);
-       }
-
-       private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
-               if (idParam!=null && !idParam.equals("")) {
-                       try {
-                               SimpleHash mergeData =  HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam));
-                               mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
-                               mergeData.put("rightsHashdata", dbRights.getHashData());
-                               mergeData.put("imgformatHashdata", dbImageFormat.getHashData());
-                               mergeData.put("imgcolorHashdata", dbImageColor.getHashData());
-                               mergeData.put("imgtypeHashdata", dbImageType.getHashData());
-                               mergeData.put("imglayoutHashdata", dbImageLayout.getHashData());
-                               deliver(req, res, mergeData, templateObjektString);
-                       }
-                       catch (ModuleException e) { throw new ServletModuleException(e.toString());}
-               }
-               else throw new ServletModuleException("ServletmoduleImage :: _edit without id");
-       }
-
-
-       /** @todo should be in ServletModule.java */
-       private EntityUsers _getUser(HttpServletRequest req)
-       {
-               HttpSession session=req.getSession(false);
-               return (EntityUsers)session.getAttribute("login.uid");
-       }
-
-
-       // deprecated
-       public void upload(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
-       {
-               //theLog.printDebugInfo("-- trying to upload");
-               String idParam = req.getParameter("id");
-               if (idParam!=null && !idParam.equals("")) {
-                       try {
-
-                               WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
-                               HashMap withValues = mp.getParameters();
-                               byte[] imageData=mp.getMedia();
-                               String fileName=mp.getFilename();
-
-                               int fileType = -1;
-                               if (fileName.toLowerCase().endsWith(".jpg")) fileType=0;
-                               if (fileName.toLowerCase().endsWith(".gif")) fileType=1;
-                               if (fileType>=0) {
-                                       EntityImage entImage = (EntityImage)mainModule.getById(idParam);
-                                       entImage.setImage(imageData, fileType);
-                               }
-                               else
-                                       theLog.printError("Wrong file uploaded!");
-                       }
-                       catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
-                       catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
-               }
-               else // keine id
-                       throw new ServletModuleException("Keine id angegeben");
-               edit(req,res);
-       }
+  private static ModuleMediafolder mediafolderModule;
+  private static DatabaseRights dbRights;
+  private static DatabaseImageFormat dbImageFormat;
+  private static DatabaseImageType dbImageType;
+  private static DatabaseImageColor dbImageColor;
+  private static DatabaseImageLayout dbImageLayout;
+
+  // Singelton / Kontruktor
+  private static ServletModuleImages instance = new ServletModuleImages();
+  public static ServletModule getInstance() { return instance; }
+
+
+  private ServletModuleImages() {
+    theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Bilder.Logfile"));
+    templateListString = MirConfig.getProp("ServletModule.Bilder.ListTemplate");
+    templateObjektString = MirConfig.getProp("ServletModule.Bilder.ObjektTemplate");
+    templateConfirmString = MirConfig.getProp("ServletModule.Bilder.ConfirmTemplate");
+    try {
+      mainModule = new ModuleImages(DatabaseImages.getInstance());
+      mediafolderModule = new ModuleMediafolder(DatabaseMediafolder.getInstance());
+      dbRights = DatabaseRights.getInstance();
+      dbImageFormat = DatabaseImageFormat.getInstance();
+      dbImageColor = DatabaseImageColor.getInstance();
+      dbImageType = DatabaseImageType.getInstance();
+      dbImageLayout = DatabaseImageLayout.getInstance();
+    }
+    catch (StorageObjectException e) {
+      theLog.printDebugInfo("servletmodulebilder konnte nicht initialisiert werden");
+    }
+  }
+
+
+  public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  {
+    try {
+      WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
+      HashMap parameters = mp.getParameters();
+      MpRequest mpReq = (MpRequest)mp.requestList.get(0);
+      byte[] imageData=mpReq.getMedia();
+      String fileName=mpReq.getFilename();
+      String contentType= mpReq.getContentType();
+
+      EntityUsers   user = _getUser(req);
+      parameters.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
+      parameters.put("to_publisher", user.getId());
+      parameters.put("is_produced", "0");
+      if (!parameters.containsKey("is_published"))
+        parameters.put("is_published","0");
+
+      String id = mainModule.add(parameters);
+      EntityImage entImage = (EntityImage)mainModule.getById(id);
+
+      if (imageData!=null && fileName!=null) {
+        int fileType = -1;
+        if (contentType.equals("image/jpeg")) fileType=0;
+        if (contentType.equals("image/gif")) fileType=1;
+        if (fileType>=0)
+          entImage.setImage(imageData, fileType);
+        else
+          theLog.printError("Wrong file uploaded!");
+      }
+      _edit(id, req, res);
+    }
+    catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
+    catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
+
+  }
+
+  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  {
+
+    try {
+      WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
+      HashMap parameters = mp.getParameters();
+      MpRequest mpReq = (MpRequest)mp.requestList.get(0);
+      byte[] imageData=mpReq.getMedia();
+      String fileName=mpReq.getFilename();
+      String contentType=mpReq.getContentType();
+
+      EntityUsers   user = _getUser(req);
+      parameters.put("to_publisher", user.getId());
+      parameters.put("is_produced", "0");
+      if (!parameters.containsKey("is_published"))
+        parameters.put("is_published","0");
+
+      String id = mainModule.set(parameters);
+      EntityImage entImage = (EntityImage)mainModule.getById(id);
+
+      if (imageData!=null && fileName!=null) {
+        int fileType = -1;
+        if (contentType.equals("image/jpeg")) fileType=0;
+        if (contentType.equals("image/gif")) fileType=1;
+        if (fileType>=0)
+          entImage.setImage(imageData, fileType);
+        else
+          theLog.printError("Wrong file uploaded!");
+      }
+      _edit(id, req, res);
+    }
+    catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
+    catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
+
+  }
+
+
+  public void showimg(HttpServletRequest req, HttpServletResponse res)
+    throws ServletModuleException
+  {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityImage entImage =(EntityImage)mainModule.getById(idParam);
+        res.setContentType("image/jpeg"); // testweise
+        ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
+
+        byte[] outbytes = entImage.getImage();
+        out.write(outbytes);
+        out.close();
+      }
+
+      catch (IOException e) {throw new ServletModuleException(e.toString());}
+      catch (ModuleException e) {throw new ServletModuleException(e.toString());}
+      catch (Exception e) {throw new ServletModuleException(e.toString());}
+    }
+    else theLog.printDebugInfo("id nicht angeben.");
+    // darf keine exception werfen
+  }
+
+  public void showicon(HttpServletRequest req, HttpServletResponse res)
+    throws ServletModuleException
+  {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityImage entImage =(EntityImage)mainModule.getById(idParam);
+        res.setContentType("image/jpeg"); // testweise
+        ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
+
+        byte[] outbytes = entImage.getIcon();
+        out.write(outbytes);
+        out.close();
+      }
+
+      catch (IOException e) {throw new ServletModuleException(e.toString());}
+      catch (ModuleException e) {throw new ServletModuleException(e.toString());}
+      catch (Exception e) {throw new ServletModuleException(e.toString());}
+    }
+    else throw new ServletModuleException("id nicht angeben.");
+  }
+
+  public void list(HttpServletRequest req, HttpServletResponse res)
+    throws ServletModuleException
+  {
+      // Parameter auswerten
+      SimpleHash mergeData = new SimpleHash();
+      String query_text = req.getParameter("query_text");
+      mergeData.put("query_text",query_text);
+      if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text));
+      String query_field = req.getParameter("query_field");
+      mergeData.put("query_field",query_field);
+      String query_is_published = req.getParameter("query_is_published");
+      mergeData.put("query_is_published",query_is_published);
+      String query_media_folder = req.getParameter("query_media_folder");
+      mergeData.put("query_media_folder",query_media_folder);
+      String offset = req.getParameter("offset");
+      if (offset==null || offset.equals("")) offset="0";
+      mergeData.put("offset",offset);
+
+      String order = req.getParameter("order");
+      if (order==null) order="webdb_lastchange desc";
+
+      // if in connection mode to content
+      String cid = req.getParameter("cid");
+      mergeData.put("cid",cid);
+
+
+      // sql basteln
+      String whereClause=""; boolean isFirst=true;
+      if (query_text!=null && !query_text.equalsIgnoreCase("")) {
+        whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;}
+      if (query_is_published != null && !query_is_published.equals("")) {
+        if (isFirst==false) whereClause+=" and ";
+        whereClause += "is_published='"+query_is_published+"'";
+        isFirst=false;
+      }
+      if (query_media_folder != null && !query_media_folder.equals("")) {
+        if (isFirst==false) whereClause+=" and ";
+        whereClause += "to_media_folder='"+query_media_folder+"'";
+      }
+      //theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset);
+
+      // fetch und ausliefern
+      try {
+        mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
+        mergeData.put("mediafolderHashdata", mediafolderModule.getHashData());
+        if (query_text!=null || query_is_published!=null || query_media_folder!=null) {
+          EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue(),10);
+          if (theList != null) {
+            mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList));
+            if(theList.getOrder()!=null) {
+              mergeData.put("order", theList.getOrder());
+              mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
+            }
+            mergeData.put("count", (new Integer(theList.getCount())).toString());
+            mergeData.put("from", (new Integer(theList.getFrom())).toString());
+            mergeData.put("to", (new Integer(theList.getTo())).toString());
+            if (theList.hasNextBatch())
+              mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
+            if (theList.hasPrevBatch())
+              mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
+          }
+        }
+        // raus damit
+        HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+      }
+      catch (ModuleException e) {throw new ServletModuleException(e.toString());}
+      catch (IOException e) {throw new ServletModuleException(e.toString());}
+      catch (Exception e) {throw new ServletModuleException(e.toString());}
+  }
+
+
+  public void add(HttpServletRequest req, HttpServletResponse res)
+  throws ServletModuleException
+  {
+    try {
+      SimpleHash mergeData = new SimpleHash();
+      mergeData.put("new", "1");
+      mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
+      deliver(req, res, mergeData, templateObjektString);
+    }
+    catch (Exception e) { throw new ServletModuleException(e.toString());}
+  }
+
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  {
+    String        idParam = req.getParameter("id");
+    _edit(idParam, req, res);
+  }
+
+  private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        SimpleHash mergeData =  HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam));
+        mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData());
+        mergeData.put("rightsHashdata", dbRights.getHashData());
+        mergeData.put("imgformatHashdata", dbImageFormat.getHashData());
+        mergeData.put("imgcolorHashdata", dbImageColor.getHashData());
+        mergeData.put("imgtypeHashdata", dbImageType.getHashData());
+        mergeData.put("imglayoutHashdata", dbImageLayout.getHashData());
+        deliver(req, res, mergeData, templateObjektString);
+      }
+      catch (ModuleException e) { throw new ServletModuleException(e.toString());}
+    }
+    else throw new ServletModuleException("ServletmoduleImage :: _edit without id");
+  }
+
+
+  /** @todo should be in ServletModule.java */
+  private EntityUsers _getUser(HttpServletRequest req)
+  {
+    HttpSession session=req.getSession(false);
+    return (EntityUsers)session.getAttribute("login.uid");
+  }
+
+
+  // deprecated
+  public void upload(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
+  {
+    //theLog.printDebugInfo("-- trying to upload");
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+
+        WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
+        HashMap withValues = mp.getParameters();
+        MpRequest mpReq = (MpRequest)mp.requestList.get(0);
+        byte[] imageData=mpReq.getMedia();
+        String fileName=mpReq.getFilename();
+        String contentType=mpReq.getContentType();
+
+        int fileType = -1;
+        if (contentType.equals("image/jpeg")) fileType=0;
+        if (contentType.equals("image/gif")) fileType=1;
+        if (fileType>=0) {
+          EntityImage entImage = (EntityImage)mainModule.getById(idParam);
+          entImage.setImage(imageData, fileType);
+        }
+        else
+          theLog.printError("Wrong file uploaded!");
+      }
+      catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());}
+      catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());}
+    }
+    else // keine id
+      throw new ServletModuleException("Keine id angegeben");
+    edit(req,res);
+  }
 
 
 }
index be5d5a9..cc4e926 100755 (executable)
@@ -51,7 +51,6 @@ public class ServletModuleOpenIndy extends ServletModule
       postingFormTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingTemplate");
       postingFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDoneTemplate");
       directOp = MirConfig.getProp("DirectOpenposting").toLowerCase();
-      //directOp="yes";
       mainModule = new ModuleComment(DatabaseComment.getInstance());
       contentModule = new ModuleContent(DatabaseContent.getInstance());
       imageModule = new ModuleImages(DatabaseImages.getInstance());
@@ -103,7 +102,7 @@ public class ServletModuleOpenIndy extends ServletModule
 
         // sync the server
         int exitValue = Helper.rsync();
-                               theLog.printDebugInfo("rsync:"+exitValue);
+        theLog.printDebugInfo("rsync:"+exitValue);
 
         // redirecting to url
         // should implement back to article
@@ -125,6 +124,21 @@ public class ServletModuleOpenIndy extends ServletModule
   public void addposting(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
   {
     SimpleHash mergeData = new SimpleHash();
+    String numOfMedia = req.getParameter("medianum");
+    if(numOfMedia==null||numOfMedia.equals("")){
+      numOfMedia="1";
+    }
+    
+    int mediaNum = Integer.parseInt(numOfMedia);
+    SimpleList mediaFields = new SimpleList();
+    for(int i =0; i<mediaNum;i++){
+      Integer mNum = new Integer(i+1);
+      mediaFields.add(mNum.toString());
+    }
+    mergeData.put("medianum",numOfMedia);
+    mergeData.put("mediafields",mediaFields);
+    
+    
     /** @todo popups missing */
     try{
       mergeData.put("languagePopUpData",DatabaseLanguage.getInstance().getPopupData());
@@ -146,54 +160,9 @@ public class ServletModuleOpenIndy extends ServletModule
     boolean setMedia=false;
 
     try {
-
       WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
+          
       HashMap withValues = mp.getParameters();
-      byte[] mediaData=mp.getMedia();
-      String fileName=mp.getFilename();
-      
-      theLog.printDebugInfo("ContentType: "+mp.getContentType());
-      
-      // if op contains imagedata
-      String mediaId=null;
-      if (mediaData!=null && fileName!=null) {
-        HashMap mediaValues = new HashMap();
-        mediaValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
-        mediaValues.put("to_publisher", "1"); // op user
-        mediaValues.put("to_media_folder", "7"); // op media_folder
-        mediaValues.put("is_produced", "0");
-        mediaValues.put("is_published","1");
-
-        String mediaTitle=(String)withValues.get("media_title");
-        if (mediaTitle==null)
-          mediaTitle = (String)withValues.get("title");
-        mediaValues.put("title",mediaTitle);
-
-        if (fileName.toLowerCase().endsWith("rm")) {
-          // this is video !!
-          //theLog.printDebugInfo("--GOT VIDEO");
-          EntityVideo entVideo = new EntityVideo(DatabaseVideos.getInstance());
-          entVideo.setValues(mediaValues);
-          mediaId = entVideo.insert();
-          entVideo.setVideoData(mediaData);
-        }
-        else if (fileName.toLowerCase().endsWith(".jpg") || fileName.toLowerCase().endsWith(".gif")) {
-          // this is image !!
-          mediaId = imageModule.add(mediaValues);
-          EntityImage entImage = (EntityImage)imageModule.getById(mediaId);
-
-          int fileType = -1;
-          if (fileName.toLowerCase().endsWith(".jpg")) fileType=0;
-          if (fileName.toLowerCase().endsWith(".gif")) fileType=1;
-          if (fileType>=0) {
-            entImage.setImage(mediaData, fileType);
-            setMedia=true;
-          }
-          else
-            theLog.printDebugInfo("Wrong file uploaded!" + fileName);
-        }
-      }
-
       withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
       withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));
       withValues.put("is_produced", "0");
@@ -201,7 +170,6 @@ public class ServletModuleOpenIndy extends ServletModule
       withValues.put("is_published","1");
       // if op direct article-type == newswire
       if (directOp.equals("yes")) withValues.put("to_article_type","1");
-      theLog.printDebugInfo("direct op: "+directOp);
       
       // owner is openposting user
       withValues.put("to_publisher","1");
@@ -209,25 +177,71 @@ public class ServletModuleOpenIndy extends ServletModule
         withValues.put("creator","Anonym");
 
       // inserting  content into database
-      String id = contentModule.add(withValues);
+      String cid = contentModule.add(withValues);
       
-      // inserting content and media id in table content_x_media
-      try{
-        DatabaseContentToMedia.getInstance().setMedia(id,mediaId);
-        theLog.printError("setting content_x_topic success");
-      } catch (Exception e) {
-        theLog.printError("setting content_x_topic failed");
+      // if op contains uploaddata
+      String mediaId=null;
+      int i=1;
+      for(Iterator it = mp.requestList.iterator(); it.hasNext();){
+        MpRequest mpReq = (MpRequest)it.next();
+        byte[] mediaData=mpReq.getMedia();
+        String fileName=mpReq.getFilename();
+        String contentType=mpReq.getContentType();
+        if (mediaData!=null && fileName!=null) {
+          HashMap mediaValues = new HashMap();
+          mediaValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
+          mediaValues.put("to_publisher", "1"); // op user
+          mediaValues.put("to_media_folder", "7"); // op media_folder
+          mediaValues.put("is_produced", "0");
+          mediaValues.put("is_published","1");
+  
+          String mediaTitle=(String)withValues.get("media_title"+i);
+          i++;
+          if (mediaTitle==null)
+            mediaTitle = (String)withValues.get("title");
+          mediaValues.put("title",mediaTitle);
+  
+          if (fileName.toLowerCase().endsWith("rm")) {
+            // this is video !!
+            //theLog.printDebugInfo("--GOT VIDEO");
+            EntityVideo entVideo = new EntityVideo(DatabaseVideos.getInstance());
+            entVideo.setValues(mediaValues);
+            mediaId = entVideo.insert();
+            entVideo.setVideoData(mediaData);
+          }
+          else if (contentType.equals("image/jpeg") || contentType.equals("image/gif")) {
+            // this is image !!
+            mediaId = imageModule.add(mediaValues);
+            EntityImage entImage = (EntityImage)imageModule.getById(mediaId);
+  
+            int fileType = -1;
+            if (contentType.equals("image/jpeg")) fileType=0;
+            if (contentType.equals("image/gif")) fileType=1;
+            if (fileType>=0) {
+              entImage.setImage(mediaData, fileType);
+              // inserting content and media id in table content_x_media
+              try{
+                DatabaseContentToMedia.getInstance().addMedia(cid,mediaId);
+                theLog.printError("setting content_x_topic success");
+              } catch (Exception e) {
+                theLog.printError("setting content_x_topic failed");
+              }
+              
+              // producing new page
+              if(mediaId!=null){
+                new ProducerImages().handle(null, null, false, false, mediaId);
+              }
+            } else {
+              theLog.printDebugInfo("Wrong file uploaded!" + fileName);
+            }
+          }
+        }
       }
 
-
-      // producing new page
-      if(mediaId!=null){
-        new ProducerImages().handle(null, null, false, false, mediaId);
-      }
       // producing openpostinglist
       new ProducerOpenPosting().handle(null,null,false,false);
       // producing new page
-      new ProducerContent().handle(null, null, false, false,id);
+      new ProducerContent().handle(null, null, false, false,cid);
       //if direct op producing startpage
       if (directOp.equals("yes")) new ProducerStartPage().handle(null,null);
       
@@ -235,12 +249,12 @@ public class ServletModuleOpenIndy extends ServletModule
       // sync the server
       //should be configureable
       int exitValue = Helper.rsync();
-                       theLog.printDebugInfo("rsync: "+exitValue);
+      theLog.printDebugInfo("rsync: "+exitValue);
 
     }
-    catch (IOException e) { throw new ServletModuleException(e.toString());}
-    catch (StorageObjectException e) { throw new ServletModuleException(e.toString());}
-    catch (ModuleException e) { throw new ServletModuleException(e.toString());}
+    catch (IOException e) { throw new ServletModuleException("IOException: "+ e.toString());}
+    catch (StorageObjectException e) { throw new ServletModuleException("StorageObjectException" + e.toString());}
+    catch (ModuleException e) { throw new ServletModuleException("ModuleException"+e.toString());}
 
     deliver(req, res, mergeData, postingFormDoneTemplate);
   }
index e154fcb..2f5b3b5 100755 (executable)
@@ -39,8 +39,11 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     this.hasTimestamp = false;
     this.theTable="content_x_media";
   }
-
-
+  
+  /**
+   * get all the media-files belonging to a content entity
+   *
+   */
   public EntityList getMedia(EntityContent content) {
     EntityList returnList=null;
     if (content != null) {
@@ -57,6 +60,27 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     }
     return returnList;
   }
+  
+  /**
+   * get all the images belonging to a content entity
+   *
+   */
+  public EntityList getImages(EntityContent content) {
+    EntityList returnList=null;
+    if (content != null) {
+      // get all to_topic from media_x_topic
+      String id = content.getId();
+      //this is not supported by mysql
+      String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
+
+      try {
+        returnList = DatabaseImages.getInstance().selectByWhereClause(subselect,-1);
+      } catch (Exception e) {
+        theLog.printDebugInfo("-- get images failed " + e.toString());
+      }
+    }
+    return returnList;
+  }
 
 
   public void setMedia(String contentId, String[] mediaId) {
@@ -120,7 +144,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       freeConnection(con,stmt);
     }
   }
-       
+  
   public void setMedia(String contentId, String mediaId) {
     if (contentId == null && mediaId == null) {
       return;
@@ -199,8 +223,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       freeConnection(con,stmt);
     }
   }
-       
-       public void delete(String contentId, String mediaId) {
+  
+  public void delete(String contentId, String mediaId) {
     if (mediaId == null || contentId==null) {
       theLog.printDebugInfo("-- delete media failed -- missing parameter");
       return;
@@ -254,39 +278,39 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     }
     return returnList;
   }
-       
+  
 /**
  * Returns a EntityList with all content-objects having a relation to a media
  */
-       
+  
 public EntityList getContent() {
     EntityList returnList=null;
     
     String select = "select distinct content_id from " + theTable;
-               // execute select statement
-               Connection con=null;Statement stmt=null;
-               try {
-                       con = getPooledCon();
-                       // should be a preparedStatement because is faster
-                       stmt = con.createStatement();
-                       ResultSet rs = executeSql(stmt,select);
-                       if (rs!=null) {
-                               String mediaSelect= "id IN (";
-                               boolean first=true;
-                               while (rs.next()) {
-                                       if (first==false) mediaSelect+=",";
-                                       mediaSelect += rs.getString(1);
-                                       first=false;
-                               }
-                               mediaSelect+=")";
-                               if (first==false)
-                                       returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,"webdb_lastchange desc");
-                       }
-               }
-               catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
-               finally { freeConnection(con,stmt);}
+    // execute select statement
+    Connection con=null;Statement stmt=null;
+    try {
+      con = getPooledCon();
+      // should be a preparedStatement because is faster
+      stmt = con.createStatement();
+      ResultSet rs = executeSql(stmt,select);
+      if (rs!=null) {
+        String mediaSelect= "id IN (";
+        boolean first=true;
+        while (rs.next()) {
+          if (first==false) mediaSelect+=",";
+          mediaSelect += rs.getString(1);
+          first=false;
+        }
+        mediaSelect+=")";
+        if (first==false)
+          returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,"webdb_lastchange desc");
+      }
+    }
+    catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+    finally { freeConnection(con,stmt);}
 
-               return returnList;
+    return returnList;
   }
 
 }
index 0106387..3b44d53 100755 (executable)
                        </ul>
                </td>
        </tr>
+<form action="${openAction}?do=addposting" method="post">
+       <tr>
+               <td>Anzahl der Medien</td>
+               <td colspan="2"><input type="text" name="medianum" value="${medianum}">&nbsp;<input type="submit">
+       </tr>
+</form>
 
 <a name="form"></a>
 <form enctype="multipart/form-data" action="${openAction}?do=insposting" method="post">
-
        <tr>
                <td bgcolor="#663399" colspan="3">
                        <center><font size="+2" face="Helvetica, Arial" color="white"><b>Ver&ouml;ffentlichungsformular</b></font></center>
                </td>
                <td colspan="2">
                        Hier kannst Du ein Medien zu Deinem Artikel hochladen (bislang nur jpg-Bilder)<br>
-                       <INPUT TYPE="file" NAME="mptest"> <font size="-1">(<i>optional</i>)</font>
+               </td>
+       </tr>
+<list mediafields as m>
+       <tr>    
+               <td>Bild ${m}</td>
+               <td colspan="2">                        
+                       <INPUT TYPE="file" NAME="media${m}"> <font size="-1">(<i>optional</i>)</font>
                </td>
        </tr>
        <tr>
                <td>
-                       Medienunterschrift:
+               Medienunterschrift ${m}:
                </td>
                <td colspan="2">
-                       <input type="text" name="media_title" size="40" maxlength="80" value=""> <font size="-1">(<i>optional</i>)</font>
+                       <input type="text" name="media_title${m}" size="40" maxlength="80" value=""> <font size="-1">(<i>optional</i>)</font>
                </td>
-       </tr>
-       
-       
+       </tr>   
+</list>
        <tr>
                <td><b          </td>
                <td bgcolor="#663399" valign="top" align="center"><br>
index 0106387..3b44d53 100755 (executable)
                        </ul>
                </td>
        </tr>
+<form action="${openAction}?do=addposting" method="post">
+       <tr>
+               <td>Anzahl der Medien</td>
+               <td colspan="2"><input type="text" name="medianum" value="${medianum}">&nbsp;<input type="submit">
+       </tr>
+</form>
 
 <a name="form"></a>
 <form enctype="multipart/form-data" action="${openAction}?do=insposting" method="post">
-
        <tr>
                <td bgcolor="#663399" colspan="3">
                        <center><font size="+2" face="Helvetica, Arial" color="white"><b>Ver&ouml;ffentlichungsformular</b></font></center>
                </td>
                <td colspan="2">
                        Hier kannst Du ein Medien zu Deinem Artikel hochladen (bislang nur jpg-Bilder)<br>
-                       <INPUT TYPE="file" NAME="mptest"> <font size="-1">(<i>optional</i>)</font>
+               </td>
+       </tr>
+<list mediafields as m>
+       <tr>    
+               <td>Bild ${m}</td>
+               <td colspan="2">                        
+                       <INPUT TYPE="file" NAME="media${m}"> <font size="-1">(<i>optional</i>)</font>
                </td>
        </tr>
        <tr>
                <td>
-                       Medienunterschrift:
+               Medienunterschrift ${m}:
                </td>
                <td colspan="2">
-                       <input type="text" name="media_title" size="40" maxlength="80" value=""> <font size="-1">(<i>optional</i>)</font>
+                       <input type="text" name="media_title${m}" size="40" maxlength="80" value=""> <font size="-1">(<i>optional</i>)</font>
                </td>
-       </tr>
-       
-       
+       </tr>   
+</list>
        <tr>
                <td><b          </td>
                <td bgcolor="#663399" valign="top" align="center"><br>
index ca8d8ef..13583dc 100755 (executable)
                       <td> 
                         <h2>${title}</h2>
                         <h4><i>${creator}, ${webdb_create_formatted}</i></h4>
-                        <p><b>${description}</b></p>
-                        <p> <if images[to_media] && images[to_media]["is_published"]=="1"> 
-                          <img src="${imageHost}${images[to_media]["id"]}.jpg" width="${images[to_media]["img_width"]}" height="${images[to_media]["img_height"]}" alt="" align="left" vspace="8" hspace="8"> 
-                          </if> ${s.description} </p>
+                        <p><b>${description}</b>
+                       <!-- images -->
+                       <list to_media as images>
+                       <p> 
+                          <if images && images["is_published"]=="1">                   
+                          <img src="${imageHost}/${images["id"]}.jpg" width="${images["img_width"]}" height="${images["img_height"]}" alt="${images["title"]}"> 
+                          </if><br><i>${images["title"]}</i>
+                       </p>
+                       </list>
+                       <!-- images -->
                        <p>${content_data}</p>
                        <if creator_main_url || creator_email>
                         <table width="100%" bgcolor="#FFFFFF">
index 89a77a8..7501769 100755 (executable)
@@ -61,7 +61,8 @@
                       </td>
                     </tr>
                   </table>
-                  </list> <!--- start-special ---> <br>
+                  </list> 
+                 <!--- start-special ---> <br>
                   <!--- features ---> <list items as i> 
                   <table width="100%" border="0" cellspacing="0" cellpadding="0">
                     <tr> 
@@ -76,7 +77,9 @@
                     </tr>
                   </table>
                   <br>
-                  </list> <!--- features ---> </td>
+                  </list> 
+                 <!--- features ---> 
+                 </td>
               </tr>
             </table>
           </td>
             <table width="150" border="0" cellspacing="2" cellpadding="0">
               <tr> 
                 <td> <!-- newswire --> 
-                  <p> <list newswire as n> <img alt="[Text]" border="0" height="10" src="/images/text_small.gif" width="12"> 
+                  <p> 
+                   <list newswire as n>
+                   <img alt="[Text]" border="0" height="10" src="/images/text_small.gif" width="12"> 
                     <a href="${producerDocRoot}${n.publish_path}${n.id}.shtml"><b>${n.title}</b></a><br>
                     <font size="-2"><b></b>${n.webdb_create_formatted}</font><br>
                     <br>
-                    </list> <!-- newswire --> </p>
+                    </list> 
+                   <!-- newswire -->
+                  </p>
                 </td>
               </tr>
             </table>