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 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;
+
+
}
/**
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
String currentMediaId;
EntityContent currentContent;
EntityList batchEntityList;
- HashMap currentContentValues;
SimpleHash imageHash = new SimpleHash();
EntityUsers userEntity=null;
Entity mediaType;
for(int i=0;i<batchEntityList.size();i++) {
currentContent = (EntityContent)batchEntityList.elementAt(i);
try {
- currentContentValues = currentContent.getValues();
-
- //because of postgres 7.1.* not needed anymore
- //currentContentValues.put("content_data",currentContent.getContentData());
- String date = (String)currentContentValues.get("date");
+ String date = currentContent.getValue("date");
String year = date.substring(0,4);
String month = date.substring(4,6);
htmlFileName = producerDocRoot
- + "/" + year + "/" + month + "/" + currentContentValues.get("id") + ".shtml";
-
- currentContentValues.put("content_data",StringUtil.deleteForbiddenTags((String)currentContentValues.get("content_data")));
- currentContentValues.put("description",StringUtil.deleteForbiddenTags((String)currentContentValues.get("description")));
-
-
- //create http-links and email-links
- if (currentContentValues.get("is_html").equals("0")) {
- String temp = (String)currentContentValues.get("content_data");
- if(temp!=null && temp.length()>0){
- 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
} //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
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());
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");
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());
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());