From b9787d33eb4cfcbde4d48e9dc48db3f4ecb4eab4 Mon Sep 17 00:00:00 2001
From: zapata
Date: Mon, 21 Jul 2003 07:01:14 +0000
Subject: [PATCH] misc fixes + updates: - fixed hidden articles module -
comments are now shown per comment_Status value on the start page
---
bundles/admin_en.properties | 9 +-
source/mircoders/accesscontrol/AccessControl.java | 38 +-
source/mircoders/servlet/ServletModuleComment.java | 646 +++++------
source/mircoders/servlet/ServletModuleContent.java | 1137 ++++++++++----------
source/mircoders/servlet/ServletModuleHidden.java | 79 +-
source/mircoders/servlet/ServletModuleUsers.java | 46 +-
templates/admin/hiddenlist.template | 54 +-
templates/admin/start_admin.template | 9 +-
8 files changed, 1026 insertions(+), 992 deletions(-)
diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties
index 10ecc057..30d45e08 100755
--- a/bundles/admin_en.properties
+++ b/bundles/admin_en.properties
@@ -1,6 +1,6 @@
########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48.2.7 2003/07/20 05:49:47 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.8 2003/07/21 07:01:14 zapata Exp $
languagename=English
@@ -302,6 +302,7 @@ start.content.all=all articles
start.content.search=search
start.allarticlesoftype={0}
+start.allcommentswithstatus={0}
start.producers.title=GENERATE MANUALLY
start.producers.produceAllNew=generate all new
@@ -310,8 +311,10 @@ start.producers.advanced=advanced page (use with care!)
start.administer.title=ADMINISTER
start.administer.comments=comments
+start.comments.title=COMMENTS
+
start.breaking.title=breaking news
-start.list.title=LIST
+start.articles.title=ARTICLES
start.fileedit.includes.title=edit include files
start.addandedit.title=ADD / EDIT
start.extra.title=EXTRA
@@ -483,8 +486,6 @@ articletypes.startspecial=Startpage-special
# Comment status values
commentstatus.normal=normal
-commentstatus.good=good
-commentstatus.bad=bad
diff --git a/source/mircoders/accesscontrol/AccessControl.java b/source/mircoders/accesscontrol/AccessControl.java
index fcfb3dc5..7e15db7d 100755
--- a/source/mircoders/accesscontrol/AccessControl.java
+++ b/source/mircoders/accesscontrol/AccessControl.java
@@ -39,6 +39,7 @@ import mircoders.entity.EntityUsers;
public class AccessControl {
private UserAccessControl user;
+ private GeneralAccessControl general;
protected LoggerWrapper logger = new LoggerWrapper("Global.AccessControl");
protected MirPropertiesConfiguration configuration;
@@ -47,6 +48,7 @@ public class AccessControl {
configuration = MirPropertiesConfiguration.instance();
user = new UserAccessControl(configuration.getVector("AccessControl.SuperUsers"));
+ general = new GeneralAccessControl();
}
catch (Throwable t) {
throw new RuntimeException(t.toString());
@@ -57,6 +59,40 @@ public class AccessControl {
return user;
}
+ public GeneralAccessControl general() {
+ return general;
+ }
+
+ public class GeneralAccessControl {
+ public boolean mayDeleteArticles(EntityUsers aSubject) {
+ return configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1");
+ }
+
+ public void assertMayDeleteArticles(EntityUsers aSubject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayDeleteArticles(aSubject))
+ throw new AuthorizationExc("not allowed to delete articles");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+ }
+
+ public boolean mayDeleteComments(EntityUsers aSubject) {
+ return configuration.getString("Mir.Localizer.Admin.AllowDeleteComment", "0").equals("1");
+ }
+
+ public void assertMayDeleteComments(EntityUsers aSubject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayDeleteArticles(aSubject))
+ throw new AuthorizationExc("not allowed to delete comments");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+ }
+ }
+
public class UserAccessControl {
private List superusers;
@@ -128,8 +164,6 @@ public class AccessControl {
catch (Throwable t) {
throw new AuthorizationFailure(t);
}
-
}
-
}
}
diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java
index c8ef0fa5..f0bb299a 100755
--- a/source/mircoders/servlet/ServletModuleComment.java
+++ b/source/mircoders/servlet/ServletModuleComment.java
@@ -1,321 +1,325 @@
-/*
- * 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 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.servlet;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.adapter.EntityAdapterModel;
-import mir.entity.adapter.EntityIteratorAdapter;
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import mir.servlet.ServletModuleUserExc;
-import mir.util.CachingRewindableIterator;
-import mir.util.HTTPRequestParser;
-import mir.util.JDBCStringRoutines;
-import mir.util.SQLQueryBuilder;
-import mir.util.URLBuilder;
-import mircoders.entity.EntityComment;
-import mircoders.global.MirGlobal;
-import mircoders.module.ModuleComment;
-import mircoders.module.ModuleContent;
-import mircoders.storage.DatabaseComment;
-import mircoders.storage.DatabaseContent;
-
-/*
- * ServletModuleComment - controls navigation for Comments
- *
- *
- * @author RK
- */
-
-public class ServletModuleComment extends ServletModule
-{
- private ModuleContent moduleContent;
-
- private static ServletModuleComment instance = new ServletModuleComment();
- public static ServletModule getInstance() { return instance; }
-
- private ServletModuleComment() {
- logger = new LoggerWrapper("ServletModule.Comment");
- try {
- configuration = MirPropertiesConfiguration.instance();
- templateListString = configuration.getString("ServletModule.Comment.ListTemplate");
- templateObjektString = configuration.getString("ServletModule.Comment.ObjektTemplate");
- templateConfirmString = configuration.getString("ServletModule.Comment.ConfirmTemplate");
-
- mainModule = new ModuleComment(DatabaseComment.getInstance());
- moduleContent = new ModuleContent(DatabaseContent.getInstance());
- }
- catch (Exception e) {
- logger.error("servletmodule comment could not be initialized:" + e.getMessage());
- }
- }
-
- public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- if (!configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1"))
- throw new ServletModuleExc("Operation not permitted");
-
- super.delete(req, res);
- }
-
- public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String idParam = req.getParameter("id");
-
- if (idParam == null)
- throw new ServletModuleExc("Invalid call: id not supplied ");
-
- showComment(idParam, req, res);
- }
-
- public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});
- EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
- Map comment;
- URLBuilder urlBuilder = new URLBuilder();
-
- urlBuilder.setValue("module", "Comment");
- urlBuilder.setValue("do", "edit");
- urlBuilder.setValue("id", anId);
- urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
-
- if (anId != null) {
- responseData.put("new", Boolean.FALSE);
- comment = model.makeEntityAdapter("comment", mainModule.getById(anId));
- }
- else {
- List fields = DatabaseComment.getInstance().getFields();
- responseData.put("new", Boolean.TRUE);
- comment = new HashMap();
- Iterator i = fields.iterator();
- while (i.hasNext()) {
- comment.put(i.next(), null);
- }
- }
- responseData.put("comment", comment);
-
- responseData.put("returnurl", requestParser.getParameter("returnurl"));
- responseData.put("thisurl", urlBuilder.getQuery());
-
- ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateObjektString);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void attach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String mediaIdParam = req.getParameter("mid");
- String commentId = req.getParameter("commentid");
-
- if (commentId == null || mediaIdParam==null) throw new ServletModuleExc("smod comment :: attach :: commentid/mid missing");
-
- try {
- EntityComment comment = (EntityComment) mainModule.getById(commentId);
- comment.attach(mediaIdParam);
- }
- catch(Throwable e) {
- throw new ServletModuleFailure(e);
- }
-
- showComment(commentId, req, res);
- }
-
- public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String commentId = req.getParameter("commentid");
- String midParam = req.getParameter("mid");
- if (commentId == null)
- throw new ServletModuleExc("smod comment :: dettach :: commentid missing");
- if (midParam == null)
- throw new ServletModuleExc("smod comment :: dettach :: mid missing");
-
- try {
- EntityComment comment = (EntityComment)mainModule.getById(commentId);
- comment.dettach(commentId, midParam);
- }
- catch(Throwable e) {
- throw new ServletModuleFailure(e);
- }
-
- showComment(commentId, req, res);
- }
-
-
- public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
- String where = requestParser.getParameter("where");
- String order = requestParser.getParameterWithDefault("order", "webdb_create desc");
- int offset = requestParser.getIntegerWithDefault("offset", 0);
-
- returnCommentList(aRequest, aResponse, where, order, offset);
- }
-
- public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- 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");
-
- if (searchIsPublished.equals("0")) {
- queryBuilder.appendAndCondition("is_published='f'");
- }
- else if (searchIsPublished.equals("1")) {
- queryBuilder.appendAndCondition("is_published='t'");
- }
-
- if (searchText.length()>0) {
- queryBuilder.appendAndCondition(
- "lower("+ searchField + ") like " +
- "'%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'");
- }
-
- if (searchStatus.length()>0) {
- queryBuilder.appendAndCondition("to_comment_status="+Integer.parseInt(searchStatus));
- }
-
- 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, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);
- }
-
- public void articlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
- String articleIdString = req.getParameter("articleid");
- int articleId;
-
- try {
- articleId = Integer.parseInt(articleIdString);
-
- returnCommentList( req, res, "to_media="+articleId, "webdb_create desc", 0);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void returnCommentList(HttpServletRequest aRequest, HttpServletResponse aResponse,
- String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {
-
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- URLBuilder urlBuilder = new URLBuilder();
- EntityAdapterModel model;
- int nrCommentsPerPage = 20;
- int count;
-
- try {
- Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
- model = MirGlobal.localizer().dataModel().adapterModel();
-
- Object commentList =
- new CachingRewindableIterator(
- new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrCommentsPerPage,
- MirGlobal.localizer().dataModel().adapterModel(), "comment", nrCommentsPerPage, anOffset)
- );
-
- responseData.put("nexturl", null);
- responseData.put("prevurl", null);
-
- count=mainModule.getSize(aWhereClause);
-
- urlBuilder.setValue("module", "Comment");
- urlBuilder.setValue("do", "list");
- urlBuilder.setValue("where", aWhereClause);
- urlBuilder.setValue("order", anOrderByClause);
-
- 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);
- responseData.put("offset" , new Integer(anOffset).toString());
- responseData.put("thisurl" , urlBuilder.getQuery());
-
- if (count>=anOffset+nrCommentsPerPage) {
- urlBuilder.setValue("offset", anOffset + nrCommentsPerPage);
- responseData.put("nexturl" , urlBuilder.getQuery());
- }
-
- if (anOffset>0) {
- urlBuilder.setValue("offset", Math.max(anOffset - nrCommentsPerPage, 0));
- responseData.put("prevurl" , urlBuilder.getQuery());
- }
-
- responseData.put("comments", commentList);
- responseData.put("from" , Integer.toString(anOffset+1));
- responseData.put("count", Integer.toString(count));
- responseData.put("to", Integer.toString(Math.min(anOffset+nrCommentsPerPage, count)));
-
- ServletHelper.generateResponse(aResponse.getWriter(), responseData, "commentlist.template");
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-}
-
+/*
+ * 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 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.servlet;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.adapter.EntityAdapterModel;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.log.LoggerWrapper;
+import mir.servlet.ServletModule;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
+import mir.servlet.ServletModuleUserExc;
+import mir.util.CachingRewindableIterator;
+import mir.util.HTTPRequestParser;
+import mir.util.JDBCStringRoutines;
+import mir.util.SQLQueryBuilder;
+import mir.util.URLBuilder;
+import mircoders.entity.EntityComment;
+import mircoders.global.MirGlobal;
+import mircoders.module.ModuleComment;
+import mircoders.module.ModuleContent;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseContent;
+
+/*
+ * ServletModuleComment - controls navigation for Comments
+ *
+ *
+ * @author the mir-coders
+ */
+
+public class ServletModuleComment extends ServletModule
+{
+ private ModuleContent moduleContent;
+
+ private static ServletModuleComment instance = new ServletModuleComment();
+ public static ServletModule getInstance() { return instance; }
+
+ private ServletModuleComment() {
+ logger = new LoggerWrapper("ServletModule.Comment");
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ templateListString = configuration.getString("ServletModule.Comment.ListTemplate");
+ templateObjektString = configuration.getString("ServletModule.Comment.ObjektTemplate");
+ templateConfirmString = configuration.getString("ServletModule.Comment.ConfirmTemplate");
+
+ mainModule = new ModuleComment(DatabaseComment.getInstance());
+ moduleContent = new ModuleContent(DatabaseContent.getInstance());
+ }
+ catch (Exception e) {
+ logger.error("servletmodule comment could not be initialized:" + e.getMessage());
+ }
+ }
+
+ public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ try {
+ MirGlobal.accessControl().general().assertMayDeleteComments(ServletHelper.getUser(aRequest));
+
+ super.delete(aRequest, aResponse);
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
+ }
+
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String idParam = aRequest.getParameter("id");
+
+ if (idParam == null)
+ throw new ServletModuleExc("Invalid call: id not supplied ");
+
+ showComment(idParam, aRequest, aResponse);
+ }
+
+ public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});
+ EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
+ Map comment;
+ URLBuilder urlBuilder = new URLBuilder();
+
+ urlBuilder.setValue("module", "Comment");
+ urlBuilder.setValue("do", "edit");
+ urlBuilder.setValue("id", anId);
+ urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
+
+ if (anId != null) {
+ responseData.put("new", Boolean.FALSE);
+ comment = model.makeEntityAdapter("comment", mainModule.getById(anId));
+ }
+ else {
+ List fields = DatabaseComment.getInstance().getFields();
+ responseData.put("new", Boolean.TRUE);
+ comment = new HashMap();
+ Iterator i = fields.iterator();
+ while (i.hasNext()) {
+ comment.put(i.next(), null);
+ }
+ }
+ responseData.put("comment", comment);
+
+ responseData.put("returnurl", requestParser.getParameter("returnurl"));
+ responseData.put("thisurl", urlBuilder.getQuery());
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateObjektString);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String mediaIdParam = aRequest.getParameter("mid");
+ String commentId = aRequest.getParameter("commentid");
+
+ if (commentId == null || mediaIdParam==null) throw new ServletModuleExc("smod comment :: attach :: commentid/mid missing");
+
+ try {
+ EntityComment comment = (EntityComment) mainModule.getById(commentId);
+ comment.attach(mediaIdParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ showComment(commentId, aRequest, aResponse);
+ }
+
+ public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String commentId = aRequest.getParameter("commentid");
+ String midParam = aRequest.getParameter("mid");
+ if (commentId == null)
+ throw new ServletModuleExc("smod comment :: dettach :: commentid missing");
+ if (midParam == null)
+ throw new ServletModuleExc("smod comment :: dettach :: mid missing");
+
+ try {
+ EntityComment comment = (EntityComment)mainModule.getById(commentId);
+ comment.dettach(commentId, midParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ showComment(commentId, aRequest, aResponse);
+ }
+
+
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String where = requestParser.getParameter("where");
+ String order = requestParser.getParameterWithDefault("order", "webdb_create desc");
+ int offset = requestParser.getIntegerWithDefault("offset", 0);
+
+ returnCommentList(aRequest, aResponse, where, order, offset);
+ }
+
+ public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ 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");
+
+ if (searchIsPublished.equals("0")) {
+ queryBuilder.appendAndCondition("is_published='f'");
+ }
+ else if (searchIsPublished.equals("1")) {
+ queryBuilder.appendAndCondition("is_published='t'");
+ }
+
+ if (searchText.length()>0) {
+ queryBuilder.appendAndCondition(
+ "lower("+ searchField + ") like " +
+ "'%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'");
+ }
+
+ if (searchStatus.length()>0) {
+ queryBuilder.appendAndCondition("to_comment_status="+Integer.parseInt(searchStatus));
+ }
+
+ 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, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);
+ }
+
+ public void articlecomments(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String articleIdString = aRequest.getParameter("articleid");
+ int articleId;
+
+ try {
+ articleId = Integer.parseInt(articleIdString);
+
+ returnCommentList( aRequest, aResponse, "to_media="+articleId, "webdb_create desc", 0);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void returnCommentList(HttpServletRequest aRequest, HttpServletResponse aResponse,
+ String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {
+
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ URLBuilder urlBuilder = new URLBuilder();
+ EntityAdapterModel model;
+ int nrCommentsPerPage = 20;
+ int count;
+
+ try {
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ model = MirGlobal.localizer().dataModel().adapterModel();
+
+ Object commentList =
+ new CachingRewindableIterator(
+ new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrCommentsPerPage,
+ MirGlobal.localizer().dataModel().adapterModel(), "comment", nrCommentsPerPage, anOffset)
+ );
+
+ responseData.put("nexturl", null);
+ responseData.put("prevurl", null);
+
+ count=mainModule.getSize(aWhereClause);
+
+ urlBuilder.setValue("module", "Comment");
+ urlBuilder.setValue("do", "list");
+ urlBuilder.setValue("where", aWhereClause);
+ urlBuilder.setValue("order", anOrderByClause);
+
+ 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);
+ responseData.put("offset" , new Integer(anOffset).toString());
+ responseData.put("thisurl" , urlBuilder.getQuery());
+
+ if (count>=anOffset+nrCommentsPerPage) {
+ urlBuilder.setValue("offset", anOffset + nrCommentsPerPage);
+ responseData.put("nexturl" , urlBuilder.getQuery());
+ }
+
+ if (anOffset>0) {
+ urlBuilder.setValue("offset", Math.max(anOffset - nrCommentsPerPage, 0));
+ responseData.put("prevurl" , urlBuilder.getQuery());
+ }
+
+ responseData.put("comments", commentList);
+ responseData.put("from" , Integer.toString(anOffset+1));
+ responseData.put("count", Integer.toString(count));
+ responseData.put("to", Integer.toString(Math.min(anOffset+nrCommentsPerPage, count)));
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, "commentlist.template");
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+}
+
diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java
index 3671dbf1..c363f435 100755
--- a/source/mircoders/servlet/ServletModuleContent.java
+++ b/source/mircoders/servlet/ServletModuleContent.java
@@ -1,565 +1,572 @@
-/*
- * 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 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.servlet;
-
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import mir.entity.adapter.EntityAdapterModel;
-import mir.entity.adapter.EntityIteratorAdapter;
-import mir.log.LoggerWrapper;
-import mir.misc.StringUtil;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleExc;
-import mir.servlet.ServletModuleFailure;
-import mir.util.CachingRewindableIterator;
-import mir.util.HTTPRequestParser;
-import mir.util.JDBCStringRoutines;
-import mir.util.SQLQueryBuilder;
-import mir.util.URLBuilder;
-import mircoders.entity.EntityContent;
-import mircoders.entity.EntityUsers;
-import mircoders.global.MirGlobal;
-import mircoders.module.ModuleContent;
-import mircoders.search.IndexUtil;
-import mircoders.storage.DatabaseComment;
-import mircoders.storage.DatabaseContent;
-import mircoders.storage.DatabaseContentToMedia;
-import mircoders.storage.DatabaseContentToTopics;
-
-import org.apache.lucene.index.IndexReader;
-
-import freemarker.template.SimpleHash;
-
-/*
- * ServletModuleContent -
- * deliver html for the article admin form.
- *
- * @version $Id: ServletModuleContent.java,v 1.52.2.3 2003/06/19 22:57:34 zapata Exp $
- * @author rk, mir-coders
- *
- */
-
-public class ServletModuleContent extends ServletModule
-{
- private String editTemplate = configuration.getString("ServletModule.Content.ObjektTemplate");;
- private String listTemplate = configuration.getString("ServletModule.Content.ListTemplate");
-
- private static ServletModuleContent instance = new ServletModuleContent();
- public static ServletModule getInstance() { return instance; }
-
- private ServletModuleContent() {
- super();
- logger = new LoggerWrapper("ServletModule.Content");
- try {
-
- templateListString = configuration.getString("ServletModule.Content.ListTemplate");
- templateObjektString = configuration.getString("ServletModule.Content.ObjektTemplate");
- templateConfirmString = configuration.getString("ServletModule.Content.ConfirmTemplate");
-
- mainModule = new ModuleContent(DatabaseContent.getInstance());
- }
- catch (Throwable e) {
- logger.fatal("ServletModuleContent could not be initialized: " + e.toString());
- }
- }
-
- public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
- String where = requestParser.getParameter("where");
- String order = requestParser.getParameterWithDefault("order", "webdb_create desc");
- int offset = requestParser.getIntegerWithDefault("offset", 0);
- String selectArticleUrl = requestParser.getParameter("selectarticleurl");
-
- returnArticleList(aRequest, aResponse, where, order, offset, selectArticleUrl);
- }
-
- public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleFailure {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- SQLQueryBuilder queryBuilder = new SQLQueryBuilder();
- String searchField = requestParser.getParameterWithDefault("searchfield", "");
- String searchValue = requestParser.getParameterWithDefault("searchvalue", "").trim();
- String searchOrder = requestParser.getParameterWithDefault("searchorder", "");
- String searchispublished = requestParser.getParameterWithDefault("searchispublished", "");
- String searchArticleType = requestParser.getParameterWithDefault("searcharticletype", "");
- String selectArticleUrl = requestParser.getParameter("selectarticleurl");
-
- if (searchValue.length()>0) {
- if (searchField.equals("id"))
- queryBuilder.appendAndCondition(
- "id='"+JDBCStringRoutines.escapeStringLiteral(searchValue)+"'");
- else if (searchField.equals("contents"))
- queryBuilder.appendAndCondition(
- "(lower(content_data) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')"+
- " or (lower(description) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')");
- else
- queryBuilder.appendAndCondition(
- "lower("+ searchField + ") like " +
- "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%'");
- }
-
- if (searchispublished.length()>0) {
- if (searchispublished.equals("0"))
- queryBuilder.appendAndCondition("is_published='f'");
- else
- queryBuilder.appendAndCondition("is_published='t'");
- }
-
- if (searchArticleType.length()>0) {
- queryBuilder.appendAndCondition("to_article_type="+Integer.parseInt(searchArticleType));
- }
-
- 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("title"))
- queryBuilder.appendDescendingOrder("title");
- else if (searchOrder.equals("creator"))
- queryBuilder.appendDescendingOrder("creator");
- }
-
- returnArticleList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0, selectArticleUrl);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- _showObject(null, aRequest, aResponse);
- }
-
-
- public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
-//theLog.printDebugInfo(":: content :: trying to insert");
- try {
- Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
-
- String now = StringUtil.date2webdbDate(new GregorianCalendar());
- withValues.put("date", now);
- withValues.put("publish_path", StringUtil.webdbDate2path(now));
- withValues.put("to_publisher", ServletHelper.getUser(aRequest).getId());
- withValues.put("is_produced", "0");
- if (!withValues.containsKey("is_published"))
- withValues.put("is_published","0");
- if (!withValues.containsKey("is_html"))
- withValues.put("is_html","0");
-
- String webdbCreate = (String) withValues.get("webdb_create");
- if (webdbCreate==null || webdbCreate.trim().length()==0)
- withValues.remove("webdb_create");
-
- String id = mainModule.add(withValues);
- List topics;
-
- DatabaseContentToTopics.getInstance().setTopics(id, aRequest.getParameterValues("to_topic"));
-
- _showObject(id, aRequest, aResponse);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- if (!configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1"))
- throw new ServletModuleExc("Operation not permitted");
-
- String idParam = aRequest.getParameter("id");
- if (idParam == null) throw new ServletModuleExc("Invalid call: id missing");
-
- String confirmParam = aRequest.getParameter("confirm");
- String cancelParam = aRequest.getParameter("cancel");
-
- logger.info("where = " + aRequest.getParameter("where"));
-
- if (confirmParam == null && cancelParam == null) {
-
- SimpleHash mergeData = new SimpleHash();
- mergeData.put("module", "Content");
- mergeData.put("infoString", "Content: " + idParam);
- mergeData.put("id", idParam);
- mergeData.put("where", aRequest.getParameter("where"));
- mergeData.put("order", aRequest.getParameter("order"));
- mergeData.put("offset", aRequest.getParameter("offset"));
- deliver(aRequest, aResponse, mergeData, templateConfirmString);
- }
- else {
- if (confirmParam!= null && !confirmParam.equals("")) {
- try {
- mainModule.deleteById(idParam);
-
- /** @todo the following two should be implied in
- * DatabaseContent */
- DatabaseContentToTopics.getInstance().deleteByContentId(idParam);
- DatabaseComment.getInstance().deleteByContentId(idParam);
- DatabaseContentToMedia.getInstance().deleteByContentId(idParam);
-
-
- //delete from lucene index, if any
- String index = configuration.getString("IndexPath");
- if (IndexReader.indexExists(index)){
- IndexUtil.unindexID(idParam,index);
- }
-
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- list(aRequest,aResponse);
- }
- else {
- // Datensatz anzeigen
- _showObject(idParam, aRequest, aResponse);
- }
- }
- }
-
- public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- String idParam = aRequest.getParameter("id");
- if (idParam == null)
- throw new ServletModuleExc("Invalid call: id not supplied ");
- _showObject(idParam, aRequest, aResponse);
- }
-
-// methods for attaching media file
- public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- String mediaIdParam = aRequest.getParameter("mid");
- String articleId = aRequest.getParameter("articleid");
-
- if (articleId == null || mediaIdParam==null)
- throw new ServletModuleExc("smod content :: attach :: articleid/mid missing");
-
- try {
- EntityContent entContent = (EntityContent) mainModule.getById(articleId);
- entContent.attach(mediaIdParam);
- }
- catch(Throwable e) {
- throw new ServletModuleFailure(e);
- }
-
- _showObject(articleId, aRequest, aResponse);
- }
-
- public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- String articleId = aRequest.getParameter("articleid");
- String midParam = aRequest.getParameter("mid");
- if (articleId == null)
- throw new ServletModuleExc("smod content :: dettach :: articleid missing");
- if (midParam == null)
- throw new ServletModuleExc("smod content :: dettach :: mid missing");
-
- try {
- EntityContent entContent = (EntityContent)mainModule.getById(articleId);
- entContent.dettach(articleId, midParam);
- }
- catch(Throwable e) {
- throw new ServletModuleFailure(e);
- }
-
- _showObject(articleId, aRequest, aResponse);
- }
-
- public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
- String returnUrl = requestParser.getParameter("returnurl");
-
- String idParam = aRequest.getParameter("id");
- if (idParam == null)
- throw new ServletModuleExc("Wrong call: (id) is missing");
-
- Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
-
- String content_id = aRequest.getParameter("id");
-
- withValues.put("is_produced", "0");
- if (!withValues.containsKey("is_published"))
- withValues.put("is_published","0");
- if (!withValues.containsKey("is_html"))
- withValues.put("is_html","0");
-
- String webdbCreate = (String) withValues.get("webdb_create");
- if (webdbCreate==null || webdbCreate.trim().length()==0)
- withValues.remove("webdb_create");
-
- String id = mainModule.set(withValues);
- DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"), aRequest.getParameterValues("to_topic"));
-
- String whereParam = aRequest.getParameter("where");
- String orderParam = aRequest.getParameter("order");
-
- if (returnUrl!=null){
- redirect(aResponse, returnUrl);
- }
- else
- _showObject(idParam, aRequest, aResponse);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
-
- /**
- * HelperMethod shows the basic article editing form.
- *
- * if the "id" parameter is null, it means show an empty form to add a new
- * article.
- *
- * @param id
- * @param aRequest
- * @param aResponse
- * @throws ServletModuleExc
- */
- public void _showObject(String id, HttpServletRequest aRequest, HttpServletResponse aResponse)
- throws ServletModuleExc {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
- EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
- Map article;
- URLBuilder urlBuilder = new URLBuilder();
-
- urlBuilder.setValue("module", "Content");
- urlBuilder.setValue("do", "edit");
- urlBuilder.setValue("id", id);
- urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
-
- if (id!=null) {
- responseData.put("new", Boolean.FALSE);
- article = model.makeEntityAdapter("content", mainModule.getById(id));
- }
- else {
- List fields = DatabaseContent.getInstance().getFields();
- responseData.put("new", Boolean.TRUE);
- article = new HashMap();
- Iterator i = fields.iterator();
- while (i.hasNext()) {
- article.put(i.next(), null);
- }
-
- article.put("to_topics", null);
-
- MirGlobal.localizer().adminInterface().initializeArticle(article);
- }
- responseData.put("article", article);
-
- responseData.put("topics",
- new EntityIteratorAdapter("", configuration.getString("Mir.Localizer.Admin.TopicListOrder"),
- 20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
-
- responseData.put("returnurl", requestParser.getParameter("returnurl"));
- responseData.put("thisurl", urlBuilder.getQuery());
-
- ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void returnArticleList(
- HttpServletRequest aRequest,
- HttpServletResponse aResponse,
- String aWhereClause,
- String anOrderByClause,
- int anOffset,
- String aSelectArticleUrl) throws ServletModuleExc {
-
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- URLBuilder urlBuilder = new URLBuilder();
- EntityAdapterModel model;
- int nrArticlesPerPage = 20;
- int count;
-
- try {
- Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
- model = MirGlobal.localizer().dataModel().adapterModel();
-
- Object articleList =
- new CachingRewindableIterator(
- new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage,
- MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset)
- );
-
- responseData.put("nexturl", null);
- responseData.put("prevurl", null);
-
- count=mainModule.getSize(aWhereClause);
-
- urlBuilder.setValue("module", "Content");
- urlBuilder.setValue("do", "list");
- urlBuilder.setValue("where", aWhereClause);
- urlBuilder.setValue("order", anOrderByClause);
-
-
- urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));
- urlBuilder.setValue("searchvalue", requestParser.getParameter("searchvalue"));
- urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));
- urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));
- urlBuilder.setValue("searcharticletype", requestParser.getParameter("searcharticletype"));
- urlBuilder.setValue("selectarticleurl", aSelectArticleUrl);
-
- responseData.put("searchfield", requestParser.getParameter("searchfield"));
- responseData.put("searchvalue", requestParser.getParameter("searchvalue"));
- responseData.put("searchispublished", requestParser.getParameter("searchispublished"));
- responseData.put("searchorder", requestParser.getParameter("searchorder"));
- responseData.put("searcharticletype", requestParser.getParameter("searcharticletype"));
- responseData.put("selectarticleurl", aSelectArticleUrl);
-
- urlBuilder.setValue("offset", anOffset);
- responseData.put("offset" , new Integer(anOffset).toString());
- responseData.put("thisurl" , urlBuilder.getQuery());
-
- if (count>=anOffset+nrArticlesPerPage) {
- urlBuilder.setValue("offset", (anOffset + nrArticlesPerPage));
- responseData.put("nexturl" , urlBuilder.getQuery());
- }
-
- if (anOffset>0) {
- urlBuilder.setValue("offset", Math.max(anOffset - nrArticlesPerPage, 0));
- responseData.put("prevurl" , urlBuilder.getQuery());
- }
-
- responseData.put("articles", articleList);
-
- responseData.put("from" , Integer.toString(anOffset+1));
- responseData.put("count", Integer.toString(count));
- responseData.put("to", Integer.toString(Math.min(anOffset+nrArticlesPerPage, count)));
- responseData.put("offset" , Integer.toString(anOffset));
- responseData.put("order", anOrderByClause);
- responseData.put("where" , aWhereClause);
-
- ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- URLBuilder urlBuilder = new URLBuilder();
-
- urlBuilder.setValue("module", "Content");
- urlBuilder.setValue("do", "setparent");
- urlBuilder.setValue("childid", requestParser.getParameter("id"));
- urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
-
- returnArticleList(aRequest, aResponse, "", "", 0, urlBuilder.getQuery());
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void listchildren(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- try {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- String articleId = requestParser.getParameter("article_id");
-
- if (articleId == null)
- throw new ServletModuleExc("ServletModuleContent.listchildren: article_id not set!");
-
- returnArticleList(aRequest, aResponse, "to_content = " + articleId, "", 0, null);
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
-
- public void setparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- String articleId = aRequest.getParameter("childid");
- String parentId = aRequest.getParameter("id");
- String returnUrl = aRequest.getParameter("returnurl");
-
- try {
- EntityContent article = (EntityContent) mainModule.getById(articleId);
- article.setValueForProperty("to_content", parentId);
- article.setProduced(false);
- article.update();
- }
- catch(Throwable e) {
- logger.error("ServletModuleContent.setparent: " + e.getMessage());
- throw new ServletModuleFailure(e);
- }
-
- redirect(aResponse, returnUrl);
- }
-
- public void clearparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
- {
- HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- String articleId = requestParser.getParameter("id");
- String returnUrl = requestParser.getParameter("returnurl");
-
- try {
- EntityContent article = (EntityContent) mainModule.getById(articleId);
- article.setValueForProperty("to_content", "");
- article.setProduced(false);
- article.update();
- }
- catch(Throwable e) {
- e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
- logger.error("ServletModuleContent.clearparent: " + e.getMessage());
-
- throw new ServletModuleFailure("ServletModuleContent.clearparent: " + e.getMessage(), e);
- }
-
- redirect(aResponse, returnUrl);
- }
-}
+/*
+ * 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 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.servlet;
+
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.lucene.index.IndexReader;
+
+import freemarker.template.SimpleHash;
+
+
+import mir.entity.adapter.EntityAdapterModel;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.log.LoggerWrapper;
+import mir.misc.StringUtil;
+import mir.servlet.ServletModule;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
+import mir.util.CachingRewindableIterator;
+import mir.util.HTTPRequestParser;
+import mir.util.JDBCStringRoutines;
+import mir.util.SQLQueryBuilder;
+import mir.util.URLBuilder;
+
+import mircoders.global.*;
+import mircoders.entity.EntityContent;
+import mircoders.entity.EntityUsers;
+import mircoders.global.MirGlobal;
+import mircoders.module.ModuleContent;
+import mircoders.search.IndexUtil;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseContentToMedia;
+import mircoders.storage.DatabaseContentToTopics;
+
+/*
+ * ServletModuleContent -
+ * deliver html for the article admin form.
+ *
+ * @version $Id: ServletModuleContent.java,v 1.52.2.4 2003/07/21 07:01:15 zapata Exp $
+ * @author rk, mir-coders
+ *
+ */
+
+public class ServletModuleContent extends ServletModule
+{
+ private String editTemplate = configuration.getString("ServletModule.Content.ObjektTemplate");;
+ private String listTemplate = configuration.getString("ServletModule.Content.ListTemplate");
+
+ private static ServletModuleContent instance = new ServletModuleContent();
+ public static ServletModule getInstance() { return instance; }
+
+ private ServletModuleContent() {
+ super();
+ logger = new LoggerWrapper("ServletModule.Content");
+ try {
+
+ templateListString = configuration.getString("ServletModule.Content.ListTemplate");
+ templateObjektString = configuration.getString("ServletModule.Content.ObjektTemplate");
+ templateConfirmString = configuration.getString("ServletModule.Content.ConfirmTemplate");
+
+ mainModule = new ModuleContent(DatabaseContent.getInstance());
+ }
+ catch (Throwable e) {
+ logger.fatal("ServletModuleContent could not be initialized: " + e.toString());
+ }
+ }
+
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String where = requestParser.getParameter("where");
+ String order = requestParser.getParameterWithDefault("order", "webdb_create desc");
+ int offset = requestParser.getIntegerWithDefault("offset", 0);
+ String selectArticleUrl = requestParser.getParameter("selectarticleurl");
+
+ returnArticleList(aRequest, aResponse, where, order, offset, selectArticleUrl);
+ }
+
+ public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleFailure {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ SQLQueryBuilder queryBuilder = new SQLQueryBuilder();
+ String searchField = requestParser.getParameterWithDefault("searchfield", "");
+ String searchValue = requestParser.getParameterWithDefault("searchvalue", "").trim();
+ String searchOrder = requestParser.getParameterWithDefault("searchorder", "");
+ String searchispublished = requestParser.getParameterWithDefault("searchispublished", "");
+ String searchArticleType = requestParser.getParameterWithDefault("searcharticletype", "");
+ String selectArticleUrl = requestParser.getParameter("selectarticleurl");
+
+ if (searchValue.length()>0) {
+ if (searchField.equals("id"))
+ queryBuilder.appendAndCondition(
+ "id='"+JDBCStringRoutines.escapeStringLiteral(searchValue)+"'");
+ else if (searchField.equals("contents"))
+ queryBuilder.appendAndCondition(
+ "(lower(content_data) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')"+
+ " or (lower(description) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')");
+ else
+ queryBuilder.appendAndCondition(
+ "lower("+ searchField + ") like " +
+ "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%'");
+ }
+
+ if (searchispublished.length()>0) {
+ if (searchispublished.equals("0"))
+ queryBuilder.appendAndCondition("is_published='f'");
+ else
+ queryBuilder.appendAndCondition("is_published='t'");
+ }
+
+ if (searchArticleType.length()>0) {
+ queryBuilder.appendAndCondition("to_article_type="+Integer.parseInt(searchArticleType));
+ }
+
+ 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("title"))
+ queryBuilder.appendDescendingOrder("title");
+ else if (searchOrder.equals("creator"))
+ queryBuilder.appendDescendingOrder("creator");
+ }
+
+ returnArticleList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0, selectArticleUrl);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ _showObject(null, aRequest, aResponse);
+ }
+
+
+ public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+//theLog.printDebugInfo(":: content :: trying to insert");
+ try {
+ Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
+
+ String now = StringUtil.date2webdbDate(new GregorianCalendar());
+ withValues.put("date", now);
+ withValues.put("publish_path", StringUtil.webdbDate2path(now));
+ withValues.put("to_publisher", ServletHelper.getUser(aRequest).getId());
+ withValues.put("is_produced", "0");
+ if (!withValues.containsKey("is_published"))
+ withValues.put("is_published","0");
+ if (!withValues.containsKey("is_html"))
+ withValues.put("is_html","0");
+
+ String webdbCreate = (String) withValues.get("webdb_create");
+ if (webdbCreate==null || webdbCreate.trim().length()==0)
+ withValues.remove("webdb_create");
+
+ String id = mainModule.add(withValues);
+ List topics;
+
+ DatabaseContentToTopics.getInstance().setTopics(id, aRequest.getParameterValues("to_topic"));
+
+ _showObject(id, aRequest, aResponse);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleFailure
+ {
+ try {
+ MirGlobal.accessControl().general().assertMayDeleteArticles(ServletHelper.getUser(aRequest));
+
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Invalid call: id missing");
+
+ String confirmParam = aRequest.getParameter("confirm");
+ String cancelParam = aRequest.getParameter("cancel");
+
+ logger.info("where = " + aRequest.getParameter("where"));
+
+ if (confirmParam == null && cancelParam == null) {
+
+ SimpleHash mergeData = new SimpleHash();
+ mergeData.put("module", "Content");
+ mergeData.put("infoString", "Content: " + idParam);
+ mergeData.put("id", idParam);
+ mergeData.put("where", aRequest.getParameter("where"));
+ mergeData.put("order", aRequest.getParameter("order"));
+ mergeData.put("offset", aRequest.getParameter("offset"));
+ deliver(aRequest, aResponse, mergeData, templateConfirmString);
+ }
+ else {
+ if (confirmParam != null && !confirmParam.equals("")) {
+ try {
+ mainModule.deleteById(idParam);
+
+ /** @todo the following two should be implied in
+ * DatabaseContent */
+ DatabaseContentToTopics.getInstance().deleteByContentId(idParam);
+ DatabaseComment.getInstance().deleteByContentId(idParam);
+ DatabaseContentToMedia.getInstance().deleteByContentId(idParam);
+
+ //delete from lucene index, if any
+ String index = configuration.getString("IndexPath");
+ if (IndexReader.indexExists(index)) {
+ IndexUtil.unindexID(idParam, index);
+ }
+
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ list(aRequest, aResponse);
+ }
+ else {
+ // Datensatz anzeigen
+ _showObject(idParam, aRequest, aResponse);
+ }
+ }
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
+ }
+
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Invalid call: id not supplied ");
+ _showObject(idParam, aRequest, aResponse);
+ }
+
+// methods for attaching media file
+ public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String mediaIdParam = aRequest.getParameter("mid");
+ String articleId = aRequest.getParameter("articleid");
+
+ if (articleId == null || mediaIdParam==null)
+ throw new ServletModuleExc("smod content :: attach :: articleid/mid missing");
+
+ try {
+ EntityContent entContent = (EntityContent) mainModule.getById(articleId);
+ entContent.attach(mediaIdParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ _showObject(articleId, aRequest, aResponse);
+ }
+
+ public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String articleId = aRequest.getParameter("articleid");
+ String midParam = aRequest.getParameter("mid");
+ if (articleId == null)
+ throw new ServletModuleExc("smod content :: dettach :: articleid missing");
+ if (midParam == null)
+ throw new ServletModuleExc("smod content :: dettach :: mid missing");
+
+ try {
+ EntityContent entContent = (EntityContent)mainModule.getById(articleId);
+ entContent.dettach(articleId, midParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ _showObject(articleId, aRequest, aResponse);
+ }
+
+ public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String returnUrl = requestParser.getParameter("returnurl");
+
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Wrong call: (id) is missing");
+
+ Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
+
+ String content_id = aRequest.getParameter("id");
+
+ withValues.put("is_produced", "0");
+ if (!withValues.containsKey("is_published"))
+ withValues.put("is_published","0");
+ if (!withValues.containsKey("is_html"))
+ withValues.put("is_html","0");
+
+ String webdbCreate = (String) withValues.get("webdb_create");
+ if (webdbCreate==null || webdbCreate.trim().length()==0)
+ withValues.remove("webdb_create");
+
+ String id = mainModule.set(withValues);
+ DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"), aRequest.getParameterValues("to_topic"));
+
+ String whereParam = aRequest.getParameter("where");
+ String orderParam = aRequest.getParameter("order");
+
+ if (returnUrl!=null){
+ redirect(aResponse, returnUrl);
+ }
+ else
+ _showObject(idParam, aRequest, aResponse);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+
+ /**
+ * HelperMethod shows the basic article editing form.
+ *
+ * if the "id" parameter is null, it means show an empty form to add a new
+ * article.
+ *
+ * @param id
+ * @param aRequest
+ * @param aResponse
+ * @throws ServletModuleExc
+ */
+ public void _showObject(String id, HttpServletRequest aRequest, HttpServletResponse aResponse)
+ throws ServletModuleExc {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
+ Map article;
+ URLBuilder urlBuilder = new URLBuilder();
+
+ urlBuilder.setValue("module", "Content");
+ urlBuilder.setValue("do", "edit");
+ urlBuilder.setValue("id", id);
+ urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
+
+ if (id!=null) {
+ responseData.put("new", Boolean.FALSE);
+ article = model.makeEntityAdapter("content", mainModule.getById(id));
+ }
+ else {
+ List fields = DatabaseContent.getInstance().getFields();
+ responseData.put("new", Boolean.TRUE);
+ article = new HashMap();
+ Iterator i = fields.iterator();
+ while (i.hasNext()) {
+ article.put(i.next(), null);
+ }
+
+ article.put("to_topics", null);
+
+ MirGlobal.localizer().adminInterface().initializeArticle(article);
+ }
+ responseData.put("article", article);
+
+ responseData.put("topics",
+ new EntityIteratorAdapter("", configuration.getString("Mir.Localizer.Admin.TopicListOrder"),
+ 20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
+
+ responseData.put("returnurl", requestParser.getParameter("returnurl"));
+ responseData.put("thisurl", urlBuilder.getQuery());
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void returnArticleList(
+ HttpServletRequest aRequest,
+ HttpServletResponse aResponse,
+ String aWhereClause,
+ String anOrderByClause,
+ int anOffset,
+ String aSelectArticleUrl) throws ServletModuleExc {
+
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ URLBuilder urlBuilder = new URLBuilder();
+ EntityAdapterModel model;
+ int nrArticlesPerPage = 20;
+ int count;
+
+ try {
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ model = MirGlobal.localizer().dataModel().adapterModel();
+
+ Object articleList =
+ new CachingRewindableIterator(
+ new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage,
+ MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset)
+ );
+
+ responseData.put("nexturl", null);
+ responseData.put("prevurl", null);
+
+ count=mainModule.getSize(aWhereClause);
+
+ urlBuilder.setValue("module", "Content");
+ urlBuilder.setValue("do", "list");
+ urlBuilder.setValue("where", aWhereClause);
+ urlBuilder.setValue("order", anOrderByClause);
+
+
+ urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));
+ urlBuilder.setValue("searchvalue", requestParser.getParameter("searchvalue"));
+ urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));
+ urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));
+ urlBuilder.setValue("searcharticletype", requestParser.getParameter("searcharticletype"));
+ urlBuilder.setValue("selectarticleurl", aSelectArticleUrl);
+
+ responseData.put("searchfield", requestParser.getParameter("searchfield"));
+ responseData.put("searchvalue", requestParser.getParameter("searchvalue"));
+ responseData.put("searchispublished", requestParser.getParameter("searchispublished"));
+ responseData.put("searchorder", requestParser.getParameter("searchorder"));
+ responseData.put("searcharticletype", requestParser.getParameter("searcharticletype"));
+ responseData.put("selectarticleurl", aSelectArticleUrl);
+
+ urlBuilder.setValue("offset", anOffset);
+ responseData.put("offset" , new Integer(anOffset).toString());
+ responseData.put("thisurl" , urlBuilder.getQuery());
+
+ if (count>=anOffset+nrArticlesPerPage) {
+ urlBuilder.setValue("offset", (anOffset + nrArticlesPerPage));
+ responseData.put("nexturl" , urlBuilder.getQuery());
+ }
+
+ if (anOffset>0) {
+ urlBuilder.setValue("offset", Math.max(anOffset - nrArticlesPerPage, 0));
+ responseData.put("prevurl" , urlBuilder.getQuery());
+ }
+
+ responseData.put("articles", articleList);
+
+ responseData.put("from" , Integer.toString(anOffset+1));
+ responseData.put("count", Integer.toString(count));
+ responseData.put("to", Integer.toString(Math.min(anOffset+nrArticlesPerPage, count)));
+ responseData.put("offset" , Integer.toString(anOffset));
+ responseData.put("order", anOrderByClause);
+ responseData.put("where" , aWhereClause);
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ URLBuilder urlBuilder = new URLBuilder();
+
+ urlBuilder.setValue("module", "Content");
+ urlBuilder.setValue("do", "setparent");
+ urlBuilder.setValue("childid", requestParser.getParameter("id"));
+ urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
+
+ returnArticleList(aRequest, aResponse, "", "", 0, urlBuilder.getQuery());
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void listchildren(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ String articleId = requestParser.getParameter("article_id");
+
+ if (articleId == null)
+ throw new ServletModuleExc("ServletModuleContent.listchildren: article_id not set!");
+
+ returnArticleList(aRequest, aResponse, "to_content = " + articleId, "", 0, null);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void setparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ String articleId = aRequest.getParameter("childid");
+ String parentId = aRequest.getParameter("id");
+ String returnUrl = aRequest.getParameter("returnurl");
+
+ try {
+ EntityContent article = (EntityContent) mainModule.getById(articleId);
+ article.setValueForProperty("to_content", parentId);
+ article.setProduced(false);
+ article.update();
+ }
+ catch(Throwable e) {
+ logger.error("ServletModuleContent.setparent: " + e.getMessage());
+ throw new ServletModuleFailure(e);
+ }
+
+ redirect(aResponse, returnUrl);
+ }
+
+ public void clearparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ String articleId = requestParser.getParameter("id");
+ String returnUrl = requestParser.getParameter("returnurl");
+
+ try {
+ EntityContent article = (EntityContent) mainModule.getById(articleId);
+ article.setValueForProperty("to_content", "");
+ article.setProduced(false);
+ article.update();
+ }
+ catch(Throwable e) {
+ e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
+ logger.error("ServletModuleContent.clearparent: " + e.getMessage());
+
+ throw new ServletModuleFailure("ServletModuleContent.clearparent: " + e.getMessage(), e);
+ }
+
+ redirect(aResponse, returnUrl);
+ }
+}
diff --git a/source/mircoders/servlet/ServletModuleHidden.java b/source/mircoders/servlet/ServletModuleHidden.java
index f1d80021..b5635711 100755
--- a/source/mircoders/servlet/ServletModuleHidden.java
+++ b/source/mircoders/servlet/ServletModuleHidden.java
@@ -18,30 +18,33 @@
* 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.servlet;
+import java.util.*;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mir.entity.EntityList;
+import mir.entity.adapter.*;
import mir.log.LoggerWrapper;
import mir.misc.HTMLTemplateProcessor;
-import mir.servlet.ServletModule;
-import mir.servlet.ServletModuleExc;
+import mir.util.*;
+import mir.servlet.*;
import mir.servlet.ServletModuleFailure;
import mir.storage.StorageObjectFailure;
import mircoders.module.ModuleContent;
import mircoders.storage.DatabaseContent;
-import freemarker.template.SimpleHash;
+import mircoders.global.*;
/*
* ServletModuleHidden - output of so called "censored" articles
@@ -52,15 +55,15 @@ import freemarker.template.SimpleHash;
public class ServletModuleHidden extends ServletModule
{
-
-// Singelton / Kontruktor
private static ServletModuleHidden instance = new ServletModuleHidden();
public static ServletModule getInstance() { return instance; }
private ServletModuleHidden() {
super();
+
logger = new LoggerWrapper("ServletModule.Hidden");
templateListString = configuration.getString("ServletModule.Hidden.ListTemplate");
+
try {
mainModule = new ModuleContent(DatabaseContent.getInstance());
}
@@ -73,47 +76,29 @@ public class ServletModuleHidden extends ServletModule
public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
{
// determine parameter
- SimpleHash mergeData = new SimpleHash();
- String query_year = req.getParameter("year");
- String query_month = req.getParameter("month");
- String order = "webdb_create";
+ HTTPRequestParser requestParser = new HTTPRequestParser(req);
+ Map responseData = ServletHelper.makeGenerationData(req, res, new Locale[] { getLocale(req), getFallbackLocale(req)});
-// form sql statement
- String whereClause = "is_published=false AND webdb_create LIKE '"+
- query_year+"-"+query_month+"%'";
+ String query_year = requestParser.getParameter("year");
+ String query_month = requestParser.getParameter("month");
- logger.debug("ServletModuleHidden.list: whereclause: " + whereClause);
-
-// fetch and deliver
try {
+ if ((query_year!=null && !query_year.equals("")) && (query_month!=null && !query_month.equals(""))) {
+ String whereClause = "is_published=false AND webdb_create LIKE "+
+ "'"+JDBCStringRoutines.escapeStringLiteral(query_year)+"-"+JDBCStringRoutines.escapeStringLiteral(query_month)+"%'";
- if ((query_year!=null && !query_year.equals(""))
- && (query_month!=null && !query_month.equals(""))) {
- EntityList theList = mainModule.getByWhereClause(whereClause, order, -1);
- if (theList!=null && theList.size()>0) {
-
-//make articleHash for comment
- StringBuffer buf= new StringBuffer("id in (");boolean first=true;
- for(int i=0;i
-
-
${lang("month")}
${lang("year")}
@@ -66,7 +64,7 @@
-
+
-
+
${i.title}
${lang("content.creator")}: ${i.creator}
${lang("message.date")}: ${i.webdb_create_formatted}
- additional media, type: audio
- additional media, type: video
- additional media, type: other
- additional media, type: image
+ additional media, type: audio
+ additional media, type: video
+ additional media, type: other
+ additional media, type: image
diff --git a/templates/admin/start_admin.template b/templates/admin/start_admin.template
index cd18f182..ebb1174c 100755
--- a/templates/admin/start_admin.template
+++ b/templates/admin/start_admin.template
@@ -20,7 +20,7 @@
- ${lang("start.list.title")}
+ ${lang("start.articles.title")}
> ${lang("start.allarticlesoftype", lang("articletypes."+a.name))}
@@ -33,6 +33,13 @@
> ${lang("start.content.all")}
+ ${lang("start.comments.title")}
+
+
+ > ${lang("start.allcommentswithstatus", lang("commentstatus."+a.name))}
+
+
+
${lang("start.extra.title")}
--
2.11.0