bugfixx: When a user selects topics in an open posting, the applicable topic pages...
authoridfx <idfx>
Sat, 2 Feb 2002 19:08:54 +0000 (19:08 +0000)
committeridfx <idfx>
Sat, 2 Feb 2002 19:08:54 +0000 (19:08 +0000)
source/mircoders/producer/ProducerList.java
source/mircoders/producer/ProducerStartPage.java
source/mircoders/producer/ProducerTopics.java
source/mircoders/servlet/ServletModuleOpenIndy.java

index 55adfcd..5a4195c 100755 (executable)
@@ -104,7 +104,9 @@ abstract public class ProducerList extends Producer {
             try {
                 //media to content
                 EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
-                if (currentMediaList!=null && currentMediaList.getCount()>=1) {
+                SimpleList contentList = (SimpleList)mergeData.get("contentlist");
+                SimpleHash contentHash = (SimpleHash)contentList.get(k);
+                                                               if (currentMediaList!=null && currentMediaList.getCount()>=1) {
                   SimpleList mediaListAudio = new SimpleList();
                   SimpleList mediaListImages = new SimpleList();
                   SimpleList mediaListVideo = new SimpleList();
@@ -139,29 +141,32 @@ abstract public class ProducerList extends Producer {
                       } //end if is_published
                     } //end if media_type != null
                   } //end for
-                  SimpleList contentList = (SimpleList)mergeData.get("contentlist");
-                  SimpleHash contentHash = (SimpleHash)contentList.get(k);
+
+
                   contentHash.put("to_media_audio", mediaListAudio);
                   contentHash.put("to_media_images", mediaListImages);
                   contentHash.put("to_media_video", mediaListVideo);
                   contentHash.put("to_media_other", mediaListOther);
                 } //end if currentMediaList != null
+                                                       
+                                                               //content to html
+                                                               if(((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ){
+                                                                       SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
+                                                                       String temp = tempScalar.getAsString();
+                                                                       if(temp!=null && temp.length()>0){
+                                                                               temp = StringUtil.createHTML(temp);
+                                                                               temp = StringUtil.decodeHTMLinTags(temp);
+                                                                               contentHash.put("description",temp);
+                                                                       }
+                                                               } else {
+                                                                       SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
+                                                                       String temp = tempScalar.getAsString();
+                                                                       if(temp!=null && temp.length()>0){
+                                                                               temp = StringUtil.decodeHTMLinTags(temp);
+                                                                               contentHash.put("description",temp);
+                                                                       }
+                                                               }
 
-                //content to html
-                if(currentContent.getValue("is_html").equals("0")){
-                  String temp = (String)currentContent.getValue("description");
-                  if(temp!=null && temp.length()>0){
-                    temp = StringUtil.createHTML(temp);
-                    temp = StringUtil.decodeHTMLinTags(temp);
-                    currentContent.setValueForProperty("description",temp);
-                  }
-                } else {
-                  String temp = (String)currentContent.getValue("description");
-                  if(temp!=null && temp.length()>0){
-                    temp = StringUtil.decodeHTMLinTags(temp);
-                    currentContent.setValueForProperty("description",temp);
-                  }
-                }
             } catch (Exception e) {
                 logHTML(htmlout, "Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString());
                 theLog.printError("Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString());
index 6092df1..1a836b1 100755 (executable)
@@ -99,7 +99,7 @@ public class ProducerStartPage extends Producer {
     SimpleList newsWireList = HTMLTemplateProcessor.makeSimpleList(entityList);
     for (int i=0; i < entityList.size();i++) {
       currentContent = (EntityContent)entityList.elementAt(i);
-      try {  
+      try {
           //fetching/setting the images
           upMediaEntityList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
           if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) {
@@ -169,7 +169,8 @@ public class ProducerStartPage extends Producer {
       try {
           //media to content
           currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
-          if (currentMediaList!=null && currentMediaList.getCount()>=1) {
+          contentHash = (SimpleHash)startItemList.get(k);
+                                       if (currentMediaList!=null && currentMediaList.getCount()>=1) {
             SimpleList mediaListAudio = new SimpleList();
             SimpleList mediaListImages = new SimpleList();
             SimpleList mediaListVideo = new SimpleList();
@@ -203,13 +204,20 @@ public class ProducerStartPage extends Producer {
                 } //end if is_published
               } //end if media_type != null
             } //end for
-            contentHash = (SimpleHash)startItemList.get(k);
             contentHash.put("to_media_audio", mediaListAudio);
             contentHash.put("to_media_images", mediaListImages);
             contentHash.put("to_media_video", mediaListVideo);
             contentHash.put("to_media_other", mediaListOther);
           } //end if currentMediaList != null
-      } catch (Exception e) {
+                                       //convert to html
+                                       if ( ((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ) {
+                                               SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
+                                               String temp = StringUtil.createHTML(tempScalar.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName);
+                                               temp = StringUtil.decodeHTMLinTags(temp);
+                                               contentHash.put("description",temp);
+                                       }
+
+                       } catch (Exception e) {
         logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping");
         theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString());
       }
@@ -232,7 +240,8 @@ public class ProducerStartPage extends Producer {
       try {
           //media to content
           currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
-          if (currentMediaList!=null && currentMediaList.getCount()>=1) {
+          contentHash = (SimpleHash)featureList.get(k);
+                                       if (currentMediaList!=null && currentMediaList.getCount()>=1) {
             SimpleList mediaListAudio = new SimpleList();
             SimpleList mediaListImages = new SimpleList();
             SimpleList mediaListVideo = new SimpleList();
@@ -266,13 +275,21 @@ public class ProducerStartPage extends Producer {
                 } //end if is_published
               } //end if media_type != null
             } //end for
-            contentHash = (SimpleHash)featureList.get(k);
             contentHash.put("to_media_audio", mediaListAudio);
             contentHash.put("to_media_images", mediaListImages);
             contentHash.put("to_media_video", mediaListVideo);
             contentHash.put("to_media_other", mediaListOther);
           } //end if currentMediaList != null
-      } catch (Exception e) {
+                                       
+                                       //convert to html
+                                       if ( ((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ) {
+                                               SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
+                                               String temp = StringUtil.createHTML(tempScalar.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName);
+                                               temp = StringUtil.decodeHTMLinTags(temp);
+                                               contentHash.put("description",temp);
+                                       }
+
+                       } catch (Exception e) {
         logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping");
         theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString());
       }
index 2e9fa00..e23e970 100755 (executable)
@@ -101,7 +101,7 @@ public class ProducerTopics extends ProducerList {
         EntityContent currentContent;
         if(entityList != null && entityList.size()==1){
           currentContent = (EntityContent)entityList.elementAt(0);
-          try { 
+          try {
               SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent);
 
               currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
@@ -144,6 +144,11 @@ public class ProducerTopics extends ProducerList {
                 specialHash.put("to_media_video", mediaListVideo);
                 specialHash.put("to_media_other", mediaListOther);
               } //end if currentMediaList != null
+                                                       //convert to html
+                                                       if ( ((SimpleScalar)specialHash.get("is_html")).getAsString().equals("0") ) {
+                                                               SimpleScalar temp = (SimpleScalar)specialHash.get("description");
+                                                               specialHash.put("description",StringUtil.createHTML(temp.getAsString()));
+                                                       }
               setAdditional("special",specialHash);
           } catch (Exception e) {
             theLog.printError("ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());
index fe76052..db4e247 100755 (executable)
@@ -181,6 +181,7 @@ public class ServletModuleOpenIndy extends ServletModule
   {
     SimpleHash mergeData = new SimpleHash();
     boolean setMedia=false;
+               boolean setTopic = false;
 
     try {
       WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
@@ -227,7 +228,7 @@ public class ServletModuleOpenIndy extends ServletModule
       theLog.printDebugInfo("id: "+cid);
       //insert was not successfull
       if(cid==null){
-        //How do we know that it was not succesful cause of a 
+        //How do we know that it was not succesful cause of a
         //dupe, what if it failed cause of "No space left on device"?
         //Or is there something I am missing? Wouldn't it be better
         //to have an explicit dupe check and then insert? I have no
@@ -237,10 +238,12 @@ 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);
-          theLog.printError("setting content_x_topic success");
+               setTopic = true;
+                                       theLog.printError("setting content_x_topic success");
         } catch (Exception e) {
           theLog.printError("setting content_x_topic failed");
           contentModule.deleteById(cid);
@@ -264,20 +267,20 @@ public class ServletModuleOpenIndy extends ServletModule
         //if the client browser sent us unknown (text/plain is default)
         //or if we got application/octet-stream, it's possible that
         //the browser is in error, better check against the file extension
-        if (contentType.equals("text/plain") || 
+        if (contentType.equals("text/plain") ||
             contentType.equals("application/octet-stream")) {
-            /** 
+            /**
              * This is just a temporary way to get the content-type via
              * the .extension , we could maybe use a magic method, by looking
              * at the header (first few bytes) of the file. (like the file(1)
              * command).
-             * The Oreilly method  relies on the content-type that the client 
+             * The Oreilly method  relies on the content-type that the client
              * browser sends and that sometimes is application-octet stream with
              * broken/mis-configured browsers.
-             * 
-             * The map file should be Mir/content-types.properties, it's the 
-             * default Sun Java file with some additional entries that it did 
-             * not have. So if you support a new media type you have to make 
+             *
+             * The map file should be Mir/content-types.properties, it's the
+             * default Sun Java file with some additional entries that it did
+             * not have. So if you support a new media type you have to make
              * sure that it is in this file -mh
              */
             contentType = FileUtil.guessContentTypeFromName(fileName);
@@ -289,7 +292,7 @@ public class ServletModuleOpenIndy extends ServletModule
 
         theLog.printError("CONTENT TYPE IS: "+contentType);
         
-        if (contentType.equals("text/plain") || 
+        if (contentType.equals("text/plain") ||
             contentType.equals("application/octet-stream")) {
           throw new ServletModuleUserException("One or more files of unrecognized types");
         }
@@ -309,7 +312,7 @@ public class ServletModuleOpenIndy extends ServletModule
 
         //the where clause to find the media_type entry
         //from the content-type.
-        //we use the media type entry to lookup the 
+        //we use the media type entry to lookup the
         //media Handler/Storage classes
         String wc = " mime_type='"+contentType+"'";
 
@@ -384,6 +387,10 @@ public class ServletModuleOpenIndy extends ServletModule
       //if direct op producing startpage
       if (directOp.equals("yes")) new ProducerStartPage().handle(null,null);
       
+                       //produce the topicPages if set
+                       //should be more intelligent
+                       if(setTopic==true) new ProducerTopics().handle(null,null);
+                       
       // sync the server
       //should be configureable
       int exitValue = Helper.rsync();