From bf44de40552d78f2646543c3b6534dd3649a1852 Mon Sep 17 00:00:00 2001 From: zapata Date: Sat, 14 Dec 2002 22:38:52 +0000 Subject: [PATCH] 2 flavors for displaying customizable operations in comment/article lists added: with checkboxes and with drop-down lists --- bundles/admin_de.properties | 3 +- bundles/admin_en.properties | 3 +- bundles/admin_es.properties | 4 +- etc/config.properties-dist | 5 + .../basic/MirBasicDataModelLocalizer.java | 1 + .../mircoders/servlet/ServletModuleLocalizer.java | 326 ++++++++++++--------- templates/admin/commentlist.template | 175 ++++++----- templates/admin/contentlist.template | 142 +++++---- 8 files changed, 389 insertions(+), 270 deletions(-) diff --git a/bundles/admin_de.properties b/bundles/admin_de.properties index d8ab36f1..4ea50bec 100755 --- a/bundles/admin_de.properties +++ b/bundles/admin_de.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: deutsch / german -# $Id: admin_de.properties,v 1.21 2002/12/14 15:55:23 zapata Exp $ +# $Id: admin_de.properties,v 1.22 2002/12/14 22:39:07 zapata Exp $ # general yes=ja @@ -148,6 +148,7 @@ content.published=publiziert content.comments=Ergänzungen contentlist.htmltitle=contentlist +contentlist.comments=Kommentaren # language language.htmltitle=languages diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index ecf1b36d..ce25e2c8 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: english -# $Id: admin_en.properties,v 1.29 2002/12/14 15:55:23 zapata Exp $ +# $Id: admin_en.properties,v 1.30 2002/12/14 22:39:07 zapata Exp $ # general yes=yes @@ -153,6 +153,7 @@ content.comments=Comments contentlist.htmltitle=Articles +contentlist.comments=comments # language language.htmltitle=Language diff --git a/bundles/admin_es.properties b/bundles/admin_es.properties index 4176ace9..4772001c 100755 --- a/bundles/admin_es.properties +++ b/bundles/admin_es.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: espanol / spanish -# $Id: admin_es.properties,v 1.13 2002/12/14 15:55:23 zapata Exp $ +# $Id: admin_es.properties,v 1.14 2002/12/14 22:39:07 zapata Exp $ # general yes=sí @@ -142,6 +142,8 @@ content.published=publicado content.comments=Comentarios contentlist.htmltitle=lista de contenidos +contentlist.comments=comentarios + # language language.htmltitle=idiomas diff --git a/etc/config.properties-dist b/etc/config.properties-dist index df4cbd10..bc79d062 100755 --- a/etc/config.properties-dist +++ b/etc/config.properties-dist @@ -67,6 +67,11 @@ Mir.Localizer.Producer.GeneratorLibrary= default=freemarker(etc/producer/) Mir.Localizer.Admin.GeneratorLibrary= default=freemarker(templates/admin/) Mir.Localizer.OpenPosting.GeneratorLibrary= default=freemarker(etc/open/) +# How should the custom operations (hide etc) in article and comment lists +# be presented? +# 0 = links, 1 = checkboxes, 2 = a listbox +Mir.Localizer.Admin.ListOperationsFlavor=1 + # Which producers need to be called after an article (resp. a comment) is posted Mir.Localizer.OpenPosting.ContentProducers= media.new;articles.changed;startpage.generate;synchronization.run Mir.Localizer.OpenPosting.CommentProducers= articles.changed;synchronization.run diff --git a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java index ad90902a..ac79c549 100755 --- a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java @@ -65,6 +65,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer { anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField()); anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'")); + anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField("")); anEntityAdapterDefinition.addCalculatedField("to_media_images", new ContentToMediaField( "image" )); anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new ContentToMediaField( "uploadedMedia" )); diff --git a/source/mircoders/servlet/ServletModuleLocalizer.java b/source/mircoders/servlet/ServletModuleLocalizer.java index c1b7d697..e316a148 100755 --- a/source/mircoders/servlet/ServletModuleLocalizer.java +++ b/source/mircoders/servlet/ServletModuleLocalizer.java @@ -1,146 +1,182 @@ -/* - * 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 mircoders.servlet; - -import java.util.*; - -import javax.servlet.*; -import javax.servlet.http.*; - -import mir.servlet.*; -import mir.entity.adapter.*; -import mir.log.*; - -import mircoders.global.*; -import mircoders.localizer.*; -import mircoders.storage.*; -import mircoders.entity.*; -import mircoders.module.*; - -public class ServletModuleLocalizer extends ServletModule { - private static ServletModuleLocalizer instance = new ServletModuleLocalizer(); - public static ServletModule getInstance() { return instance; } - - private ModuleContent contentModule; - private ModuleComment commentModule; - - private ServletModuleLocalizer() { - try { - contentModule = new ModuleContent(DatabaseContent.getInstance()); - commentModule = new ModuleComment(DatabaseComment.getInstance()); - - logger = new LoggerWrapper("ServletModule.Localizer"); - } - catch (Exception e) { - logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage()); - } - } - - public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { - String idString = aRequest.getParameter("id"); - String operationString = aRequest.getParameter("operation"); - String returnUrlString = aRequest.getParameter("returnurl"); - - MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; - EntityAdapter comment; - EntityComment entity; - - try { - entity = (EntityComment) commentModule.getById(idString); - - if (entity!=null) { - comment = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("comment", entity); - operation = MirGlobal.localizer().adminInterface().simpleCommentOperationForName(operationString); - operation.perform(comment); - } - - redirect(aResponse, returnUrlString); - } - catch (Throwable e) { - e.printStackTrace(System.out); - throw new ServletModuleException(e.getMessage()); - } - } - - public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { - String articleIdString = aRequest.getParameter("articleid"); - String operationString = aRequest.getParameter("operation"); - String returnUrlString = aRequest.getParameter("returnurl"); - - MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; - EntityAdapter article; - EntityContent entity; - - try { - entity = (EntityContent) contentModule.getById(articleIdString); - - if (entity!=null) { - article = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", entity); - operation = MirGlobal.localizer().adminInterface().simpleArticleOperationForName(operationString); - operation.perform(article); - } - - redirect(aResponse, returnUrlString); - } - catch (Throwable e) { - e.printStackTrace(System.out); - throw new ServletModuleException(e.getMessage()); - } - } - - public void batchedarticleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { - String articleIdString = aRequest.getParameter("articleid"); - String operationString = aRequest.getParameter("operation"); - String returnUrlString = aRequest.getParameter("returnurl"); - - MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; - EntityAdapter article; - EntityContent entity; - - try { - entity = (EntityContent) contentModule.getById(articleIdString); - - if (entity!=null) { - article = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", entity); - operation = MirGlobal.localizer().adminInterface().simpleArticleOperationForName(operationString); - operation.perform(article); - } - - redirect(aResponse, returnUrlString); - } - catch (Throwable e) { - e.printStackTrace(System.out); - throw new ServletModuleException(e.getMessage()); - } - } - +/* + * 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 mircoders.servlet; + +import java.util.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import mir.servlet.*; +import mir.entity.adapter.*; +import mir.log.*; +import mir.util.*; + +import mircoders.global.*; +import mircoders.localizer.*; +import mircoders.storage.*; +import mircoders.entity.*; +import mircoders.module.*; + +public class ServletModuleLocalizer extends ServletModule { + private static ServletModuleLocalizer instance = new ServletModuleLocalizer(); + public static ServletModule getInstance() { return instance; } + + private ModuleContent contentModule; + private ModuleComment commentModule; + + private ServletModuleLocalizer() { + try { + contentModule = new ModuleContent(DatabaseContent.getInstance()); + commentModule = new ModuleComment(DatabaseComment.getInstance()); + + logger = new LoggerWrapper("ServletModule.Localizer"); + } + catch (Exception e) { + logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage()); + } + } + + public void performCommentOperation(String anId, String anOperation) { + MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; + EntityAdapter comment; + EntityComment entity; + + try { + entity = (EntityComment) commentModule.getById(anId); + + if (entity != null) { + comment = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("comment", entity); + operation = MirGlobal.localizer().adminInterface().simpleCommentOperationForName(anOperation); + operation.perform(comment); + logger.info("Operation " + anOperation + " successfully performed on comment " + anId); + } + logger.error("Error while performing " + anOperation + " on comment " + anId + ": comment is null"); + } + catch (Throwable e) { + logger.error("Error while performing " + anOperation + " on comment " + anId + ": " + e.getMessage()); + } + } + + public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + String commentIdString = aRequest.getParameter("id"); + String operationString = aRequest.getParameter("operation"); + String returnUrlString = aRequest.getParameter("returnurl"); + + performCommentOperation(commentIdString, operationString); + + redirect(aResponse, returnUrlString); + } + + public void commentoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + String returnUrlString = aRequest.getParameter("returnurl"); + + String[] operations = aRequest.getParameterValues("operation"); + + for (int i=0; i0) { + List parts = StringRoutines.splitString(operations[i], ";"); + + if (parts.size() != 2) { + logger.error("commentoperationbatch: operation string invalid: " + + operations[i]); + } + else { + String commentIdString = (String) parts.get(0); + String operationString = (String) parts.get(1); + + performCommentOperation(commentIdString, operationString); + } + } + } + + redirect(aResponse, returnUrlString); + } + + public void performArticleOperation(String anId, String anOperation) { + MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; + EntityAdapter article; + EntityContent entity; + + try { + entity = (EntityContent) contentModule.getById(anId); + + if (entity != null) { + article = MirGlobal.localizer().dataModel().adapterModel(). + makeEntityAdapter("content", entity); + operation = MirGlobal.localizer().adminInterface(). + simpleArticleOperationForName(anOperation); + operation.perform(article); + logger.info("Operation " + anOperation + " successfully performed on article " + anId); + } + logger.error("Error while performing " + anOperation + " on article " + anId + ": article is null"); + } + catch (Throwable e) { + logger.error("Error while performing " + anOperation + " on article " + anId + ": " + e.getMessage()); + } + } + + public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + String articleIdString = aRequest.getParameter("articleid"); + String operationString = aRequest.getParameter("operation"); + String returnUrlString = aRequest.getParameter("returnurl"); + + performArticleOperation(articleIdString, operationString); + redirect(aResponse, returnUrlString); + } + + public void articleoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + String returnUrlString = aRequest.getParameter("returnurl"); + + String[] operations = aRequest.getParameterValues("operation"); + + for (int i=0; i0) { + List parts = StringRoutines.splitString(operations[i], ";"); + + if (parts.size() != 2) { + logger.error("articleoperationbatch: operation string invalid: " + + operations[i]); + } + else { + String articleIdString = (String) parts.get(0); + String operationString = (String) parts.get(1); + + performArticleOperation(articleIdString, operationString); + } + } + } + + redirect(aResponse, returnUrlString); + } + } \ No newline at end of file diff --git a/templates/admin/commentlist.template b/templates/admin/commentlist.template index cd1f62d9..8238f088 100755 --- a/templates/admin/commentlist.template +++ b/templates/admin/commentlist.template @@ -61,80 +61,115 @@ - - - - - - - - - - - class="list1"class="list2"> - - + + +
+ + + + +

