From: rk Date: Tue, 5 Feb 2002 14:21:23 +0000 (+0000) Subject: restructuring producer X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=cbc54d75af170ff6fa7af1751d8ca31aef64437a;p=mir.git restructuring producer --- diff --git a/source/mircoders/entity/EntityComment.java b/source/mircoders/entity/EntityComment.java index 7b535bed..b99e30ae 100755 --- a/source/mircoders/entity/EntityComment.java +++ b/source/mircoders/entity/EntityComment.java @@ -56,5 +56,34 @@ public class EntityComment extends Entity 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; + } + } diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java index 8eac2db8..80cc7c68 100755 --- a/source/mircoders/entity/EntityContent.java +++ b/source/mircoders/entity/EntityContent.java @@ -127,14 +127,24 @@ public class EntityContent extends Entity public String getValue(String field) { - if (field!=null && field.equals("date_formatted")) + String returnField = null; + if (field!=null) { - if (hasValueForField("date")) - return StringUtil.webdbDate2readableDate(getValue("date")); - else return null; - } - else - return super.getValue(field); + if (field.equals("date_formatted")) + { + if (hasValueForField("date")) + returnField = StringUtil.webdbDate2readableDate(getValue("date")); + } + else if (field.equals("description_parsed")) + returnField = getDescriptionParsed(); + else if (field.equals("content_data_parsed")) + returnField = getContentDataParsed(); + else + return super.getValue(field); + } + return returnField; + + } /** @@ -153,35 +163,42 @@ public class EntityContent extends Entity super.setValues(theStringValues); } - /** - * return the content_data as string - * is obsolete, because content_data is now sql-type text - - public String getContentData() - { - Connection con=null;Statement stmt=null; - byte[] content_data=null; - - try { - con = theStorageObject.getPooledCon(); - con.setAutoCommit(false); - stmt = con.createStatement(); - ResultSet rs = theStorageObject.executeSql(stmt,"select content_data from content where id="+getId()); - if(rs!=null) { - if (rs.next()) { - content_data = rs.getBytes(1); - } - rs.close(); - } - } - catch (Exception e) {theLog.printError("EntityContent :: getContent failed! "+e.toString());} - finally { - try {con.setAutoCommit(true); } catch (Exception e) {;} - theStorageObject.freeConnection(con,stmt); } - return StringUtil.encodeHtml(StringUtil.unquote( new String(content_data) )); - } -*/ + private String getContentDataParsed() { + String returnField = getValue("content_data"); + if (returnField!=null & returnField.length()>0 ) { + returnField=StringUtil.deleteForbiddenTags(returnField); + //create http-links and email-links + if (getValue("is_html").equals("0")) { + /** @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(returnField,imageRoot,mailLinkName,extLinkName,intLinkName); + } + returnField = StringUtil.decodeHTMLinTags(returnField); + } + return returnField; + } + + + private String getDescriptionParsed() { + String returnField = getValue("description"); + if (returnField != null && returnField.length()>0) { + returnField = StringUtil.deleteForbiddenTags(returnField); + if (getValue("is_html").equals("0")) { + /** @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(returnField,imageRoot,mailLinkName,extLinkName,intLinkName); + } + returnField = StringUtil.decodeHTMLinTags(returnField); + } + return returnField; + } /** * fetches all the comments belonging to an article diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index 2d4ca519..f466a3ff 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -66,7 +66,6 @@ public class ProducerContent extends Producer { String currentMediaId; EntityContent currentContent; EntityList batchEntityList; - HashMap currentContentValues; SimpleHash imageHash = new SimpleHash(); EntityUsers userEntity=null; Entity mediaType; @@ -103,50 +102,12 @@ public class ProducerContent extends Producer { for(int i=0;i0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } else { - String temp = (String)currentContentValues.get("content_data"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } - - //create the freemarker-model - SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); + + "/" + year + "/" + month + "/" + currentContent.getValue("id") + ".shtml"; /** @todo all the following should take place in EntityContent */ // get the uploaded media @@ -177,19 +138,7 @@ public class ProducerContent extends Producer { } //end if currentMediaList != null // get the comments for the article - // and html-ize them - - /** @todo currently this doesn't work - * all this should be moved to Entity, and the parsed description should - * be delivered via entity.get("description_parsed") */ SimpleList commentList = currentContent.getComments(); - if(commentList.isEmpty()==false){ - while(commentList.hasNext()){ - SimpleHash comment = (SimpleHash)commentList.next(); - SimpleScalar commentText = (SimpleScalar)comment.get("description"); - comment.put("description",new SimpleScalar(StringUtil.createHTML(commentText.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName))); - } - } mergeData.put("comments", commentList); // get the topics of this article diff --git a/source/mircoders/producer/ProducerList.java b/source/mircoders/producer/ProducerList.java index 99d5950e..a0765784 100755 --- a/source/mircoders/producer/ProducerList.java +++ b/source/mircoders/producer/ProducerList.java @@ -149,24 +149,6 @@ abstract public class ProducerList extends Producer { 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); - } - } - } 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()); diff --git a/source/mircoders/producer/ProducerStartPage.java b/source/mircoders/producer/ProducerStartPage.java index e9423e47..dafda02f 100755 --- a/source/mircoders/producer/ProducerStartPage.java +++ b/source/mircoders/producer/ProducerStartPage.java @@ -203,13 +203,6 @@ public class ProducerStartPage extends Producer { contentHash.put("to_media_video", mediaListVideo); contentHash.put("to_media_other", mediaListOther); } //end if currentMediaList != null - //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"); @@ -276,14 +269,6 @@ public class ProducerStartPage extends Producer { contentHash.put("to_media_other", mediaListOther); } //end if currentMediaList != null - //convert to html - theLog.printDebugInfo("############### html conversion"); - 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()); diff --git a/source/mircoders/producer/ProducerTopics.java b/source/mircoders/producer/ProducerTopics.java index 7fb06c0b..cbe48261 100755 --- a/source/mircoders/producer/ProducerTopics.java +++ b/source/mircoders/producer/ProducerTopics.java @@ -144,11 +144,7 @@ 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());