small fixes here and there
authorzapata <zapata>
Fri, 5 Jul 2002 00:22:26 +0000 (00:22 +0000)
committerzapata <zapata>
Fri, 5 Jul 2002 00:22:26 +0000 (00:22 +0000)
source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java
source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java
source/mircoders/servlet/ServletModuleOpenIndy.java

index 91488c2..136a908 100755 (executable)
@@ -51,6 +51,8 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     try {\r
       anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create");\r
       anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());\r
+\r
+      anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
     }\r
     catch (Throwable t) {\r
       throw new MirLocalizerFailure(t.getMessage(), t);\r
@@ -117,7 +119,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
 \r
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
-        if (anEntityAdapter.get("is_html").equals("0")) {\r
+        if (anEntityAdapter.get("is_html")!=null && anEntityAdapter.get("is_html").equals("0")) {\r
           return MirGlobal.localizer().producerAssistant().filterText((String) anEntityAdapter.get(fieldName));\r
         }\r
         else {\r
index 7c8e8f7..761fe58 100755 (executable)
@@ -5,6 +5,7 @@ import java.io.*;
 import freemarker.template.utility.*;
 import mir.misc.*;
 import mir.entity.*;
+import mir.util.*;
 import mircoders.module.*;
 import mircoders.storage.*;
 import mircoders.localizer.*;
@@ -19,20 +20,20 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
     Map configMap = new HashMap();
     Map utilityMap = new HashMap();
 
-               configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
-               configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
+    configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
+    configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
     configMap.put("productionHost", MirGlobal.getConfigProperty("Producer.ProductionHost"));
-               configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
-               configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
-               configMap.put("now", StringUtil.date2readableDateTime(new GregorianCalendar()));
-               configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
-               configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
-               configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
-               configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
-               configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
-               configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
-
-               utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+    configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
+    configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
+    configMap.put("now", new DateToMapAdapter((new GregorianCalendar()).getTime()));
+    configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
+    configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
+    configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
+    configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
+    configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
+    configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
+
+    utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
 
     aValueSet.put("config", configMap);
     aValueSet.put("utility", utilityMap);
index 1c7ed36..32ad063 100755 (executable)
@@ -62,7 +62,7 @@ public class ServletModuleOpenIndy extends ServletModule
       postingFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDoneTemplate");
       postingFormDupeTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDupeTemplate");
       directOp = MirConfig.getProp("DirectOpenposting").toLowerCase();
-                       passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
+      passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
       mainModule = new ModuleComment(DatabaseComment.getInstance());
       contentModule = new ModuleContent(DatabaseContent.getInstance());
       themenModule = new ModuleTopics(DatabaseTopics.getInstance());
@@ -83,18 +83,26 @@ public class ServletModuleOpenIndy extends ServletModule
   public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
   {
     String aid = req.getParameter("aid"); // the article id the comment will belong to
+    String language = req.getParameter("language");
+
     if (aid!=null && !aid.equals(""))
     {
-                       SimpleHash mergeData = new SimpleHash();
+      SimpleHash mergeData = new SimpleHash();
+
+      // onetimepasswd
+      if(passwdProtection.equals("yes")){
+        String passwd = this.createOneTimePasswd();
+        System.out.println(passwd);
+        HttpSession session = req.getSession(false);
+        session.setAttribute("passwd",passwd);
+        mergeData.put("passwd", passwd);
+      }
 
-                       // onetimepasswd
-                       if(passwdProtection.equals("yes")){
-                               String passwd = this.createOneTimePasswd();
-                               System.out.println(passwd);
-                               HttpSession session = req.getSession(false);
-                               session.setAttribute("passwd",passwd);
-                               mergeData.put("passwd", passwd);
-                       }
+      if (language!=null) {
+        HttpSession session = req.getSession(false);
+        session.setAttribute("Locale", new Locale(language, ""));
+        session.setAttribute("passwd",language);
+      }
 
       mergeData.put("aid", aid);
       deliver(req, res, mergeData, commentFormTemplate);
@@ -108,7 +116,7 @@ public class ServletModuleOpenIndy extends ServletModule
    */
 
   public void inscomment(HttpServletRequest req, HttpServletResponse res)
-       throws ServletModuleException,ServletModuleUserException
+  throws ServletModuleException,ServletModuleUserException
   {
     String aid = req.getParameter("to_media"); // the article id the comment will belong to
     if (aid!=null && !aid.equals(""))
@@ -126,19 +134,19 @@ public class ServletModuleOpenIndy extends ServletModule
         }
         withValues.put("is_published","1");
 
-                               //checking the onetimepasswd
-                               if(passwdProtection.equals("yes")){
-                                       HttpSession session = req.getSession(false);
-                                       String sessionPasswd = (String)session.getAttribute("passwd");
-                                       if ( sessionPasswd == null){
-                                               throw new ServletModuleUserException("Lost password");
-                                       }
-                                       String passwd = req.getParameter("passwd");
-                                       if ( passwd == null || (!sessionPasswd.equals(passwd))) {
-                                               throw new ServletModuleUserException("Missing password");
-                                       }
-                                       session.invalidate();
-                               }
+        //checking the onetimepasswd
+        if(passwdProtection.equals("yes")){
+          HttpSession session = req.getSession(false);
+          String sessionPasswd = (String)session.getAttribute("passwd");
+          if ( sessionPasswd == null){
+            throw new ServletModuleUserException("Lost password");
+          }
+          String passwd = req.getParameter("passwd");
+          if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+            throw new ServletModuleUserException("Missing password");
+          }
+          session.invalidate();
+        }
 
         // inserting into database
         String id = mainModule.add(withValues);
@@ -174,14 +182,14 @@ public class ServletModuleOpenIndy extends ServletModule
     throws ServletModuleException {
     SimpleHash mergeData = new SimpleHash();
 
-               // onetimepasswd
-               if(passwdProtection.equals("yes")){
-                       String passwd = this.createOneTimePasswd();
-                       System.out.println(passwd);
-                       HttpSession session = req.getSession(false);
-                       session.setAttribute("passwd",passwd);
-                       mergeData.put("passwd", passwd);
-               }
+    // onetimepasswd
+    if(passwdProtection.equals("yes")){
+      String passwd = this.createOneTimePasswd();
+      System.out.println(passwd);
+      HttpSession session = req.getSession(false);
+      session.setAttribute("passwd",passwd);
+      mergeData.put("passwd", passwd);
+    }
 
     String maxMedia = MirConfig.getProp("ServletModule.OpenIndy.MaxMediaUploadItems");
     String numOfMedia = req.getParameter("medianum");
@@ -235,26 +243,26 @@ public class ServletModuleOpenIndy extends ServletModule
   {
     SimpleHash mergeData = new SimpleHash();
     boolean setMedia=false;
-               boolean setTopic = false;
+    boolean setTopic = false;
 
     try {
       WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
 
       HashMap withValues = mp.getParameters();
 
-                       //checking the onetimepasswd
-                       if(passwdProtection.equals("yes")){
-                               HttpSession session = req.getSession(false);
-                               String sessionPasswd = (String)session.getAttribute("passwd");
-                               if ( sessionPasswd == null){
-                                       throw new ServletModuleUserException("Lost password");
-                               }
-                               String passwd = (String)withValues.get("passwd");
-                               if ( passwd == null || (!sessionPasswd.equals(passwd))) {
-                                       throw new ServletModuleUserException("Missing password");
-                               }
-                               session.invalidate();
-                       }
+      //checking the onetimepasswd
+      if(passwdProtection.equals("yes")){
+        HttpSession session = req.getSession(false);
+        String sessionPasswd = (String)session.getAttribute("passwd");
+        if ( sessionPasswd == null){
+          throw new ServletModuleUserException("Lost password");
+        }
+        String passwd = (String)withValues.get("passwd");
+        if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+          throw new ServletModuleUserException("Missing password");
+        }
+        session.invalidate();
+      }
 
       if ((((String)withValues.get("title")).length() == 0) ||
           (((String)withValues.get("description")).length() == 0) ||
@@ -309,7 +317,7 @@ public class ServletModuleOpenIndy extends ServletModule
 
       String[] to_topicsArr = mp.getParameterValues("to_topic");
 
-                       if (to_topicsArr != null && to_topicsArr.length > 0) {
+      if (to_topicsArr != null && to_topicsArr.length > 0) {
         try{
           DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
           setTopic = true;
@@ -516,15 +524,15 @@ public class ServletModuleOpenIndy extends ServletModule
         +"Error One or more files of unrecognized type. Sorry");
   }
 
-       protected String createOneTimePasswd(){
-               Random r = new Random();
-               int random = r.nextInt();
-               long l = System.currentTimeMillis();
-               l = (l*l*l*l)/random;
-               if(l<0) l = l * -1;
-               String returnString = ""+l;
-               return returnString.substring(5);
-       }
+  protected String createOneTimePasswd(){
+    Random r = new Random();
+    int random = r.nextInt();
+    long l = System.currentTimeMillis();
+    l = (l*l*l*l)/random;
+    if(l<0) l = l * -1;
+    String returnString = ""+l;
+    return returnString.substring(5);
+  }
 
 }