fix trivial thinko bug regarding the nexturl
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
index c2f57b6..3822b64 100755 (executable)
@@ -62,14 +62,13 @@ import mircoders.localizer.*;
  *  ServletModuleContent -
  *  deliver html for the article admin form.
  *
- * @version $Id: ServletModuleContent.java,v 1.24 2002/11/30 19:45:56 zapata Exp $
+ * @version $Id: ServletModuleContent.java,v 1.30 2002/12/28 03:14:42 mh Exp $
  * @author rk, mir-coders
  *
  */
 
 public class ServletModuleContent extends ServletModule
 {
-
   static ModuleTopics         themenModule;
   static ModuleSchwerpunkt    schwerpunktModule;
   static ModuleImages         imageModule;
@@ -85,9 +84,9 @@ public class ServletModuleContent extends ServletModule
     logger = new LoggerWrapper("ServletModule.Content");
     try {
       templateListString = MirConfig.getProp("ServletModule.Content.ListTemplate");
-//templateOpString = MirConfig.getProp("ServletModule.Content.OpTemplate");
       templateObjektString = MirConfig.getProp("ServletModule.Content.ObjektTemplate");
       templateConfirmString = MirConfig.getProp("ServletModule.Content.ConfirmTemplate");
+
       mainModule = new ModuleContent(DatabaseContent.getInstance());
       themenModule = new ModuleTopics(DatabaseTopics.getInstance());
       schwerpunktModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance());
@@ -157,7 +156,7 @@ public class ServletModuleContent extends ServletModule
       String        orderParam = req.getParameter("order");
 
       theList = ((ModuleContent)mainModule).getContentByField(fieldParam, fieldValueParam, orderParam, 0, user);
-      returnArticleList(req, res, "lower("+ fieldParam + ") like lower('%" + StringUtil.quote(fieldValueParam) + "%')", orderParam, 0);
+      returnArticleList(req, res, "lower("+ fieldParam + ") like lower('%" + JDBCStringRoutines.escapeStringLiteral(fieldValueParam) + "%')", orderParam, 0);
     } catch (ModuleException e) {
       throw new ServletModuleException(e.toString());
     }
@@ -251,7 +250,7 @@ public class ServletModuleContent extends ServletModule
   public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
   {
     String        idParam = req.getParameter("id");
-    if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben");
+    if (idParam == null) throw new ServletModuleException("Invalid call: id not supplied ");
     _showObject(idParam, req, res);
   }
 
@@ -329,7 +328,7 @@ public class ServletModuleContent extends ServletModule
       HashMap withValues = getIntersectingValues(req, DatabaseContent.getInstance());
       String[] topic_id = req.getParameterValues("to_topic");
       String content_id = req.getParameter("id");
-// withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));
+
       if(user != null) withValues.put("user_id", user.getId());
       withValues.put("is_produced", "0");
       if (!withValues.containsKey("is_published"))
@@ -337,18 +336,13 @@ public class ServletModuleContent extends ServletModule
       if (!withValues.containsKey("is_html"))
         withValues.put("is_html","0");
 
-//      ML: this is not multi-language friendly and this can be done in a template
-//      if (withValues.get("creator").toString().equals(""))
-//        withValues.put("creator","Anonym");
-
-//theLog.printDebugInfo("updating. ");
       String id = mainModule.set(withValues);
       DatabaseContentToTopics.getInstance().setTopics(req.getParameter("id"),topic_id);
-//theLog.printDebugInfo("update done. ");
+
       String whereParam = req.getParameter("where");
       String orderParam = req.getParameter("order");
+
       if ((whereParam!=null && !whereParam.equals("")) || (orderParam!=null && !orderParam.equals(""))){
-        //theLog.printDebugInfo("update to list");
         list(req,res);
       }
       else
@@ -374,9 +368,11 @@ public class ServletModuleContent extends ServletModule
     SimpleHash extraInfo = new SimpleHash();
     try {
       TemplateModelRoot entContent;
+
       if (id != null) {
         entContent = (TemplateModelRoot)mainModule.getById(id);
-      } else {
+      }
+      else {
         SimpleHash withValues = new SimpleHash();
         withValues.put("new", "1");
         withValues.put("is_published", "0");
@@ -388,20 +384,8 @@ public class ServletModuleContent extends ServletModule
       }
 
       extraInfo.put("themenPopupData", themenModule.getTopicsAsSimpleList());
-      try {
-        extraInfo.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData());
-      }
-      catch (Exception e) {
-        logger.error("articletype could not be fetched.");
-      }
-      try {
-        extraInfo.put("languagePopupData", DatabaseLanguage.getInstance().getPopupData());
-      }
-      catch (Exception e) {
-        logger.error("language-popup could not be fetched.");
-      }
-
-      extraInfo.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList());
+      extraInfo.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData());
+      extraInfo.put("languagePopupData", DatabaseLanguage.getInstance().getPopupData());
 
       // code to be able to return to the list:
       String offsetParam, whereParam, orderParam;
@@ -423,7 +407,7 @@ public class ServletModuleContent extends ServletModule
     //     old one...
 
     EntityAdapterModel model;
-    int nrArticlesPerPage = 30;
+    int nrArticlesPerPage = 20;
     int count;
 
     try {
@@ -432,7 +416,7 @@ public class ServletModuleContent extends ServletModule
 
       Object contentList =
           new CachingRewindableIterator(
-          new EntityIteratorAdapter( aWhereClause, anOrderByClause, 20,
+          new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage,
           MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset)
       );
 
@@ -445,7 +429,7 @@ public class ServletModuleContent extends ServletModule
         responseData.put("nexturl" ,
                          "module=Content&do=list&where=" + HTMLRoutines.encodeURL(aWhereClause) +
                          "&order=" + HTMLRoutines.encodeURL(anOrderByClause) +
-                         "&offset=" + anOffset + nrArticlesPerPage);
+                         "&offset=" + (anOffset + nrArticlesPerPage));
       }
       if (anOffset>0) {
         responseData.put("prevurl" ,