fixed comment/article search + configurable icon sizes
authorzapata <zapata>
Fri, 21 Feb 2003 05:37:33 +0000 (05:37 +0000)
committerzapata <zapata>
Fri, 21 Feb 2003 05:37:33 +0000 (05:37 +0000)
19 files changed:
bundles/admin_de.properties
bundles/admin_en.properties
bundles/admin_es.properties
bundles/admin_eu.properties
bundles/admin_nl.properties
bundles/admin_pt.properties
bundles/admin_sv.properties
bundles/admin_tr.properties
etc/default.properties
source/mir/misc/WebdbImage.java
source/mir/util/SQLQueryBuilder.java
source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java
source/mircoders/media/MediaHandlerImagesExtern.java
source/mircoders/servlet/ServletHelper.java
source/mircoders/servlet/ServletModuleComment.java
source/mircoders/servlet/ServletModuleContent.java
templates/admin/commentlist.template
templates/admin/content.template
templates/admin/contentlist.template

index 1cf51a4..24044ce 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: deutsch / german
-# $Id: admin_de.properties,v 1.25 2003/01/18 08:15:19 mh Exp $
+# $Id: admin_de.properties,v 1.26 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Deutsch
 
@@ -102,9 +102,9 @@ commentlist.published=publiziert
 commentlist.hidden=versteckt
 commentlist.search=go!
 
-commentlist.order.datedesc= date (desc.)                  # needs translation
-commentlist.order.dateasc= date (asc.)                    # needs translation
-commentlist.order.articletitle= article title             # needs translation
+commentsearch.order.datedesc= date (desc.)                  # needs translation
+contentsearch.order.dateasc= date (asc.)                    # needs translation
+contentsearch.order.articletitle= article title             # needs translation
 
 
 # confirm
index a9c32d4..9ffef87 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: english
-# $Id: admin_en.properties,v 1.34 2003/02/20 16:06:30 zapata Exp $
+# $Id: admin_en.properties,v 1.35 2003/02/21 05:38:36 zapata Exp $
 
 languagename=English
 
@@ -102,13 +102,26 @@ comment.status=Status
 comment.language=Language
 
 commentlist.htmltitle=Comments
-commentlist.published=published
-commentlist.hidden=hidden
-commentlist.search=go!
 
-commentlist.order.datedesc= date (desc.)
-commentlist.order.dateasc= date (asc.)
-commentlist.order.articletitle= article title
+commentsearch.field = Field
+commentsearch.field.title = Title
+commentsearch.field.creator = Author
+commentsearch.field.description = Description
+commentsearch.value = Value
+
+commentsearch.publishedstate = Published state
+commentsearch.publishedstate.hidden = Hidden
+commentsearch.publishedstate.published = Published
+
+commentsearch.status = Status
+
+commentsearch.order = Order
+commentsearch.order.datedesc= date (desc.)
+commentsearch.order.dateasc= date (asc.)
+commentsearch.order.articletitle= article title
+
+commentsearch.searchbutton = Search
+
 
 
 # confirm
@@ -160,10 +173,31 @@ content.viewparent=view
 content.clearparent=de-select
 content.selectparent=select
 
+contentsearch.value = value
+contentsearch.field = field
+contentsearch.field.title = Title
+contentsearch.field.creator = Author
+contentsearch.field.contents=Contents
+
+contentsearch.publishedstate = publication state
+contentsearch.publishedstate.hidden=hidden
+contentsearch.publishedstate.published=published
+
+contentsearch.articletype = article type
+
+contentsearch.order = order by
+contentsearch.order.datedesc=Newest first
+contentsearch.order.dateasc=Oldest first
+contentsearch.order.title=Title
+contentsearch.order.creator=Author
+
+contentsearch.searchbutton=Search
+
 contentlist.htmltitle=Articles
 contentlist.comments=Comments
 contentlist.select=Select
 
+
 # language
 language.htmltitle=Language
 language.name=Language
index 468cdd1..a813d5f 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: espanol / spanish
-# $Id: admin_es.properties,v 1.21 2003/01/18 16:04:33 zapata Exp $
+# $Id: admin_es.properties,v 1.22 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Español
 
@@ -99,9 +99,9 @@ commentlist.published=publicado
 commentlist.hidden=oculto
 commentlist.search=buscar!
 