+ +

+
+ +
- - ${lang("list.previous")}  - - - ${lang("list.next")}  - -

${lang("comment.date")}

${lang("comment.title")}/ ${lang("comment.creator")}
- ${lang("comment.text")}

${entry.creationdate.formatted["dd.mm.yyyy"]}
- hidden- -
+ + + + + + + - class="list1"class="list2"> + + + + + + - - - - - + + + + + + + + + +
+ + ${lang("list.previous")}  + + + ${lang("list.next")}  + +

${lang("comment.date")}

${lang("comment.title")}/ ${lang("comment.creator")}
+ ${lang("comment.text")}

- - ${lang("comment.article")} - - ${utility.encodeHTML(entry.to_content.title)} - -
- - - ${lang("commentstatus." + entry.status.name)} - + +
${entry.creationdate.formatted["dd.mm.yyyy"]}
+ hidden- +
+ + ${lang("comment.article")} + + ${utility.encodeHTML(entry.to_content.title)} + +
+ + + ${lang("commentstatus." + entry.status.name)} - + + ${entry.title}
+ + ${lang("comment.creator")}: ${entry.creator}
+ ${entry.description} +
URL: ${entry.main_url}
+
+ + + [${op}] + + + + + [${op}] + + + + + + | + ${lang("edit")} +
+
+   + ${lang("delete")} - ${entry.title}
- - ${lang("comment.creator")}: ${entry.creator}
- ${entry.description} -
URL: ${entry.main_url}
-
${lang("edit")} - | - - - [${op}] - - -
-   - ${lang("delete")} - -
${count} ${lang("records")} / ${lang("show_from_to", from, to)}
+ + ${lang("list.previous")}  + + + ${lang("list.next")}  + +
+ + +

