fixed the date format in a pdf
authorzapata <zapata>
Wed, 25 Jun 2003 03:20:58 +0000 (03:20 +0000)
committerzapata <zapata>
Wed, 25 Jun 2003 03:20:58 +0000 (03:20 +0000)
etc/config.properties-dist
source/default.properties
source/mir/rss/RSSReader.java
source/mir/util/DateTimeFunctions.java
source/mircoders/media/MediaHandlerImagesExtern.java
source/mircoders/pdf/PDFGenerator.java
source/mircoders/storage/DatabaseContent.java

index ae7ff3f..4642346 100755 (executable)
@@ -46,9 +46,16 @@ Mir.Tech-email.name=mir-coders mailinglist
 Mir.Public-email.address=mir-coders@lists.indymedia.org
 Mir.Public-email.name=mir-coders mailinglist
 
-Mir.Version=1.1beta
 DirectOpenposting=yes
 
+# Default timezone to display times in in admin, producers
+#
+# Leave empty to use the system's default
+Mir.DefaultTimezone=
+
+# Default date/time format
+Mir.DefaultDateTimeFormat = yyyy-MM-dd HH:mm
+
 #where to put the lucene index
 IndexPath=/tmp/index
 
@@ -60,7 +67,6 @@ Log.log4j.ConfigurationFile = etc/log4j.properties
 Log.Home = log
 
 Mir.Localizer=mircoders.localizer.basic.MirBasicLocalizer
-Mir.Localizer.Logfile=log/localizer.log
 
 # The location of the producer specifiations
 Mir.Localizer.ProducerConfigFile=etc/producer/producers.xml
@@ -111,13 +117,6 @@ Mir.Localizer.OpenPosting.CommentProducers= articles.changed;synchronization.run
 # Which producers need to be called after the "produce all new" link is clicked from admin
 Mir.Localizer.Producer.AllNewProducers= media.new;articles.changed;startpage.run;synchronization.run
 
-
-#note that you can't make pdf's without making fo's
-#this is actually now set in producers.xml
-#but these summarize what is said in there for the benefit of OpenMir 
-GenerateFO=yes
-GeneratePDF=yes
-
 #use rsync to mirror the website to a remote-host
 Rsync=no
 Rsync.Script.Path=/var/www/bin/rsync-copy
@@ -281,7 +280,6 @@ Database.Name=Mir
 # this sets the adaptor to be used
 
 Database.Adaptor=mir.storage.DatabaseAdaptorPostgresql
-Database.Logfile=log/dbentity.log
 
 #
 # configuration for adaptor postgres
index b5487bb..2cc6883 100755 (executable)
@@ -302,6 +302,7 @@ PDF.Index.FontFamily=helvetica
 PDF.Meta.Height=36
 PDF.Meta.FontSize=14
 PDF.Meta.FontFamily=helvetica 
+RDF.Meta.DateFormat=yyyy-MM-dd HH:mm
 
 # how to format the article description
 
@@ -393,6 +394,9 @@ Mir.DefaultHTMLCharset=UTF-8
 # Leave empty to use the system's default
 Mir.DefaultTimezone= 
 
+# Default date/time format
+Mir.DefaultDateTimeFormat = yyyy-MM-dd HH:mm
+
 
 
 
index 86a915a..bdc850b 100755 (executable)
@@ -31,13 +31,13 @@ package mir.rss;
 
 import java.io.InputStream;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.List;
-import java.util.*;
+import java.util.Map;
 import java.util.Vector;
-import java.text.*;
 
+import mir.util.DateTimeFunctions;
 import mir.util.XMLReader;