-commentlist.order.datedesc= fecha (desc.)
-commentlist.order.dateasc= fecha (asc.)
-commentlist.order.articletitle= título del artículo
+commentsearch.order.datedesc= fecha (desc.)
+commentsearch.order.dateasc= fecha (asc.)
+commentsearch.order.articletitle= título del artículo
 
 
 # confirm
index fba7c1a..ba67237 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: euskera / basque
-# $Id: admin_eu.properties,v 1.7 2003/01/18 16:27:23 zapata Exp $
+# $Id: admin_eu.properties,v 1.8 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Euskera
 
@@ -98,9 +98,9 @@ commentlist.produced=ekoiztua
 commentlist.hidden=izkutua
 commentlist.search=bilatu!
 
-commentlist.order.datedesc= data (behera)
-commentlist.order.dateasc= data (gora)
-commentlist.order.articletitle= artikuluaren titulua
+commentsearch.order.datedesc= data (behera)
+commentsearch.order.dateasc= data (gora)
+commentsearch.order.articletitle= artikuluaren titulua
 
 # confirm
 confirm.htmltitle=Indymedia Euskal Herria | Ezabaketa baieztatu
index e3e2fb3..489c8ae 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: dutch
-# $Id: admin_nl.properties,v 1.3 2003/01/18 15:54:30 zapata Exp $
+# $Id: admin_nl.properties,v 1.4 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Nederlands
 
@@ -106,9 +106,9 @@ commentlist.published=Gepubliceerd
 commentlist.hidden=Verborgen
 commentlist.search=Zoek
 
-commentlist.order.datedesc= Datum (nieuwste eerst)
-commentlist.order.dateasc= Datum (oudste eerst)
-commentlist.order.articletitle= Titel artikel
+commentsearch.order.datedesc= Datum (nieuwste eerst)
+commentsearch.order.dateasc= Datum (oudste eerst)
+commentsearch.order.articletitle= Titel artikel
 
 # confirm
 confirm.htmltitle=Bevestigen
index cd7122e..c633789 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: portuguese
-# $Id: admin_pt.properties,v 1.2 2003/01/18 08:15:19 mh Exp $
+# $Id: admin_pt.properties,v 1.3 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Português
 
@@ -106,9 +106,9 @@ commentlist.published=publicado
 commentlist.hidden=escondido
 commentlist.search=Vá!
 
-commentlist.order.datedesc= date (desc.)
-commentlist.order.dateasc= date (asc.)
-commentlist.order.articletitle= título do artigo
+commentsearch.order.datedesc= date (desc.)
+commentsearch.order.dateasc= date (asc.)
+commentsearch.order.articletitle= título do artigo
 
 
 # confirm
index b87de08..d51095d 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: svenska
-# $Id: admin_sv.properties,v 1.2 2003/01/18 08:15:19 mh Exp $
+# $Id: admin_sv.properties,v 1.3 2003/02/21 05:38:36 zapata Exp $
 
 languagename=Svenska
 
@@ -106,9 +106,9 @@ commentlist.published=publicerad
 commentlist.hidden=g&ouml;md
 commentlist.search=S&ouml;k!
 
-commentlist.order.datedesc= datum (fallande)
-commentlist.order.dateasc= datum (stigande)
-commentlist.order.articletitle= artikelrubrik
+commentsearch.order.datedesc= datum (fallande)
+commentsearch.order.dateasc= datum (stigande)
+commentsearch.order.articletitle= artikelrubrik
 
 
 # confirm
index 6461714..d80fc69 100755 (executable)
Binary files a/bundles/admin_tr.properties and b/bundles/admin_tr.properties differ
index 0713724..51faebe 100755 (executable)
@@ -168,6 +168,13 @@ Producer.RealMedia.Host=rtsp://some.media.server/somedir/
 # absolute directory, where the images are saved
 Producer.Image.Path=/pub/Dokumente/Indymedia/de-tech/Mir/produced/images/
 
+# images will be scaled down so that the size (both widht and height) are below:
+Producer.Image.MaxSize = 640
+
+# icons will be generated so that the size (both width and height) are below:
+Producer.Image.MaxIconSize = 120
+
+
 # media specific storage directories
 # absolute directory, where the media files are saved
 Producer.Media.Path=/pub/Dokumente/Indymedia/de-tech/Mir/produced/media