+ +

+ +
- - ${count} ${lang("records")} / ${lang("show_from_to", from, to)} - - - - ${lang("list.previous")}  - - - ${lang("list.next")}  - - - - ${lang("no_matches_found")} - - + +

${lang("no_matches_found")}

+ diff --git a/templates/admin/contentlist.template b/templates/admin/contentlist.template index acc7d0f9..dc732217 100755 --- a/templates/admin/contentlist.template +++ b/templates/admin/contentlist.template @@ -8,60 +8,98 @@ - - - - - - - - - - class="list1"class="list2"> - - - - - - - - -
- ${lang("content.creationdate")}
- ${lang("content.modificationdate")}
- ${lang("content.status")}
- ${lang("content.type")} - ${lang("content.title")}
- ${lang("content.creator")}
- ${lang("content.comment")} 
- - ${entry.creationdate.formatted["dd.MM.yyyy hh:mm"]}
- ${entry.changedate.formatted["dd.MM.yyyy hh:mm"]}
- F-H- -
-
- - - - ${lang("articletypes." + entry.article_type.name)} - - - ${entry.title} -
- ${entry.creator}  - ${lang("edit")} - | - - [${op}] - -
-
class="list3"class="list4" valign="top"> + +
+ + + - ${entry.comment} 
- - ${lang("delete")} - -
${count} ${lang("records")} - / ${lang("show_from_to", from, to)}
+

+ +

+
+ + + + + + + + + + + + class="list1"class="list2"> + + + + + + + + +
+ ${lang("content.creationdate")}
+ ${lang("content.modificationdate")}
+ ${lang("content.status")}
+ ${lang("content.type")} - ${lang("content.title")}
+ ${lang("content.creator")}
+ ${lang("content.comment")} 
+ + ${entry.creationdate.formatted["dd.MM.yyyy hh:mm"]}
+ ${entry.changedate.formatted["dd.MM.yyyy hh:mm"]}
+ F-H- +
+
+ + + + ${lang("articletypes." + entry.article_type.name)} - + + ${entry.title} +
+ ${entry.creator}
+ + + + [${op}] + + + + + [${op}] + + + + + + + | + + ${lang("edit")} + ${lang("contentlist.comments")} +
+
class="list3"class="list4" valign="top"> + + ${entry.comment}  + + ${lang("delete")} + +
${count} ${lang("records")} + / ${lang("show_from_to", from, to)}
+ +

+ +

+ + +

-- 2.11.0