-import mir.util.*;
 
 /**
  *
index 367240a..4bfe083 100755 (executable)
@@ -155,4 +155,19 @@ public class DateTimeFunctions {
       throw new UtilFailure(t);
     }
   }
+
+  public static String advancedDateFormat(String aFormat, Date aDate, String aTimeZone) {
+    return advancedDateFormat(aFormat, aDate, TimeZone.getTimeZone(aTimeZone));
+  }
+
+  public static String advancedDateFormat(String aFormat, Date aDate, TimeZone aTimeZone) {
+    SimpleDateFormat simpleFormat = new SimpleDateFormat(aFormat);
+
+    simpleFormat.setTimeZone(aTimeZone);
+    return simpleFormat.format(aDate);
+  }
+
+  public static String dateToSortableString(Date aDate) {
+    return advancedDateFormat("yyyyMMddHHmmss", aDate, "GMT");
+  }
 }
\ No newline at end of file
index e8b623a..4d15ba9 100755 (executable)
@@ -41,6 +41,7 @@ import mir.media.MediaExc;
 import mir.media.MediaFailure;
 import mir.misc.StringUtil;
 import mircoders.storage.DatabaseUploadedMedia;
+import mircoders.module.*;
 
 
 /**
@@ -110,6 +111,8 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
         anImageEntity.setValueForProperty("publish_path", filePath);
 
         anImageEntity.update();
+
+
       }
     }
     catch(Throwable t) {
index bdfcdbe..d684602 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 package mircoders.pdf;
@@ -38,14 +38,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.MalformedURLException;
 
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mircoders.entity.EntityContent;
-import mircoders.entity.EntityImages;
-import mircoders.storage.DatabaseContentToMedia;
-
 import com.lowagie.text.BadElementException;
 import com.lowagie.text.Document;
 import com.lowagie.text.DocumentException;
@@ -61,6 +53,17 @@ import com.lowagie.text.pdf.PdfContentByte;
 import com.lowagie.text.pdf.PdfTemplate;
 import com.lowagie.text.pdf.PdfWriter;
 
+import mir.misc.*;
+import mir.util.*;
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.entity.EntityList;
+import mir.log.LoggerWrapper;
+import mircoders.entity.EntityContent;
+import mircoders.entity.EntityImages;
+import mircoders.storage.DatabaseContentToMedia;
+
+
 
 
 public class PDFGenerator{
@@ -80,18 +83,18 @@ public class PDFGenerator{
   public float rightEdge;
   public float leftEdge;
 
-  public int    maxImageHeight;   
-  public int    maxImageWidth;    
+  public int    maxImageHeight;
+  public int    maxImageWidth;
   protected LoggerWrapper logger;
 
-  public int indexFontSize; 
-  public int indexLineHeight; 
-  public int indexFontFamily; 
+  public int indexFontSize;
+  public int indexLineHeight;
+  public int indexFontFamily;
 
   public float footerHeight;
   public String footerText;
-  public int footerFontSize; 
-  public int footerFontFamily; 
+  public int footerFontSize;
+  public int footerFontFamily;
 
   public int metaHeight;
   public int metaFontSize;
@@ -129,40 +132,40 @@ public class PDFGenerator{
       indexFontSize   = Integer.parseInt(configuration.getString("PDF.Index.FontSize"));
       indexLineHeight = Integer.parseInt(configuration.getString("PDF.Index.LineHeight"));
       indexFontFamily = getFontByName(configuration.getString("PDF.Index.FontFamily"));
-      
+
       footerText = configuration.getString("PDF.Footer.String");
       footerFontSize   = Integer.parseInt(configuration.getString("PDF.Footer.FontSize"));
       footerFontFamily = getFontByName(configuration.getString("PDF.Footer.FontFamily"));
       footerHeight = Integer.parseInt(configuration.getString("PDF.Footer.Height"));;
-      
+
       metaFontSize   = Integer.parseInt(configuration.getString("PDF.Meta.FontSize"));
       metaFontFamily = getFontByName(configuration.getString("PDF.Meta.FontFamily"));
       metaHeight = Integer.parseInt(configuration.getString("PDF.Meta.Height"));;
-      
+
       descriptionFontSize   = Integer.parseInt(configuration.getString("PDF.Description.FontSize"));
       descriptionLineHeight = Integer.parseInt(configuration.getString("PDF.Description.LineHeight"));
       descriptionFontFamily = getFontByName(configuration.getString("PDF.Description.FontFamily"));
-      
+
       contentFontSize   = Integer.parseInt(configuration.getString("PDF.Content.FontSize"));
       contentLineHeight = Integer.parseInt(configuration.getString("PDF.Content.LineHeight"));
       contentFontFamily = getFontByName(configuration.getString("PDF.Content.FontFamily"));
-      
+
       sourceFontSize   = Integer.parseInt(configuration.getString("PDF.Source.FontSize"));
       sourceLineHeight = Integer.parseInt(configuration.getString("PDF.Source.LineHeight"));
       sourceFontFamily = getFontByName(configuration.getString("PDF.Source.FontFamily"));
-      
+
       bigImageCaptionFontSize   = Integer.parseInt(configuration.getString("PDF.BigImageCaption.FontSize"));
       bigImageCaptionFontFamily = getFontByName(configuration.getString("PDF.BigImageCaption.FontFamily"));
-    
+
     }
     catch (NumberFormatException e){
       e.printStackTrace();
     }
 
     // step 1: make a document
-    
+
     String pageSize = configuration.getString("PDF.Pagesize");
-    
+
     if (pageSize.equals("LETTER")){
       document = new Document(PageSize.LETTER);
       pageWidth = 612;
@@ -176,35 +179,35 @@ public class PDFGenerator{
 
     maxImageHeight    = 250;
     maxImageWidth     = 250;
-        
-   
+
+
     verticalMargin = 20;
     horizontalMargin = 20;
-    
 
-    
+
+
     topEdge=pageHeight-verticalMargin;
     bottomEdge=verticalMargin;
     rightEdge=pageWidth-horizontalMargin;
     leftEdge=horizontalMargin;
-    
+
     currentYPosition=topEdge;
     currentPage = 1;
-    
+
     String headerText = configuration.getString("PDF.Title.String");
-    
+
     try{
       writer = PdfWriter.getInstance(document, out);
       cb = writer.getDirectContent();
-      
-      document.open();      
+
+      document.open();
       addHeader(headerText);
     }
     catch(DocumentException de) {
       logger.error(de.getMessage());
     }
   }
-  
+
   public void stop(){
     addFooter();
     document.close();
@@ -219,30 +222,30 @@ public class PDFGenerator{
 
     try {
       if ((! headerImage.equals("")) && headerImageHeight != 0){
-       PdfTemplate template = cb.createTemplate(rightEdge-horizontalMargin,headerImageHeight); 
-       
-       float toYPosition=currentYPosition - headerImageHeight;
-       Image theImage = Image.getInstance(headerImage);
-       theImage.setAbsolutePosition(0,0); 
-       //      theImage.scaleAbsolute(img_width,img_height);
-       template.addImage(theImage);
-      
-       
-       cb.addTemplate(template,leftEdge,toYPosition);
-       currentYPosition = toYPosition;
+  PdfTemplate template = cb.createTemplate(rightEdge-horizontalMargin,headerImageHeight);
+
+  float toYPosition=currentYPosition - headerImageHeight;
+  Image theImage = Image.getInstance(headerImage);
+  theImage.setAbsolutePosition(0,0);
+  //   theImage.scaleAbsolute(img_width,img_height);
+  template.addImage(theImage);
+
+
+  cb.addTemplate(template,leftEdge,toYPosition);
+  currentYPosition = toYPosition;
       }
       if (! headerText.equals("")){
-       ColumnText ct = new ColumnText(cb);   
-       //add a basic header
-       ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
-       float[] rightCol = {rightEdge,currentYPosition,rightEdge,currentYPosition-titleLineHeight};
-       float[] leftCol = {leftEdge,currentYPosition,leftEdge,currentYPosition-titleLineHeight};
-       ct.setColumns(leftCol,rightCol);
-       ct.setYLine(currentYPosition);
-       ct.setAlignment(Element.ALIGN_CENTER);
-       ct.go();
-      
-       currentYPosition = currentYPosition - titleLineHeight;
+  ColumnText ct = new ColumnText(cb);
+  //add a basic header
+  ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
+  float[] rightCol = {rightEdge,currentYPosition,rightEdge,currentYPosition-titleLineHeight};
+  float[] leftCol = {leftEdge,currentYPosition,leftEdge,currentYPosition-titleLineHeight};
+  ct.setColumns(leftCol,rightCol);
+  ct.setYLine(currentYPosition);
+  ct.setAlignment(Element.ALIGN_CENTER);
+  ct.go();
+
+  currentYPosition = currentYPosition - titleLineHeight;
       }
     }
     catch(DocumentException de) {
@@ -277,7 +280,7 @@ public class PDFGenerator{
     catch(DocumentException de) {
       logger.error(de.getMessage());
     }
-    
+
 
 
   }
@@ -310,9 +313,9 @@ public class PDFGenerator{
     cb.lineTo(leftEdge, currentYPosition-5);
     cb.stroke();
     currentYPosition = currentYPosition - 10;
-    
+
   }
-  
+
   public void addFooter(){
     try{
     ColumnText fct = new ColumnText(cb);
@@ -322,10 +325,10 @@ public class PDFGenerator{
     cb.stroke();
     float[] leftFooterCols = {leftEdge,bottomEdge+footerHeight-1,leftEdge,bottomEdge};
     float[] rightFooterCols = {rightEdge,bottomEdge+footerHeight-1,rightEdge,bottomEdge};
-    
+
     Paragraph footerP=new Paragraph(footerText,new Font(footerFontFamily,footerFontSize));
     fct.addText(footerP);
-    
+
     fct.setColumns(leftFooterCols,rightFooterCols);
     fct.setYLine(bottomEdge+footerHeight-1);
     fct.setAlignment(Element.ALIGN_JUSTIFIED);
@@ -348,7 +351,7 @@ public class PDFGenerator{
     try{
       //add a footer
       addFooter();
-      document.newPage();   
+      document.newPage();
       currentPage++;
       currentYPosition=topEdge;
     }
@@ -356,9 +359,9 @@ public class PDFGenerator{
       logger.error(de.getMessage());
     }
   }
-  
+
   public void addArticleSeparator(){
-    // make a line 
+    // make a line
     if (! enoughY(10)){
       newPage();
     }
@@ -371,45 +374,45 @@ public class PDFGenerator{
 
   public void addArticleMetaInfo(ColumnText ct,String theTitle,String theCreator,String theDate){
       //see if we have room for the author and title
-    
+
     if (! enoughY(metaHeight)){
-       newPage();
+  newPage();
       }
-    
+
     Paragraph titleP=new Paragraph(theTitle+"\n",new Font(metaFontFamily,metaFontSize,Font.BOLD));
     Paragraph whowhenP=new Paragraph(theCreator + "  " + theDate ,new Font(metaFontFamily,metaFontSize));
     ct.addText(titleP);
     ct.addText(whowhenP);
-    
+
     ct.setYLine(currentYPosition);
     ct.setAlignment(Element.ALIGN_LEFT);
-    
+
     float toYPosition = currentYPosition - metaHeight;
     float[] leftHeadCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
     float[] rightHeadCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
-    
+
     ct.setColumns(leftHeadCols,rightHeadCols);
-    try { 
+    try {
       ct.go();
       currentYPosition = toYPosition;
     }
     catch(DocumentException de) {
       logger.error(de.getMessage());
     }
-    
+
   }
 
   public void addArticleDescription(ColumnText ct,String theDescription){
     // Now we add the description, one line at a time, the ct should be empty at this point
-    
-    
+
+
     Paragraph descP=new Paragraph(theDescription,new Font(descriptionFontFamily,descriptionFontSize,Font.BOLD));
     ct.addText(descP);
-    
+
     // every article has a description, so we can assume that:
     int status = ColumnText.NO_MORE_COLUMN;
-    
-    int brake=1000; 
+
+    int brake=1000;
     while ((status & ColumnText.NO_MORE_TEXT) == 0 && brake >0){
       //there is still text left in the description.
       status = addTextLine(ct,descriptionLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
@@ -418,16 +421,16 @@ public class PDFGenerator{
     if (brake == 0)
       logger.error("runaway description...try increasing the line height or decreasing the font size");
   }
+
   public void addArticleContent(ColumnText ct,String theContent,EntityList images){
     //let's go ahead and add in all the body text
     Paragraph contentP=new Paragraph(theContent,new Font(contentFontFamily,contentFontSize));
     ct.addText(contentP);
-    
+
     int contentLinesBeforeImages=3;
     //and assume we have at least one line of text in the content
     int status = ColumnText.NO_MORE_COLUMN;
-    
+
     // let's add a little bit of text, like a couple of lines
     int x = 0;
     while (((status & ColumnText.NO_MORE_TEXT) == 0) && x<contentLinesBeforeImages){
@@ -437,166 +440,166 @@ public class PDFGenerator{
 
     boolean addImageOnLeft = true; //we will alternate within articles
     while (images.hasNext()){
-      
+
       EntityImages currentImage=(EntityImages) images.next();
       float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
       float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
       if (img_height>maxImageHeight){
-       img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue();
-       img_height=maxImageHeight;
+  img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue();
+  img_height=maxImageHeight;
       }
       if (img_width>maxImageWidth){
-       img_height=(new Float((new Float(img_height*(maxImageWidth/img_width))).intValue())).floatValue();
-       img_width=maxImageWidth;
+  img_height=(new Float((new Float(img_height*(maxImageWidth/img_width))).intValue())).floatValue();
+  img_width=maxImageWidth;
       }
 
       String img_title=currentImage.getValue("title");
       String img_path=currentImage.getValue("publish_path");
-      
-      if ((status & ColumnText.NO_MORE_TEXT) == 0){ 
-       // there is still text, so add an image which will have text wrapped around it, then add the text which 
-       // will be on the left or the right of the image
-       
-       float templateMinimumHeight = img_height+20;
-       float templateWidth = img_width+10;
-       float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
-       
-       PdfTemplate template = cb.createTemplate(templateWidth,templateHeight); 
-       
-       
-       //here we need a page check
-       if (! enoughY((new Float(templateHeight)).intValue())){
-         //ok, well just fill text to the bottom then
-         float toYPosition = bottomEdge+footerHeight;
-         float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
-         float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
-         ct.setColumns(leftBottomCols,rightBottomCols);
-         ct.setYLine(currentYPosition);
-         ct.setAlignment(Element.ALIGN_JUSTIFIED);
-         try{ 
-           status=ct.go();
-         }
-         catch(DocumentException de) {
-           logger.error(de.getMessage());
-         }
-         newPage();
-       }
-       
-       float toYPosition=currentYPosition - templateHeight;
-
-       try {
-         Image theImage = Image.getInstance(localImageDir+img_path);
-         theImage.scaleAbsolute(img_width,img_height);
-         theImage.setAbsolutePosition(5,13); 
-         
-         template.addImage(theImage);
-         template.beginText();
-         BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
-         template.setFontAndSize(bf, 8);
-         template.setTextMatrix(5, 3);
-         template.showText(img_title);
-         template.endText();
-       }
-       catch(BadElementException de) {
-         logger.error(de.getMessage());
-       }
-       catch(DocumentException de) {
-         logger.error(de.getMessage());
-       }
-       catch (MalformedURLException de){
-        logger.error(de.getMessage());
-       }
-       catch (IOException de){
-         logger.error(de.getMessage());
-       }
-
-       
-       float leftImageTextEdge=leftEdge;
-       float rightImageTextEdge=rightEdge;
-       
-       
-       if (addImageOnLeft){
-         cb.addTemplate(template,leftEdge,toYPosition);
-         leftImageTextEdge=leftEdge+templateWidth+5;
-         addImageOnLeft = false;
-       }           
-       else {
-         cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
-         rightImageTextEdge = rightEdge-templateWidth-5;
-         addImageOnLeft = true;
-       }
-
-       logger.debug("adding template at " + leftEdge + "," + toYPosition);
-       
-       //and fill some text while we are at it
-       
-       float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
-       float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
-       ct.setColumns(leftBottomCols,rightBottomCols);
-       ct.setYLine(currentYPosition);
-       ct.setAlignment(Element.ALIGN_JUSTIFIED);
-       try{ 
-       status=ct.go();
-       currentYPosition=toYPosition;
-       }
-       catch(DocumentException de) {
-         logger.error(de.getMessage());
-       }
-       
-       
+
+      if ((status & ColumnText.NO_MORE_TEXT) == 0){
+  // there is still text, so add an image which will have text wrapped around it, then add the text which
+  // will be on the left or the right of the image
+
+  float templateMinimumHeight = img_height+20;
+  float templateWidth = img_width+10;
+  float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
+
+  PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
+
+
+  //here we need a page check
+  if (! enoughY((new Float(templateHeight)).intValue())){
+    //ok, well just fill text to the bottom then
+    float toYPosition = bottomEdge+footerHeight;
+    float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
+    float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
+    ct.setColumns(leftBottomCols,rightBottomCols);
+    ct.setYLine(currentYPosition);
+    ct.setAlignment(Element.ALIGN_JUSTIFIED);
+    try{
+      status=ct.go();
+    }
+    catch(DocumentException de) {
+      logger.error(de.getMessage());
+    }
+    newPage();
+  }
+
+  float toYPosition=currentYPosition - templateHeight;
+
+  try {
+    Image theImage = Image.getInstance(localImageDir+img_path);
+    theImage.scaleAbsolute(img_width,img_height);
+    theImage.setAbsolutePosition(5,13);
+
+    template.addImage(theImage);
+    template.beginText();
+    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
+    template.setFontAndSize(bf, 8);
+    template.setTextMatrix(5, 3);
+    template.showText(img_title);
+    template.endText();
+  }
+  catch(BadElementException de) {
+    logger.error(de.getMessage());
+  }
+  catch(DocumentException de) {
+    logger.error(de.getMessage());
+  }
+  catch (MalformedURLException de){
+   logger.error(de.getMessage());
+  }
+  catch (IOException de){
+    logger.error(de.getMessage());
+  }
+
+
+  float leftImageTextEdge=leftEdge;
+  float rightImageTextEdge=rightEdge;
+
+
+  if (addImageOnLeft){
+    cb.addTemplate(template,leftEdge,toYPosition);
+    leftImageTextEdge=leftEdge+templateWidth+5;
+    addImageOnLeft = false;
+  }
+  else {
+    cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
+    rightImageTextEdge = rightEdge-templateWidth-5;
+    addImageOnLeft = true;
+  }
+
+  logger.debug("adding template at " + leftEdge + "," + toYPosition);
+
+  //and fill some text while we are at it
+
+  float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
+  float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
+  ct.setColumns(leftBottomCols,rightBottomCols);
+  ct.setYLine(currentYPosition);
+  ct.setAlignment(Element.ALIGN_JUSTIFIED);
+  try{
+  status=ct.go();
+  currentYPosition=toYPosition;
+  }
+  catch(DocumentException de) {
+    logger.error(de.getMessage());
+  }
+
+
       }
-      else { 
-       //add an image on the left with a big caption to the right
-       currentYPosition = currentYPosition - 10;
-       float templateMinimumHeight = img_height;
-       float templateWidth = img_width;
-       float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
-       PdfTemplate template = cb.createTemplate(templateWidth,templateHeight); 
-       if (! enoughY((new Float(templateHeight)).intValue())){
-         newPage();
-       }
-       float toYPosition=currentYPosition - templateHeight;
-       try{ 
-         Image theImage = Image.getInstance(localImageDir+img_path);
-         theImage.setAbsolutePosition(0,13); 
-         theImage.scaleAbsolute(img_width,img_height);
-         template.addImage(theImage);
-       }
-       catch(BadElementException de) {
-         logger.error(de.getMessage());
-       }
-       catch(DocumentException de) {
-         logger.error(de.getMessage());
-       }
-       catch(MalformedURLException de) {
-         logger.error(de.getMessage());
-       }
-       catch(IOException de) {
-         logger.error(de.getMessage());
-       }
-
-       cb.addTemplate(template,leftEdge,toYPosition);
-         
-       // add a big caption
-       ColumnText cct = new ColumnText(cb);   
-       float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
-       float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
-       
-       Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
-       cct.addText(captionP);
-       cct.setColumns(leftCaptionCols,rightCaptionCols);
-       cct.setYLine(currentYPosition-5);
-       cct.setAlignment(Element.ALIGN_LEFT);
-       try{
-         cct.go();
-         currentYPosition=toYPosition;
-       }
-       catch(DocumentException de) {
-         logger.error(de.getMessage());
-       }
+      else {
+  //add an image on the left with a big caption to the right
+  currentYPosition = currentYPosition - 10;
+  float templateMinimumHeight = img_height;
+  float templateWidth = img_width;
+  float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
+  PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
+  if (! enoughY((new Float(templateHeight)).intValue())){
+    newPage();
+  }
+  float toYPosition=currentYPosition - templateHeight;
+  try{
+    Image theImage = Image.getInstance(localImageDir+img_path);
+    theImage.setAbsolutePosition(0,13);
+    theImage.scaleAbsolute(img_width,img_height);
+    template.addImage(theImage);
+  }
+  catch(BadElementException de) {
+    logger.error(de.getMessage());
+  }
+  catch(DocumentException de) {
+    logger.error(de.getMessage());
+  }
+  catch(MalformedURLException de) {
+    logger.error(de.getMessage());
+  }
+  catch(IOException de) {
+    logger.error(de.getMessage());
+  }
+
+  cb.addTemplate(template,leftEdge,toYPosition);
+
+  // add a big caption
+  ColumnText cct = new ColumnText(cb);
+  float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
+  float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
+
+  Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
+  cct.addText(captionP);
+  cct.setColumns(leftCaptionCols,rightCaptionCols);
+  cct.setYLine(currentYPosition-5);
+  cct.setAlignment(Element.ALIGN_LEFT);
+  try{
+    cct.go();
+    currentYPosition=toYPosition;
+  }
+  catch(DocumentException de) {
+    logger.error(de.getMessage());
+  }
       }
     }
-    
+
     //add the rest of the text which might be left
     int brake = 10000;
     while ((status & ColumnText.NO_MORE_TEXT) == 0  && brake > 0){
@@ -617,131 +620,136 @@ public class PDFGenerator{
   private boolean enoughY(int heightOfBlockToAdd){
     if ((currentYPosition - heightOfBlockToAdd - footerHeight) < bottomEdge )
       return false;
-    else 
+    else
       return true;
   }
-  
-  
+
+
   public void add(EntityContent entityContent){
     logger.error("adding a content Entity");
-    
+
     /*
      * initialize
      * separate
      * meta info
      * description
-     * content  
+     * content
      * --image with text
      * --normal text
      * --image without text
      * source
     */
