templateModelRoot ist now a simplehash with two entries: data and config, bugfix...
[mir.git] / source / mircoders / entity / EntityComment.java
index 462a636..b99e30a 100755 (executable)
@@ -5,9 +5,9 @@ import java.io.*;
 import java.util.*;
 import java.sql.*;
 
-import webdb.entity.*;
-import webdb.misc.*;
-import webdb.storage.*;
+import mir.entity.*;
+import mir.misc.*;
+import mir.storage.*;
 
 import mir.storage.*;
 
@@ -19,51 +19,71 @@ 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) {
-               this();
-               setStorage(theStorage);
-       }
+  public EntityComment()
+  {
+    super();
+  }
 
-       public HashMap getValues() {
-               HashMap returnHash = super.getValues();
-               String create = (String)returnHash.get("webdb_create");
-               returnHash.put("date",StringUtil.dateToReadableDate(create));
+  public EntityComment(StorageObject theStorage) {
+    this();
+    setStorage(theStorage);
+  }
 
-               return returnHash;
-       }
 
-/**
- * overridden method setValues to patch creator_main_url
- */
+  /**
+   * overridden method setValues to patch creator_main_url
+   */
+  public void setValues(HashMap theStringValues)
+  {
+    if (theStringValues != null) {
+      if (!theStringValues.containsKey("is_published")) {
+       theStringValues.put("is_published","0");
+                       }
 
-       public void setValues(HashMap theStringValues)
-       {
-               if (theStringValues != null) {
-                       if (!theStringValues.containsKey("is_published"))
-                        theStringValues.put("is_published","0");
-                       if (theStringValues.containsKey("main_url"))
+                       if (theStringValues.containsKey("main_url")){
                                if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) {
                                        theStringValues.remove("main_url");
-        } else if (!((String)theStringValues.get("main_url")).startsWith("http://")){
-          theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url")));
-        }
-               }
-               super.setValues(theStringValues);
+                               } else if ((!((String)theStringValues.get("main_url")).startsWith("http://"))
+                                                                       && ((String)theStringValues.get("main_url")).length()>0){
+                                       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();
-  }
 }