index ff035b9..05d2c35 100755 (executable)
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * 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 the com.oreilly.servlet library, 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 mir.misc;
-
-/**
- * Title:
- * Description:
- * Copyright:    Copyright (c) 2002 Mir-coders
- * @author $Author: idfx $
- * @version $Id: WebdbImage.java,v 1.9 2003/01/25 17:45:18 idfx Exp $
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Random;
-
-import javax.media.jai.InterpolationBilinear;
-import javax.media.jai.JAI;
-import javax.media.jai.ParameterBlockJAI;
-import javax.media.jai.PlanarImage;
-
-import com.sun.media.jai.codec.FileSeekableStream;
-
-public class WebdbImage
-{
-
-       // default values for scaling
-       private int               maxIconSize=120;
-       private int               maxImageSize=640;
-
-       private int               iconWidth;
-       private int               iconHeight;
-
-  Random r = new Random();
-
-       // internal representation of the image
-       private PlanarImage       planarImage;
-
-  // type of the image
-  private String _type;
-
-
-       // constructor
-  // takes a temporary file as a parameter
-       public WebdbImage(File f, String type)
-               throws IOException
-       {
-    // It has to be a FileSeekableStream cause the image conversion
-    // needs to seek backwards.
-               planarImage = JAI.create("stream",new FileSeekableStream(f));
-    _type = type;
-               scaleImage();
-       }
-
-       // acc3ssor-methods
-  // must be run after scaleIcon()
-       public int getIconWidth() throws IOException {
-               return iconWidth;
-       }
-
-  // must be run after scaleIcon()
-       public int getIconHeight() throws IOException {
-               return iconHeight;
-       }
-
-       public int getImageWidth() {
-               return (int)planarImage.getWidth();
-       }
-
-       public int getImageHeight() {
-               return (int)planarImage.getHeight();
-       }
-
-       public void setImage(OutputStream outStream) {
-    JAI.create("encode", planarImage, outStream, _type, null);
-       }
-
-       public void setIcon(OutputStream outStream)
-               throws IOException
-       {
-               scaleIcon(outStream);
-       }
-
-       private void scaleImage()
-               throws java.io.IOException
-       {
-               if (maxImageSize>0 && ( getImageHeight()> maxImageSize|| getImageWidth() >maxImageSize))
-               {
-                       float scale;
-      ParameterBlockJAI params = new ParameterBlockJAI("scale");
-      params.addSource(planarImage);
-                       if (getImageHeight() > getImageWidth())
-        scale = (float)maxImageSize / (float)getImageHeight();
-      else
-        scale = (float)maxImageSize / (float)getImageWidth();
-
-      params.setParameter("xScale", scale);
-      params.setParameter("yScale", scale);
-                       params.setParameter("xTrans",0.0F);
-                       params.setParameter("yTrans",0.0F);
-                       params.setParameter("interpolation",new InterpolationBilinear());
-                       planarImage = JAI.create("scale", params);
-               }
-       }
-
-       private void scaleIcon(OutputStream outStream)
-               throws java.io.IOException
-       {
-    float scale;
-    ParameterBlockJAI params = new ParameterBlockJAI("scale");
-    params.addSource(planarImage);
-    if (getImageHeight() > getImageWidth())
-      scale = (float)maxIconSize / (float)getImageHeight();
-    else
-      scale = (float)maxIconSize / (float)getImageWidth();
-
-    params.setParameter("xScale", scale);
-    params.setParameter("yScale", scale);
-    params.setParameter("xTrans",0.0F);
-    params.setParameter("yTrans",0.0F);
-    params.setParameter("interpolation",new InterpolationBilinear());
-    PlanarImage temp = JAI.create("scale", params);
-    JAI.create("encode", temp, outStream, _type, null);
-    iconWidth=temp.getWidth();
-    iconHeight=temp.getHeight();
-       }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.misc;\r
+\r
+/**\r
+ * Title:\r
+ * Description:\r
+ * Copyright:    Copyright (c) 2002 Mir-coders\r
+ * @author $Author: zapata $\r
+ * @version $Id: WebdbImage.java,v 1.10 2003/02/21 05:37:59 zapata Exp $\r
+ */\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+import java.util.Random;\r
+\r
+import javax.media.jai.InterpolationBilinear;\r
+import javax.media.jai.JAI;\r
+import javax.media.jai.ParameterBlockJAI;\r
+import javax.media.jai.PlanarImage;\r
+\r
+import com.sun.media.jai.codec.FileSeekableStream;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+\r
+public class WebdbImage\r
+{\r
+\r
+  // default values for scaling\r
+  private int maxIconSize;\r
+  private int maxImageSize;\r
+\r
+  private int iconWidth;\r
+  private int iconHeight;\r
+\r
+  Random r = new Random();\r
+\r
+  // internal representation of the image\r
+  private PlanarImage planarImage;\r
+\r
+  // type of the image\r
+  private String _type;\r
+\r
+  private WebdbImage() {\r
+  }\r
+\r
+  // constructor\r
+  // takes a temporary file as a parameter\r
+  public WebdbImage(File f, String type) throws Exception {\r
+    // It has to be a FileSeekableStream cause the image conversion\r
+    // needs to seek backwards.\r
+    maxImageSize = MirPropertiesConfiguration.instance().getInt("Producer.Image.MaxSize");\r
+    maxIconSize = MirPropertiesConfiguration.instance().getInt("Producer.Image.MaxIconSize");\r
+\r
+    planarImage = JAI.create("stream", new FileSeekableStream(f));\r
+    _type = type;\r
+    scaleImage();\r
+  }\r
+\r
+  // acc3ssor-methods\r
+  // must be run after scaleIcon()\r
+  public int getIconWidth() throws IOException {\r
+    return iconWidth;\r
+  }\r
+\r
+  // must be run after scaleIcon()\r
+  public int getIconHeight() throws IOException {\r
+    return iconHeight;\r
+  }\r
+\r
+  public int getImageWidth() {\r
+    return (int) planarImage.getWidth();\r
+  }\r
+\r
+  public int getImageHeight() {\r
+    return (int) planarImage.getHeight();\r
+  }\r
+\r
+  public void setImage(OutputStream outStream) {\r
+    JAI.create("encode", planarImage, outStream, _type, null);\r
+  }\r
+\r
+  public void setIcon(OutputStream outStream) throws IOException {\r
+    scaleIcon(outStream);\r
+  }\r
+\r
+  private void scaleImage() throws java.io.IOException {\r
+    if (maxImageSize > 0 &&\r
+        (getImageHeight() > maxImageSize || getImageWidth() > maxImageSize)) {\r
+      float scale;\r
+      ParameterBlockJAI params = new ParameterBlockJAI("scale");\r
+      params.addSource(planarImage);\r
+      if (getImageHeight() > getImageWidth())\r
+        scale = (float) maxImageSize / (float) getImageHeight();\r
+      else\r
+        scale = (float) maxImageSize / (float) getImageWidth();\r
+\r
+      params.setParameter("xScale", scale);\r
+      params.setParameter("yScale", scale);\r
+      params.setParameter("xTrans", 0.0F);\r
+      params.setParameter("yTrans", 0.0F);\r
+      params.setParameter("interpolation", new InterpolationBilinear());\r
+      planarImage = JAI.create("scale", params);\r
+    }\r
+  }\r
+\r
+  private void scaleIcon(OutputStream outStream) throws java.io.IOException {\r
+    float scale;\r
+    ParameterBlockJAI params = new ParameterBlockJAI("scale");\r
+    params.addSource(planarImage);\r
+    if (getImageHeight() > getImageWidth())\r
+      scale = (float) maxIconSize / (float) getImageHeight();\r
+    else\r
+      scale = (float) maxIconSize / (float) getImageWidth();\r
+\r
+    params.setParameter("xScale", scale);\r
+    params.setParameter("yScale", scale);\r
+    params.setParameter("xTrans", 0.0F);\r
+    params.setParameter("yTrans", 0.0F);\r
+    params.setParameter("interpolation", new InterpolationBilinear());\r
+    PlanarImage temp = JAI.create("scale", params);\r
+    JAI.create("encode", temp, outStream, _type, null);\r
+    iconWidth = temp.getWidth();\r
+    iconHeight = temp.getHeight();\r
+  }\r
+\r
+}
\ No newline at end of file
index f1d0d6b..99a0bc3 100755 (executable)
@@ -31,10 +31,10 @@ public class SQLQueryBuilder {
 
   public void appendAndCondition(String aQualifier) {
     if (whereClause.length()==0) {
-      whereClause.append(aQualifier);
+      whereClause.append("(").append(aQualifier).append(")");
     }
     else {
-      whereClause.append("(").append(whereClause).append(") and (").append(aQualifier).append(")");
+      whereClause.append(" and (").append(aQualifier).append(")");
     }
   }
 
index 414eb02..9202738 100755 (executable)
@@ -104,7 +104,6 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
 
     EntityList topicList=null;
     EntityList entityList=null;
-    EntityList parentList=null;
     EntityList languageList=null;
 
     try {
@@ -121,7 +120,6 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
 
     aValueSet.put("topics", topicList);
     aValueSet.put("imclist", entityList);
-    aValueSet.put("parentlist", parentList);
 
     Map articleTypeMap = new HashMap();
     articleTypeMap.put("openposting", "0");
index 74da670..f64d9bd 100755 (executable)
@@ -61,6 +61,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
       String filePath = datePath + anImageEntity.getId() + ext;\r
       String iconFilePath = MirPropertiesConfiguration.instance().getString("Producer.StorageRoot") + getIconStoragePath() + filePath;\r
       String imageFilePath = getStoragePath() + File.separator + filePath;\r
+      int maxIconSize = MirPropertiesConfiguration.instance().getInt("Producer.Image.MaxIconSize");\r
 \r
       File imageFile = new File(imageFilePath);\r
       File iconFile = new File(iconFilePath);\r
@@ -71,7 +72,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
       else {\r
         ImageProcessor processor = new ImageProcessor(imageFile, "JPEG");\r
 \r
-        processor.descaleImage(150, 0.8F);\r
+        processor.descaleImage(maxIconSize, 0.2F);\r
         File dir = new File(iconFile.getParent());\r
           if (dir!=null && !dir.exists()){\r
             dir.mkdirs();\r
index 135a212..b1e0c10 100755 (executable)
@@ -9,6 +9,8 @@ import mir.generator.Generator;
 import mir.servlet.ServletModuleException;
 import mir.util.NullWriter;
 import mir.util.ResourceBundleGeneratorFunction;
+import mir.entity.adapter.*;
+import mir.util.*;
 import mircoders.global.MirGlobal;
 
 import org.apache.struts.util.MessageResources;
@@ -24,6 +26,30 @@ public class ServletHelper {
 
       MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(result);
 
+      Object languages =
+          new CachingRewindableIterator(
+            new EntityIteratorAdapter( "", "id", 30,
+               MirGlobal.localizer().dataModel().adapterModel(), "language"));
+      Object topics =
+          new CachingRewindableIterator(
+            new EntityIteratorAdapter("", "id", 30,
+               MirGlobal.localizer().dataModel().adapterModel(), "topic"));
+
+      Object articleTypes =
+          new CachingRewindableIterator(
+            new EntityIteratorAdapter( "", "id", 30,
+               MirGlobal.localizer().dataModel().adapterModel(), "articleType"));
+
+      Object commentStatuses =
+          new CachingRewindableIterator(
+            new EntityIteratorAdapter( "", "id", 30,
+               MirGlobal.localizer().dataModel().adapterModel(), "commentStatus"));
+
+      result.put("commentstatuses", commentStatuses);
+      result.put("articletypes", articleTypes);
+      result.put("languages", languages);
+      result.put("topics", topics);
+
       result.put( "lang",
           new ResourceBundleGeneratorFunction( aLocale,
                   MessageResources.getMessageResources("bundles.adminlocal"),
index 5fcc9e2..7f43dc4 100755 (executable)
@@ -48,6 +48,7 @@ import mir.util.CachingRewindableIterator;
 import mir.util.HTTPRequestParser;
 import mir.util.JDBCStringRoutines;
 import mir.util.URLBuilder;
+import mir.util.SQLQueryBuilder;
 import mircoders.global.MirGlobal;
 import mircoders.module.ModuleComment;
 import mircoders.module.ModuleContent;
@@ -134,56 +135,44 @@ public class ServletModuleComment extends ServletModule
   public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException
   {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+    SQLQueryBuilder queryBuilder = new SQLQueryBuilder();
 
     String queryField = "";
     String searchField = requestParser.getParameter("searchfield");
     String searchText = requestParser.getParameter("searchtext");
     String searchIsPublished = requestParser.getParameter("searchispublished");
+    String searchStatus = requestParser.getParameter("searchstatus");
     String searchOrder = requestParser.getParameter("searchorder");
 
-    String whereClause = " (1=1) ";
-    String orderClause = "webdb_create desc";
-
     if (searchIsPublished.equals("0")) {
-      whereClause=whereClause + "is_published='f'";
+      queryBuilder.appendAndCondition("is_published='f'");
     }
     else if (searchIsPublished.equals("1")) {
-      whereClause=whereClause + "is_published='t'";
+      queryBuilder.appendAndCondition("is_published='t'");
     }
 
-    if (!searchField.equals("") && !searchText.equals("")) {
-      queryField="";
-
-      if (searchField.equals("title"))
-        queryField = "title";
-      else if (searchField.equals("creator"))
-        queryField = "creator";
-      else if (searchField.equals("description"))
-        queryField = "description";
-      else
-        queryField = "";
-
-      if (!queryField.equals("")) {
-        if (!whereClause.equals(""))
-          whereClause = whereClause + " and ";
-
-        whereClause = whereClause + "lower(" + queryField + ") like '%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'";
-      }
+    if (searchText.length()>0) {
+        queryBuilder.appendAndCondition(
+          "lower("+ searchField + ") like " +
+          "'%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'");
     }
 
-    System.out.println("search order = " + searchOrder);
-
-    if (searchOrder.equals("datedesc")) {
-      orderClause = "webdb_create desc";
+    if (searchStatus.length()>0) {
+      queryBuilder.appendAndCondition("to_comment_status="+Integer.parseInt(searchStatus));
     }
-    else if (searchOrder.equals("dateasc")) {
-      orderClause = "webdb_create asc";
-    }
-    else if (searchOrder.equals("articletitle")) {
-      orderClause = "(select content.title from content where content.id = comment.to_media) asc";
+
+    if (searchOrder.length()>0) {
+      if (searchOrder.equals("datedesc"))
+        queryBuilder.appendAscendingOrder("webdb_create");
+      else if (searchOrder.equals("dateasc"))
+        queryBuilder.appendDescendingOrder("webdb_create");
+      else if (searchOrder.equals("articletitle"))
+        queryBuilder.appendAscendingOrder("(select content.title from content where content.id = comment.to_media)");
+      else if (searchOrder.equals("creator"))
+        queryBuilder.appendDescendingOrder("creator");
     }
 
-    returnCommentList(aRequest, aResponse, whereClause, orderClause, 0);
+    returnCommentList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);
   }
 
   public void articlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
@@ -238,11 +227,13 @@ public class ServletModuleComment extends ServletModule
       urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));
       urlBuilder.setValue("searchtext", requestParser.getParameter("searchtext"));
       urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));
+      urlBuilder.setValue("searchstatus", requestParser.getParameter("searchstatus"));
       urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));
 
       responseData.put("searchfield", requestParser.getParameter("searchfield"));
       responseData.put("searchtext", requestParser.getParameter("searchtext"));
       responseData.put("searchispublished", requestParser.getParameter("searchispublished"));
+      responseData.put("searchstatus", requestParser.getParameter("searchstatus"));
       responseData.put("searchorder", requestParser.getParameter("searchorder"));
 
       urlBuilder.setValue("offset", anOffset);
index 4b955e5..f37ccf3 100755 (executable)
@@ -84,7 +84,7 @@ import freemarker.template.TemplateModelRoot;
  *  ServletModuleContent -\r
  *  deliver html for the article admin form.\r
  *\r
- * @version $Id: ServletModuleContent.java,v 1.33 2003/02/20 16:05:34 zapata Exp $\r
+ * @version $Id: ServletModuleContent.java,v 1.34 2003/02/21 05:37:59 zapata Exp $\r
  * @author rk, mir-coders\r
  *\r
  */\r
@@ -155,7 +155,7 @@ public class ServletModuleContent extends ServletModule
       }\r
 \r
       if (searchArticleType.length()>0) {\r
-        queryBuilder.appendAndCondition("to_article_type="+searchArticleType);\r
+        queryBuilder.appendAndCondition("to_article_type="+Integer.parseInt(searchArticleType));\r
       }\r
 \r
       if (searchOrder.length()>0) {\r
@@ -399,22 +399,6 @@ public class ServletModuleContent extends ServletModule
       }\r
       responseData.put("article", article);\r
 \r
-      Object languages =\r
-          new CachingRewindableIterator(\r
-            new EntityIteratorAdapter( "", "id", 30,\r
-               MirGlobal.localizer().dataModel().adapterModel(), "language"));\r
-      Object topics =\r
-          new CachingRewindableIterator(\r
-            new EntityIteratorAdapter("", "id", 30,\r
-               MirGlobal.localizer().dataModel().adapterModel(), "topic"));\r
-      Object articleTypes =\r
-          new CachingRewindableIterator(\r
-            new EntityIteratorAdapter( "", "id", 30,\r
-               MirGlobal.localizer().dataModel().adapterModel(), "articleType"));\r
-\r
-      responseData.put("articleTypes", articleTypes);\r
-      responseData.put("languages", languages);\r
-      responseData.put("topics", topics);\r
       responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
       responseData.put("thisurl", urlBuilder.getQuery());\r
 \r
index 965a5a2..14f29b5 100755 (executable)
    
   <table border="0" cellpadding="2" cellspacing="1">
     <tr class="pink">
-      <td>
-        search in field
-      </td>
-      <td>
-        for value
-      </td>
-      <td>
-        published
-      </td>
-<comment>      
-      <td>
-        status
-      </td>
-</comment>      
-      <td>
-        order
-      </td>
+      <td>${lang("commentsearch.field")}</td>
+      <td>${lang("commentsearch.value")}</td>
+      <td>${lang("commentsearch.publishedstate")}</td>
+      <td>${lang("commentsearch.status")}</td>
+      <td>${lang("commentsearch.order")}</td>
     </tr>
     <tr>
       <td>
 
       <td>
              <select name="searchfield">
-            <option value="title"<if searchfield=="title"> selected</if>>${lang("comment.title")}</option>
-            <option value="creator"<if searchfield=="creator"> selected</if>>${lang("comment.creator")}</option>
-            <option value="description"<if searchfield=="description"> selected</if>>${lang("comment.text")}</option>
+            <option value="title"<if searchfield=="title"> selected</if>>${lang("commentsearch.field.title")}</option>
+            <option value="creator"<if searchfield=="creator"> selected</if>>${lang("commentsearch.field.creator")}</option>
+            <option value="description"<if searchfield=="description"> selected</if>>${lang("commentsearch.field.description")}</option>
           </select>
       </td>
       <td>
           <select name="searchispublished">
             <option value="">--</option>
-            <option value="0" <if searchispublished=="0"> selected</if>>${lang("commentlist.hidden")}</option>
-            <option value="1" <if searchispublished=="1"> selected</if>>${lang("commentlist.published")}</option>
+            <option value="0" <if searchispublished=="0"> selected</if>>${lang("commentsearch.publishedstate.hidden")}</option>
+            <option value="1" <if searchispublished=="1"> selected</if>>${lang("commentsearch.publishedstate.published")}</option>
           </select>
       </td>
-<comment>
       <td>
           <select name="searchstatus">
             <option value="">--</option>
-            <option value="0" <if searchstatus=="0"> selected</if>>${lang("commentlist.hidden")}</option>
-            <option value="1" <if searchstatus=="1"> selected</if>>${lang("commentlist.published")}</option>
+            <list commentstatuses as cs>
+              <option value="${cs.id}" <if searchstatus==cs.id> selected</if>>${lang("commentstatus." + cs.name)}</option>
+            </list>
           </select>
       </td>
-</comment>
       <td>
           <select name="searchorder">
-            <option value="datedesc" <if searchorder=="datedesc"> selected</if>>${lang("commentlist.order.datedesc")}</option>
-            <option value="dateasc" <if searchorder=="dateasc"> selected</if>>${lang("commentlist.order.dateasc")}</option>
-            <option value="articletitle" <if searchorder=="articletitle"> selected</if>>${lang("commentlist.order.articletitle")}</option>
+            <option value="datedesc" <if searchorder=="datedesc"> selected</if>>${lang("commentsearch.order.datedesc")}</option>
+            <option value="dateasc" <if searchorder=="dateasc"> selected</if>>${lang("commentsearch.order.dateasc")}</option>
+            <option value="articletitle" <if searchorder=="articletitle"> selected</if>>${lang("commentsearch.order.articletitle")}</option>
           </select>
       </td>
       <td>
-          <input type="submit" name="search" value="${lang("commentlist.search")}">
+          <input class="majorbutton" type="submit" name="search" value="${lang("commentsearch.searchbutton")}">
       </td>
     </tr>
   </table>
index 84cf9df..78c9494 100755 (executable)
@@ -81,7 +81,7 @@
           <tr>
             <td>
               <select name="to_article_type">
-                <list articleTypes as a>
+                <list articletypes as a>
                   <option value="${a.id}" <if (a.id == article.to_article_type)>selected</if>>${lang("articletypes."+a.name)}</option>
                 </list>
               </select>
index bfae89c..61d2765 100755 (executable)
     <include "head.template">
     
     <if showsearch=="1">
-      <form method="get" action="${config.actionRoot}">
+      <form method="POST" action="${config.actionRoot}">
         <input type="hidden" name="module" value="Content">
         <input type="hidden" name="do" value="search">
         <input type="hidden" name="selectarticleurl" value="${utility.encodeHTML(selectarticleurl)}">
          
         <table border="0" cellpadding="2" cellspacing="1">
           <tr class="pink">
-            <td>for value</td>
-            <td>search in field</td>
-            <td>published</td>
-            <td>article type</td>
-            <td>order</td>
+            <td>${lang("contentsearch.value")}</td>
+            <td>${lang("contentsearch.field")}</td>
+            <td>${lang("contentsearch.publishedstate")}</td>
+            <td>${lang("contentsearch.articletype")}</td>
+            <td>${lang("contentsearch.order")}</td>
           </tr>
           <tr>
-            <td><input type="text"   size="10" maxlength="20" name="searchvalue" value="${searchvalue}"></td>
+            <td><input type="text" size="10" maxlength="20" name="searchvalue" value="${searchvalue}"></td>
             <td>
                      <select name="searchfield">
-                  <option value="title"<if searchfield=="title"> selected</if>>${lang("content.title")}</option>
-                  <option value="creator"<if searchfield=="creator"> selected</if>>${lang("content.creator")}</option>
-                  <option value="contents"<if searchfield=="content"> selected</if>>${lang("content.contents")}</option>
+                  <option value="title"<if searchfield=="title"> selected</if>>${lang("contentsearch.field.title")}</option>
+                  <option value="creator"<if searchfield=="creator"> selected</if>>${lang("contentsearch.field.creator")}</option>
+                  <option value="contents"<if searchfield=="content"> selected</if>>${lang("contentsearch.field.contents")}</option>
                 </select>
             </td>
             <td>
                 <select name="searchispublished">
                   <option value="">--</option>
-                  <option value="0" <if searchispublished=="0"> selected</if>>${lang("contentlist.hidden")}</option>
-                  <option value="1" <if searchispublished=="1"> selected</if>>${lang("contentlist.published")}</option>
+                  <option value="0" <if searchispublished=="0"> selected</if>>${lang("contentsearch.publishedstate.hidden")}</option>
+                  <option value="1" <if searchispublished=="1"> selected</if>>${lang("contentsearch.publishedstate.published")}</option>
                 </select>
             </td>
             <td>
                 <select name="searcharticletype">
                   <option value="">--</option>
                   <list articletypes as at>
-                    <option value="${at.id}" <if searcharticletype=="${at.id}"> selected</if>>${lang("articletype."+at.name)}</option>
+                    <option value="${at.id}" <if searcharticletype==at.id> selected</if>>${lang("articletype."+at.name)}</option>
                   </list>
                 </select>
             </td>
             <td>
                 <select name="searchorder">
-                  <option value="datedesc" <if searchorder=="datedesc"> selected</if>>${lang("contentlist.order.datedesc")}</option>
-                  <option value="dateasc" <if searchorder=="dateasc"> selected</if>>${lang("contentlist.order.dateasc")}</option>
-                  <option value="title" <if searchorder=="title"> selected</if>>${lang("contentlist.order.title")}</option>
-                  <option value="creator" <if searchorder=="creator"> selected</if>>${lang("contentlist.order.creator")}</option>
+                  <option value="datedesc" <if searchorder=="datedesc"> selected</if>>${lang("contentsearch.order.datedesc")}</option>
+                  <option value="dateasc" <if searchorder=="dateasc"> selected</if>>${lang("contentsearch.order.dateasc")}</option>
+                  <option value="title" <if searchorder=="title"> selected</if>>${lang("contentsearch.order.title")}</option>
+                  <option value="creator" <if searchorder=="creator"> selected</if>>${lang("contentsearch.order.creator")}</option>
                 </select>
             </td>
             <td>
-                <input type="submit" name="search" value="${lang("contentlist.search")}">
+                <input class="majorbutton" type="submit" name="search" value="${lang("contentsearch.searchbutton")}">
             </td>
           </tr>
         </table>