-    
+
     EntityList images=DatabaseContentToMedia.getInstance().getImages(entityContent);
     String isHTML  = entityContent.getValue("is_html");
     String theTitle = entityContent.getValue("title");
     String theCreator = entityContent.getValue("creator");
-    String theDate = entityContent.getValue("webdb_create_formatted");
+    String theDate = DateTimeFunctions.advancedDateFormat(
+        configuration.getString("RDF.Meta.DateFormat"),
+        StringUtil.convertMirInternalDateToDate(entityContent.getValue("webdb_create")),
+        configuration.getString("Mir.DefaultTimezone"));
+
+
     String theDescriptionRaw = entityContent.getValue("description");
     String theContentRaw = entityContent.getValue("content_data");
     String theSource =  configuration.getString("Producer.ProductionHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getValue("publish_path") + entityContent.getValue("id") + ".shtml";
 
 
-    
+
     String theContent = "";
     String theDescription = "";
-    
+
     if (isHTML.equals("1")){
-      
-      
-            
-      try { 
-       RE nobackslashr = new RE("\r");
-       theContent= nobackslashr.substituteAll(theContentRaw,"");
-       
-       RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
-       theContent = HxTag.substituteAll(theContent,"\n\n");
-       
-       RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
-       theContent = ListItemTag.substituteAll(theContent,"\n * ");
-
-       RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
-       theContent = ListTag.substituteAll(theContent,"\n");
-       
-       RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
-       theContent= DivTag.substituteAll(theContent,"\n");
-
-       RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
-       theContent= PTag.substituteAll(theContent,"\n    ");
-
-       RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
-       theContent= PTagClose.substituteAll(theContent,"\n");
-
-       RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
-       theContent= BRTag.substituteAll(theContent,"\n");
-       
-       RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
-       REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
-       String theContentCopy=theContent;
-       while (atags.hasMoreMatches()){
-         REMatch atag = atags.nextMatch();
-         String atagString=atag.toString();
-         String atagStringHref=atag.toString(1);
-         String atagStringText=atag.toString(2);
-         int begin=theContentCopy.indexOf(atagString);
-         theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
-       }
-       theContent=theContentCopy;
-       
-       RE noTags = new RE("<[^>]*>");
-       theContent= noTags.substituteAll(theContent," ");
-       
-       theContent=mir.util.Translate.decode(theContent);
-
-       RE re1 = new RE("\r?\n\r?\n");
-       String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
-       
-       RE re2 = new RE("\r?\n");
-       String theDescription2 = re2.substituteAll(theDescription1," ");
-       
-       RE re3 = new RE("BREAKHERE");
-       theDescription = re3.substituteAll(theDescription2,"\n    ");
-       
+
+
+
+      try {
+  RE nobackslashr = new RE("\r");
+  theContent= nobackslashr.substituteAll(theContentRaw,"");
+
+  RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
+  theContent = HxTag.substituteAll(theContent,"\n\n");
+
+  RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
+  theContent = ListItemTag.substituteAll(theContent,"\n * ");
+
+  RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
+  theContent = ListTag.substituteAll(theContent,"\n");
+
+  RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
+  theContent= DivTag.substituteAll(theContent,"\n");
+
+  RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
+  theContent= PTag.substituteAll(theContent,"\n    ");
+
+  RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
+  theContent= PTagClose.substituteAll(theContent,"\n");
+
+  RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
+  theContent= BRTag.substituteAll(theContent,"\n");
+
+  RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
+  REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
+  String theContentCopy=theContent;
+  while (atags.hasMoreMatches()){
+    REMatch atag = atags.nextMatch();
+    String atagString=atag.toString();
+    String atagStringHref=atag.toString(1);
+    String atagStringText=atag.toString(2);
+    int begin=theContentCopy.indexOf(atagString);
+    theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
+  }
+  theContent=theContentCopy;
+
+  RE noTags = new RE("<[^>]*>");
+  theContent= noTags.substituteAll(theContent," ");
+
+  theContent=mir.util.Translate.decode(theContent);
+
+  RE re1 = new RE("\r?\n\r?\n");
+  String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
+
+  RE re2 = new RE("\r?\n");
+  String theDescription2 = re2.substituteAll(theDescription1," ");
+
+  RE re3 = new RE("BREAKHERE");
+  theDescription = re3.substituteAll(theDescription2,"\n    ");
+
 
       }
       catch(REException ree){
-       logger.error(ree.getMessage());
+  logger.error(ree.getMessage());
       }
     }
     else {
-      try { 
-       RE re1 = new RE("\r?\n\r?\n");
-       String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
-       String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
-       
-       RE re2 = new RE("\r?\n");
-       String theContent2 = re2.substituteAll(theContent1," ");
-       String theDescription2 = re2.substituteAll(theDescription1," ");
-       
-       RE re3 = new RE("BREAKHERE");
-       theContent = "    " + re3.substituteAll(theContent2,"\n    ");
-       theDescription = re3.substituteAll(theDescription2,"\n    ");
+      try {
+  RE re1 = new RE("\r?\n\r?\n");
+  String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
+  String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
+
+  RE re2 = new RE("\r?\n");
+  String theContent2 = re2.substituteAll(theContent1," ");
+  String theDescription2 = re2.substituteAll(theDescription1," ");
+
+  RE re3 = new RE("BREAKHERE");
+  theContent = "    " + re3.substituteAll(theContent2,"\n    ");
+  theDescription = re3.substituteAll(theDescription2,"\n    ");
 
       }
       catch(REException ree){
-       logger.error(ree.getMessage());
+  logger.error(ree.getMessage());
       }
     }
 
     addArticleSeparator();
-    
+
     ColumnText ct = new ColumnText(cb);
-    
+
     addArticleMetaInfo(ct,theTitle,theCreator,theDate);
     addArticleDescription(ct,theDescription);
     addArticleContent(ct,theContent,images);
     addArticleSource(ct,theSource);
-      
+
   }
 
   public int getFontByName(String fontName) {
@@ -750,20 +758,20 @@ public class PDFGenerator{
       theFont = Font.HELVETICA;
     }
     else {
-      if (fontName.equalsIgnoreCase("courier")) { 
-       theFont = Font.COURIER;
+      if (fontName.equalsIgnoreCase("courier")) {
+  theFont = Font.COURIER;
       }
       else {
-       if (fontName.equalsIgnoreCase("times")) { 
-         theFont = Font.TIMES_ROMAN;
-       }
-       else {
-         logger.error("using helvetica because I can't get font for name: "+fontName);
-         theFont = Font.HELVETICA;
-       }
+  if (fontName.equalsIgnoreCase("times")) {
+    theFont = Font.TIMES_ROMAN;
+  }
+  else {
+    logger.error("using helvetica because I can't get font for name: "+fontName);
+    theFont = Font.HELVETICA;
+  }
       }
     }
-    
+
     return theFont;
 
   }
index a5fc5a4..9f55167 100755 (executable)
@@ -102,14 +102,6 @@ public class DatabaseContent extends Database implements StorageObject {
   }
 
   /**
-   * returns the comments that belong to the article (via entityrelation)
-   * where db-flag is_published is true
-   */
-  public EntityList getComments(EntityContent entC) throws StorageObjectFailure {
-    return relationComments.getMany(entC,"webdb_create","is_published='1'");
-  }
-
-  /**
    *
    * @param id
    * @return