restructuring producer startpage
[mir.git] / source / mircoders / entity / EntityComment.java
index 53f3577..b99e30a 100755 (executable)
@@ -19,14 +19,12 @@ import mir.storage.*;
  */
 
 
-public class EntityComment extends AbstractEntity implements Entity
+public class EntityComment extends Entity
 {
-  private static int instances;
 
   public EntityComment()
   {
     super();
-    instances++;
   }
 
   public EntityComment(StorageObject theStorage) {
@@ -34,13 +32,6 @@ public class EntityComment extends AbstractEntity implements Entity
     setStorage(theStorage);
   }
 
-  public HashMap getValues() {
-    HashMap returnHash = super.getValues();
-    String create = (String)returnHash.get("webdb_create");
-    returnHash.put("date",StringUtil.dateToReadableDate(create));
-
-    return returnHash;
-  }
 
   /**
    * overridden method setValues to patch creator_main_url
@@ -51,26 +42,48 @@ public class EntityComment extends AbstractEntity implements Entity
       if (!theStringValues.containsKey("is_published")) {
        theStringValues.put("is_published","0");
                        }
-                   
+
                        if (theStringValues.containsKey("main_url")){
-                               theLog.printDebugInfo("------------------ http");
                                if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) {
-                                       theLog.printDebugInfo("laenge1: "+((String)theStringValues.get("main_url")).length());
                                        theStringValues.remove("main_url");
                                } else if ((!((String)theStringValues.get("main_url")).startsWith("http://"))
                                                                        && ((String)theStringValues.get("main_url")).length()>0){
-                                       theLog.printDebugInfo("laenge2: "+((String)theStringValues.get("main_url")).length());
                                        theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url")));
                                }
                        }
-                       
+
     }
     super.setValues(theStringValues);
   }
 
+       /**
+        * overridden method getValue to include formatted date into every
+        * entityContent
+        */
+
+       public String getValue(String field)
+  {
+    String returnField = null;
+    if (field!=null)
+    {
+      if (field.equals("date_formatted"))
+      {
+                 if (hasValueForField("date"))
+       returnField = StringUtil.webdbDate2readableDate(getValue("date"));
+               }
+      else if (field.equals("description_parsed")) {
+        /** @todo the config stuff should be moved to StringUtil */
+        String extLinkName = MirConfig.getProp("Producer.ExtLinkName");
+        String intLinkName = MirConfig.getProp("Producer.IntLinkName");
+        String mailLinkName = MirConfig.getProp("Producer.MailLinkName");
+        String imageRoot = MirConfig.getProp("Producer.ImageRoot");
+        returnField = StringUtil.createHTML(getValue("description"),imageRoot,mailLinkName,extLinkName,intLinkName);
+      }
+      else
+        return super.getValue(field);
+    }
+    return returnField;
+       }
+
 
-  public void finalize() {
-    instances--;
-    super.finalize();
-  }
 }