From 0c4d79188ad0df9f35a0fb1131821d01af1418a7 Mon Sep 17 00:00:00 2001 From: zapata Date: Sun, 1 Dec 2002 22:12:25 +0000 Subject: [PATCH] maintenance + localized operations introduced for comments --- bundles/admin_ay.properties | 11 +- bundles/admin_de.properties | 11 +- bundles/admin_en.properties | 12 +- bundles/admin_es.properties | 11 +- bundles/admin_gn.properties | 9 +- bundles/admin_qu.properties | 9 +- bundles/admin_tr.properties | Bin 26694 -> 27290 bytes source/mir/entity/EntityList.java | 290 +++++----- source/mir/util/HTTPRequestParser.java | 39 ++ source/mir/util/URLBuilder.java | 53 ++ source/mircoders/entity/EntityComment.java | 45 +- source/mircoders/servlet/ServletModuleComment.java | 254 ++++----- source/mircoders/servlet/ServletModuleContent.java | 7 +- .../mircoders/servlet/ServletModuleLocalizer.java | 35 +- templates/admin/comment.template | 11 +- templates/admin/commentlist.template | 198 ++++--- templates/admin/content.template | 586 ++++++++++----------- web/style/admin.css | 10 +- 18 files changed, 853 insertions(+), 738 deletions(-) create mode 100755 source/mir/util/HTTPRequestParser.java create mode 100755 source/mir/util/URLBuilder.java diff --git a/bundles/admin_ay.properties b/bundles/admin_ay.properties index 3939b6f4..865cd034 100755 --- a/bundles/admin_ay.properties +++ b/bundles/admin_ay.properties @@ -86,9 +86,14 @@ comment.creator=autor comment.article=del artículo commentlist.htmltitle=lista de comentarios -commentlist.produced=producido +commentlist.published=publicado commentlist.hidden=oculto -commentlist.search=buscar! +commentlist.search=buscar! + +commentlist.order.datedesc= date (desc.) # needs translation +commentlist.order.dateasc= date (asc.) # needs translation +commentlist.order.articletitle= article title # needs translation + # confirm confirm.htmltitle=confirmar borrado @@ -126,6 +131,8 @@ content.creationdate=fecha content.modificationdate=último cambio content.status=Estado content.type=Tipo de artículo +content.published=publicado +content.comments=Comentarios contentlist.htmltitle=lista de contenidos diff --git a/bundles/admin_de.properties b/bundles/admin_de.properties index 3a889dad..26974afb 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.17 2002/11/30 20:21:00 zapata Exp $ +# $Id: admin_de.properties,v 1.18 2002/12/01 22:12:25 zapata Exp $ # general yes=ja @@ -93,10 +93,15 @@ comment.creator=Uhrheber comment.article=zu artikel commentlist.htmltitle=commentlist -commentlist.produced=produziert +commentlist.published=publiziert commentlist.hidden=versteckt commentlist.search=go! +commentlist.order.datedesc= date (desc.) # needs translation +commentlist.order.dateasc= date (asc.) # needs translation +commentlist.order.articletitle= article title # needs translation + + # confirm confirm.htmltitle=confirm delete confirm.really_delete=Datensatz wirklich löschen? @@ -136,6 +141,8 @@ content.type=articletype content.import_date=Importiert content.lastchange_date=zuletzt geäendert content.create_date=Datum +content.published=publiziert +content.comments=Ergänzungen contentlist.htmltitle=contentlist diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index 89f0bf89..6861e7ba 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: english -# $Id: admin_en.properties,v 1.25 2002/11/30 20:21:00 zapata Exp $ +# $Id: admin_en.properties,v 1.26 2002/12/01 22:12:25 zapata Exp $ # general yes=yes @@ -97,10 +97,15 @@ comment.creator=author comment.article=for article commentlist.htmltitle=Comments -commentlist.produced=produced +commentlist.published=published commentlist.hidden=hidden commentlist.search=go! +commentlist.order.datedesc= date (desc.) +commentlist.order.dateasc= date (asc.) +commentlist.order.articletitle= article title + + # confirm confirm.htmltitle=confirm delete confirm.really_delete=Do you really want to delete this entry? @@ -140,6 +145,9 @@ content.type=Article type content.import_date=Import date content.lastchange_date=Last modified content.create_date=Date +content.published=published +content.comments=Comments + contentlist.htmltitle=Articles diff --git a/bundles/admin_es.properties b/bundles/admin_es.properties index f9345955..6da56674 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.9 2002/11/30 20:21:00 zapata Exp $ +# $Id: admin_es.properties,v 1.10 2002/12/01 22:12:25 zapata Exp $ # general yes=sí @@ -90,10 +90,15 @@ comment.creator=autor comment.article=del artículo commentlist.htmltitle=lista de comentarios -commentlist.produced=producido +commentlist.published=publicado commentlist.hidden=oculto commentlist.search=buscar! +commentlist.order.datedesc= date (desc.) # needs translation +commentlist.order.dateasc= date (asc.) # needs translation +commentlist.order.articletitle= article title # needs translation + + # confirm confirm.htmltitle=confirmar borrado confirm.really_delete=Desea borrar esta entrada? @@ -130,6 +135,8 @@ content.creationdate=fecha content.modificationdate=último cambio content.status=Estado content.type=Tipo de artículo +content.published=publicado +content.comments=Comentarios contentlist.htmltitle=lista de contenidos diff --git a/bundles/admin_gn.properties b/bundles/admin_gn.properties index 00a213ce..8364f90c 100755 --- a/bundles/admin_gn.properties +++ b/bundles/admin_gn.properties @@ -87,10 +87,15 @@ comment.creator=autor comment.article=del artículo commentlist.htmltitle=lista de comentarios -commentlist.produced=producido +commentlist.published=publicado commentlist.hidden=oculto commentlist.search=buscar! +commentlist.order.datedesc= date (desc.) # needs translation +commentlist.order.dateasc= date (asc.) # needs translation +commentlist.order.articletitle= article title # needs translation + + # confirm confirm.htmltitle=confirmar borrado confirm.really_delete=Desea borrar esta entrada? @@ -127,6 +132,8 @@ content.creationdate=fecha content.modificationdate=último cambio content.status=Estado content.type=Tipo de artículo +content.published=publicado +content.comments=Comentarios contentlist.htmltitle=lista de contenidos diff --git a/bundles/admin_qu.properties b/bundles/admin_qu.properties index 496f8b8b..0be383cd 100755 --- a/bundles/admin_qu.properties +++ b/bundles/admin_qu.properties @@ -87,10 +87,15 @@ comment.creator=autor comment.article=del artículo commentlist.htmltitle=lista de comentarios -commentlist.produced=producido +commentlist.published=publicado commentlist.hidden=oculto commentlist.search=buscar! +commentlist.order.datedesc= date (desc.) # needs translation +commentlist.order.dateasc= date (asc.) # needs translation +commentlist.order.articletitle= article title # needs translation + + # confirm confirm.htmltitle=confirmar borrado confirm.really_delete=Desea borrar esta entrada? @@ -127,6 +132,8 @@ content.creationdate=fecha content.modificationdate=último cambio content.status=Estado content.type=Tipo de artículo +content.published=publicado +content.comments=Comentarios contentlist.htmltitle=lista de contenidos diff --git a/bundles/admin_tr.properties b/bundles/admin_tr.properties index b3e73c7e10ba0f203e43509d63401a491b695992..4fdce1981fd032000ff14b883561fe8bb6ec7b09 100755 GIT binary patch delta 343 zcmX?hfpOMV#tjbqlRbDXCZFNsnOw&oFjOcS2J*JKFWWZeeyLifyr*X n29q^Jq{NGXK@bV_QV~NbLoV2hMGU+QT$3+~32$B`z9awuW;#wB delta 57 zcmbPrmGRgG#tjbqvPBH}3@Hqy49N_sK-!k!4?_`= 0); - } - - /** - * Sets the offset of the previous batch. - * @param i the previous offset - */ - public void setPrevBatch(int i) { - offsetprev = i; - } - - /** - * Returns the offset of the previous batch. - * @return offset of the previous batch - */ - public int getPrevBatch() { - return offsetprev; - } - - /** - * Returns whether there is a previous batch. - * @return true if yes, false if no - */ - public boolean hasPrevBatch() { - return (offsetprev >= 0); - } - - /** - * Returns the start index of the batch. - * @return - */ - public int getFrom() { - return offset+1; - } - - /** - * Returns the end index of the batch. - * @return - */ - public int getTo() { - if (hasNextBatch()) - return offsetnext; - else - return count; - } + /** + * Sets the WHERE clause that fetched the Entities of this EntityList from the database. + * @param wc The string that contains the WHERE clause + */ + public void setWhere(String wc) { + this.whereClause = wc; + } + + /** + * Returns the WHERE clause that returned this EntityList from the database + * @return whereClause The WHERE clause + */ + public String getWhere() { + return whereClause; + } + + + /** + * Sets the sorting criterium of this EntityList + * @param oc + */ + public void setOrder(String oc) { + this.orderClause = oc; + } + + /** + * Returns the sorting criterium. + * @return orderClause The sort order + */ + public String getOrder() { + return orderClause; + } + + /** + * Sets the number of rows that match the WHERE clause + * @param i The number of rows that match the WHERE clause + */ + public void setCount(int i) { + this.count = i; + } + + /** + * Returns the number of rows that match the WHERE clause + * @return The number of rows ... + */ + public int getCount() { + return count; + } + + /** + * Sets the offset + * @param i The offset + */ + public void setOffset(int i) { + offset = i; + } + + /** + * Returns the offset + * @return offset + */ + public int getOffset() { + return offset; + } + + /** + * Sets the offset of the next batch of Entities. + * @param i The next offset + */ + public void setNextBatch(int i) { + offsetnext = i; + } + + /** + * Returns the offset of the next batch of Entities. + * @return offset of the next batch + */ + public int getNextBatch() { + return offsetnext; + } + + /** + * Returns whether there is a next batch within the WHERE clause + * @return true if yes, false if no. + */ + public boolean hasNextBatch() { + return (offsetnext >= 0); + } + + /** + * Sets the offset of the previous batch. + * @param i the previous offset + */ + public void setPrevBatch(int i) { + offsetprev = i; + } + + /** + * Returns the offset of the previous batch. + * @return offset of the previous batch + */ + public int getPrevBatch() { + return offsetprev; + } + + /** + * Returns whether there is a previous batch. + * @return true if yes, false if no + */ + public boolean hasPrevBatch() { + return (offsetprev >= 0); + } + + /** + * Returns the start index of the batch. + * @return + */ + public int getFrom() { + return offset+1; + } + + /** + * Returns the end index of the batch. + * @return + */ + public int getTo() { + if (hasNextBatch()) + return offsetnext; + else + return count; + } /** * Inserts an Entity into the EntityList. @@ -216,9 +216,9 @@ public class EntityList implements TemplateListModel, StorableObject { public void add (Entity anEntity) { if (anEntity!=null) - theEntityArrayList.add(anEntity); + theEntityArrayList.add(anEntity); else - theLog.printWarning("EntityList: add called with empty Entity"); + theLog.printWarning("EntityList: add called with empty Entity"); } @@ -243,9 +243,9 @@ public class EntityList implements TemplateListModel, StorableObject { } - // The following methods have to be implemented - // for this class to be an implementation of the - // TemplateListModel of the Freemarker packages +// The following methods have to be implemented +// for this class to be an implementation of the +// TemplateListModel of the Freemarker packages public TemplateModel get(int i) { return elementAt(i); } public boolean isRewound() { return (freemarkerListPointer==-1) ? true : false; } @@ -253,7 +253,7 @@ public class EntityList implements TemplateListModel, StorableObject { public TemplateModel next() { if (hasNext()) { - freemarkerListPointer++;return get(freemarkerListPointer); } + freemarkerListPointer++;return get(freemarkerListPointer); } else return null; } @@ -280,16 +280,16 @@ public class EntityList implements TemplateListModel, StorableObject { } - // Methods to implement StorableObject +// Methods to implement StorableObject public Set getNotifyOnReleaseSet() { return null; } public StoreIdentifier getStoreIdentifier() { if ( theStorage!=null ) { return - new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST, - StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(), - whereClause, orderClause, offset, limit )); + new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST, + StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(), + whereClause, orderClause, offset, limit )); } theLog.printWarning("EntityList could not return StoreIdentifier"); return null; diff --git a/source/mir/util/HTTPRequestParser.java b/source/mir/util/HTTPRequestParser.java new file mode 100755 index 00000000..62baccdd --- /dev/null +++ b/source/mir/util/HTTPRequestParser.java @@ -0,0 +1,39 @@ +package mir.util; + +import javax.servlet.*; +import javax.servlet.http.*; + +public class HTTPRequestParser { + private HttpServletRequest request; + + public HTTPRequestParser(HttpServletRequest aRequest) { + request = aRequest; + } + + public boolean hasParameter(String aName) { + return request.getParameter(aName)!=null; + } + + public String getParameterWithDefault(String aName, String aDefault) { + if (hasParameter(aName)) + return request.getParameter(aName); + else + return aDefault; + } + + public String getParameter(String aName) { + return getParameterWithDefault(aName, ""); + } + + public int getIntegerWithDefault(String aName, int aDefault) { + int result = aDefault; + String value = getParameter(aName); + + try { + result = Integer.parseInt(value); + } + catch (Throwable t) { + } + return result; + } +} \ No newline at end of file diff --git a/source/mir/util/URLBuilder.java b/source/mir/util/URLBuilder.java new file mode 100755 index 00000000..940d3bc6 --- /dev/null +++ b/source/mir/util/URLBuilder.java @@ -0,0 +1,53 @@ +package mir.util; + +import java.util.*; + +public class URLBuilder { + private Map keyValues; + private String base; + + public URLBuilder(String aBase) { + keyValues = new HashMap(); + base = aBase; + } + + public URLBuilder() { + this(""); + } + + public void setValue(String aKey, String aValue) { + keyValues.put(aKey, aValue); + } + + public void setValue(String aKey, int aValue) { + keyValues.put(aKey, Integer.toString(aValue)); + } + + public void deleteKey(String aKey) { + keyValues.remove(aKey); + } + + public String getQuery() { + StringBuffer query = new StringBuffer(); + Iterator i; + + i = keyValues.entrySet().iterator(); + + while(i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + + query.append(HTMLRoutines.encodeURL((String) entry.getKey())); + query.append("="); + query.append(HTMLRoutines.encodeURL((String) entry.getValue())); + + if (i.hasNext()) + query.append("&"); + } + + return query.toString(); + } + + public String getUrl() { + return base + "?" + getQuery(); + } +} \ No newline at end of file diff --git a/source/mircoders/entity/EntityComment.java b/source/mircoders/entity/EntityComment.java index 3e71fa0f..30bee5d6 100755 --- a/source/mircoders/entity/EntityComment.java +++ b/source/mircoders/entity/EntityComment.java @@ -45,8 +45,8 @@ import mir.storage.*; /** * This class maps one line of the comment-table to a java-object. * - * @author $Author: mh $ - * @version $Revision: 1.10 $ $Date: 2002/09/01 22:05:53 $ + * @author $Author: zapata $ + * @version $Revision: 1.11 $ $Date: 2002/12/01 22:13:37 $ */ @@ -71,37 +71,38 @@ public class EntityComment extends Entity { if (theStringValues != null) { if (!theStringValues.containsKey("is_published")) { - theStringValues.put("is_published","0"); - } + theStringValues.put("is_published","0"); + } - if (theStringValues.containsKey("main_url")){ - if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) { - theStringValues.remove("main_url"); - } else if ((!((String)theStringValues.get("main_url")).startsWith("http://")) - && ((String)theStringValues.get("main_url")).length()>0){ - theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url"))); - } - } + if (theStringValues.containsKey("main_url")){ + if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) { + theStringValues.remove("main_url"); + } + else if ((!((String)theStringValues.get("main_url")).startsWith("http://")) + && ((String)theStringValues.get("main_url")).length()>0) { + theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url"))); + } + } } super.setValues(theStringValues); } - /** - * overridden method getValue to include formatted date into every - * entityContent - */ + /** + * overridden method getValue to include formatted date into every + * entityContent + */ - public String getValue(String field) + public String getValue(String field) { String returnField = null; if (field!=null) { if (field.equals("date_formatted") || field.equals("webdb_create_short")) { - if (hasValueForField("webdb_create")) - returnField = StringUtil.dateToReadableDate(getValue("webdb_create")); - } + if (hasValueForField("webdb_create")) + returnField = StringUtil.dateToReadableDate(getValue("webdb_create")); + } else if (field.equals("description_parsed")) { /** @todo the config stuff should be moved to StringUtil */ String extLinkName = MirConfig.getProp("Producer.ExtLinkName"); @@ -114,7 +115,5 @@ public class EntityComment extends Entity return super.getValue(field); } return returnField; - } - - + } } diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java index 8894213a..a94e49e6 100755 --- a/source/mircoders/servlet/ServletModuleComment.java +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -77,9 +77,11 @@ public class ServletModuleComment extends ServletModule private ServletModuleComment() { logger = new LoggerWrapper("ServletModule.Comment"); + templateListString = MirConfig.getProp("ServletModule.Comment.ListTemplate"); templateObjektString = MirConfig.getProp("ServletModule.Comment.ObjektTemplate"); templateConfirmString = MirConfig.getProp("ServletModule.Comment.ConfirmTemplate"); + try { mainModule = new ModuleComment(DatabaseComment.getInstance()); moduleContent = new ModuleContent(DatabaseContent.getInstance()); @@ -89,183 +91,157 @@ public class ServletModuleComment extends ServletModule } } - public void list(HttpServletRequest req, HttpServletResponse res) - throws ServletModuleException + public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { - // Parameter auswerten - SimpleHash mergeData = new SimpleHash(); - String query_text = req.getParameter("query_text"); - mergeData.put("query_text",query_text); - if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text)); - String query_field = req.getParameter("query_field"); - mergeData.put("query_field",query_field); - String query_is_published = req.getParameter("query_is_published"); - mergeData.put("query_is_published",query_is_published); - - String offset = req.getParameter("offset"); - if (offset==null || offset.equals("")) offset="0"; - mergeData.put("offset",offset); - - // patching order - String order = req.getParameter("order"); - if(order!=null) { - mergeData.put("order", order); - mergeData.put("order_encoded", URLEncoder.encode(order)); - if (order.equals("webdb_create")) order="webdb_create desc"; - } + HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); - // sql basteln - String whereClause=""; boolean isFirst=true; - if (query_text!=null && !query_text.equalsIgnoreCase("")) { - whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;} - if (query_is_published != null && !query_is_published.equals("")) { - if (isFirst==false) whereClause+=" and "; - whereClause += "is_published='"+query_is_published+"'"; - isFirst=false; - } + String where = requestParser.getParameter("where"); + String order = requestParser.getParameter("order"); + int offset = requestParser.getIntegerWithDefault("offset", 0); - logger.debug("list comments: whereclause = " + whereClause + ", order = " + order + ", offset = " + offset); + returnCommentList(aRequest, aResponse, where, order, offset); + } - // fetch und ausliefern - try { + public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException + { + HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); - if (query_text!=null || query_is_published!=null ) { - EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue()); - if (theList!=null && theList.size()>0) { - - //make articleHash for comment - StringBuffer buf= new StringBuffer("id in (");boolean first=true; - for(int i=0;i0) { - generationData.put( "previousurl", "module=Comment&do=listarticlecomments&offset="+ - Math.max( 0, anOffset - nrCommentsPerPage )+"&articleid="+anArticleId); - generationData.put("previous", new Integer(Math.max( 0, anOffset - nrCommentsPerPage ))); - } + if (!queryField.equals("")) { + if (!whereClause.equals("")) + whereClause = whereClause + " and "; - if (anOffset + nrCommentsPerPage < totalNrComments) { - generationData.put( "nexturl", "module=Comment&do=listarticlecomments&offset="+ - Math.min( anOffset + nrCommentsPerPage, totalNrComments-1 )+"&articleid="+anArticleId); - generationData.put("next", new Integer(Math.min( anOffset + nrCommentsPerPage, totalNrComments-1 ))); + // ML: searchText must be properly escaped! + whereClause = whereClause + "lower(" + queryField + ") like '%" + searchText.toLowerCase() + "%'"; } + } - generator.generate(aWriter, generationData, new PrintWriter(new NullWriter())); + System.out.println("search order = " + searchOrder); + + if (searchOrder.equals("datedesc")) { + orderClause = "webdb_create desc"; + } + else if (searchOrder.equals("dateasc")) { + orderClause = "webdb_create asc"; } - catch (Throwable t) { - t.printStackTrace(System.out); - throw new ServletModuleException(t.getMessage()); + else if (searchOrder.equals("articletitle")) { + orderClause = "(select content.title from content where content.id = comment.to_media) asc"; } + + returnCommentList(aRequest, aResponse, whereClause, orderClause, 0); } - public void listarticlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + public void articlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException { String articleIdString = req.getParameter("articleid"); - String offsetString = req.getParameter("offset"); - int offset = 0; - int articleId = 0; - - try { - offset = Integer.parseInt(offsetString); - } - catch (Throwable t) { - } + int articleId; try { articleId = Integer.parseInt(articleIdString); - showArticleCommentList( res.getWriter(), offset, articleId, getLocale(req)); + returnCommentList( req, res, "to_media="+articleId, "webdb_create desc", 0); } catch (ServletModuleException e) { throw e; } catch (Throwable e) { - e.printStackTrace(System.out); throw new ServletModuleException(e.getMessage()); } } - public void performarticlecommentsoperation(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException { - String commentIdString = req.getParameter("commentid"); - String articleIdString = req.getParameter("articleid"); - String offsetString = req.getParameter("offset"); - String operation = req.getParameter("operation"); - int offset = 0; - int articleId = 0; + public void returnCommentList(HttpServletRequest aRequest, HttpServletResponse aResponse, + String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleException { + // ML: experiment in using the producer's generation system instead of the + // old one... + + HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); + URLBuilder urlBuilder = new URLBuilder(); + EntityAdapterModel model; + int nrCommentsPerPage = 20; + int count; try { - articleId = Integer.parseInt(articleIdString); + Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest)); + model = MirGlobal.localizer().dataModel().adapterModel(); - showArticleCommentList( res.getWriter(), offset, articleId, getLocale(req)); - } - catch (ServletModuleException e) { - throw e; + 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("searchorder", requestParser.getParameter("searchorder")); + + responseData.put("searchfield", requestParser.getParameter("searchfield")); + responseData.put("searchtext", requestParser.getParameter("searchtext")); + responseData.put("searchispublished", requestParser.getParameter("searchispublished")); + responseData.put("searchorder", requestParser.getParameter("searchorder")); + + urlBuilder.setValue("offset", anOffset); + 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) { - e.printStackTrace(System.out); + e.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, logger.ERROR_MESSAGE))); + throw new ServletModuleException(e.getMessage()); } } } + diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index c2f57b65..dd63e3fe 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -62,14 +62,13 @@ import mircoders.localizer.*; * ServletModuleContent - * deliver html for the article admin form. * - * @version $Id: ServletModuleContent.java,v 1.24 2002/11/30 19:45:56 zapata Exp $ + * @version $Id: ServletModuleContent.java,v 1.25 2002/12/01 22:13:37 zapata Exp $ * @author rk, mir-coders * */ public class ServletModuleContent extends ServletModule { - static ModuleTopics themenModule; static ModuleSchwerpunkt schwerpunktModule; static ModuleImages imageModule; @@ -423,7 +422,7 @@ public class ServletModuleContent extends ServletModule // old one... EntityAdapterModel model; - int nrArticlesPerPage = 30; + int nrArticlesPerPage = 20; int count; try { @@ -432,7 +431,7 @@ public class ServletModuleContent extends ServletModule Object contentList = new CachingRewindableIterator( - new EntityIteratorAdapter( aWhereClause, anOrderByClause, 20, + new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage, MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset) ); diff --git a/source/mircoders/servlet/ServletModuleLocalizer.java b/source/mircoders/servlet/ServletModuleLocalizer.java index 406f978f..6977bdf7 100755 --- a/source/mircoders/servlet/ServletModuleLocalizer.java +++ b/source/mircoders/servlet/ServletModuleLocalizer.java @@ -51,10 +51,12 @@ public class ServletModuleLocalizer extends ServletModule { 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"); } @@ -63,26 +65,29 @@ public class ServletModuleLocalizer extends ServletModule { } } + public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + String idString = aRequest.getParameter("id"); + String operationString = aRequest.getParameter("operation"); + String returnUrlString = aRequest.getParameter("returnurl"); - public void commentoperation(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException - { - try { - String operationKey = req.getParameter("operation"); - String commentId = req.getParameter("commentid"); - EntityComment comment = (EntityComment) DatabaseComment.getInstance().selectById(commentId); - MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation = - (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) - MirGlobal.localizer().adminInterface().simpleArticleOperationForName(operationKey); + MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation; + EntityAdapter comment; + EntityComment entity; - EntityAdapter adapter = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("comment", comment); + try { + entity = (EntityComment) commentModule.getById(idString); - operation.perform( adapter ); + if (entity!=null) { + comment = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("comment", entity); + operation = MirGlobal.localizer().adminInterface().simpleCommentOperationForName(operationString); + operation.perform(comment); + } - res.sendRedirect(req.getParameter("returnuri")); + redirect(aResponse, returnUrlString); } - catch (Throwable t) { - t.printStackTrace(System.out); - throw new ServletModuleException(t.getMessage()); + catch (Throwable e) { + e.printStackTrace(System.out); + throw new ServletModuleException(e.getMessage()); } } diff --git a/templates/admin/comment.template b/templates/admin/comment.template index 4a3d5538..8e66068a 100755 --- a/templates/admin/comment.template +++ b/templates/admin/comment.template @@ -10,14 +10,13 @@
- - - - - + + + + @@ -25,7 +24,7 @@ - + diff --git a/templates/admin/commentlist.template b/templates/admin/commentlist.template index c4fbfbaf..21960304 100755 --- a/templates/admin/commentlist.template +++ b/templates/admin/commentlist.template @@ -7,94 +7,132 @@ - - -
${lang("comment.date")}:${utility.encodeHTML(utility.encodeHTML(data.date))}${utility.encodeHTML(utility.encodeHTML(data.webdb_create))}
- - - - + + + +
+ + + +
- - - - - - - - - - -
+ + + + + + + + + + + + + + +
+ search in field + + for value + + published + + order +
+ + + + + + + + + +
+ + + + + - - - - - - - class="list1"class="list2"> - - - - - - - - - - - - - - - - - - - - + + + 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")}

${entry.webdb_create_short}
- hidden- -
- ${entry.title}
- Von: ${entry.creator}
- ${entry.description} -
URL: ${entry.main_url}
-
${lang("edit")} -
- ${data.articleHash[entry.to_media]["title"]}
- - edit | - - view -
 ${lang("delete")} -
${data.count} ${lang("records")} - / ${lang("show_from_to", data.from, data.to)} 
- -zurueck  - - -weiter - -
${lang("no_matches_found")}
${entry.webdb_create_short}
+ hidden- +
+ ${lang("comment.article")} + + ${utility.encodeHTML(entry.to_content.title)} + +
+ + ${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")}  + +
${lang("no_matches_found")}
- + diff --git a/templates/admin/content.template b/templates/admin/content.template index 74b064cd..633d64db 100755 --- a/templates/admin/content.template +++ b/templates/admin/content.template @@ -9,338 +9,294 @@
- - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
- - ${lang("content.owner")}: - - - - ${utility.encodeHTML(data.login_user.login)} - -  
- - ${lang("content.import_date")}: - - - - ${utility.encodeHTML(data.date)} - -  
- - ${lang("content.lastchange_date")}: - - - ${utility.encodeHTML(data.webdb_lastchange)}
-
 
- - ${lang("content.create_date")}: - - - ${utility.encodeHTML(data.webdb_create)}

${lang("edit")} (yyyy-mm-dd [HH:mm]): -
-
 
- - ${lang("content.topic")}  - -  / ${lang("content.feature")}:  - - - - - - - - - - - - -
- - - - -
- - -
-
- - ${lang("content.title")}: 

${lang("content.subtitle")}: 
- - -
-
-
-
- - -
- - ${lang("content.location")}: - - - - - - -
- - ${lang("content.creator")}: - - - - -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - - - - - - - - - - - + + - - + + -
 ${lang("content.comments")} + ${lang("content.published")} : + checked> + + + + + +
+ ${lang("content.import_date")}: + + ${data.date} +  
+ ${lang("content.lastchange_date")}: + + ${utility.encodeHTML(data.webdb_lastchange)}
+
 
+ ${lang("content.create_date")}: + + ${utility.encodeHTML(data.webdb_create)}

${lang("edit")} (yyyy-mm-dd [HH:mm]): +
+
 
+ ${lang("content.topic")}  + +  / ${lang("content.feature")}:  + + + + + + + + + + +
+ + + + +
+ + +
+
+ ${lang("content.title")}:  + +
+
+ ${lang("content.subtitle")}: 
+ + +
+ + +
+ ${lang("content.location")}: + + + +
+ ${lang("content.creator")}: + + + +
+
+ ${lang("content.creator.email")}/${lang("content.creator.url")}: + + + + + +
+ ${lang("content.creator.address")}/${lang("content.creator.telephone")}: + + + + + +
+ ${lang("content.abstract")}: + + + + +
+ ${lang("content.content")}: + +
+ ${lang("content.html")} + checked>  + + + +
+ +
+ ${lang("content.comment")}:
+ ${lang("content.internal")} +
+ +
    + + + + + +
+ ${lang("content.attachments")} +
- - ${lang("content.creator.email")}/${lang("content.creator.url")}: - - - - - - -
- - ${lang("content.creator.address")}/${lang("content.creator.telephone")}: - - - - - - -
- - ${lang("content.abstract")}: - - - - - -
- - ${lang("content.content")}: - - - ${lang("content.html")} - checked>  - - - - - - -
- - ${lang("content.comment")}:
- ${lang("content.internal")} - -
- -
    - frei : - checked> - - - - - -
${lang("content.attachments")}
- - ${lang("content.images")}: - - - edit - ${lang("delete")} - + ${lang("content.images")}: + + edit + ${lang("delete")} +
- - ${lang("content.media")}: - - ${lang("content.addimage")} - + ${lang("content.media")}: + + ${lang("content.addimage")} +
- - ${lang("content.audio")}: - - - edit - ${lang("delete")} - + ${lang("content.audio")}: + + edit + ${lang("delete")} +
- - ${lang("content.media")}: - - - ${lang("content.addaudio")} - + ${lang("content.media")}: + + ${lang("content.addaudio")} +
- - ${lang("content.video")}: - - - edit - ${lang("delete")} -
- - ${lang("content.media")}: - - - ${lang("content.addvideo")} -
- - ${lang("content.other")}: - - - edit - ${lang("delete")} - + ${lang("content.video")}: + + edit + ${lang("delete")} +
- - ${lang("content.media")}: - - - ${lang("content.addother")} - + ${lang("content.media")}: + + ${lang("content.addvideo")} +
-
- - + + + + ${lang("content.other")}: + + + edit + ${lang("delete")} + + + + + + ${lang("content.media")}: + + + ${lang("content.addother")} + + + + + + diff --git a/web/style/admin.css b/web/style/admin.css index e2ea7743..cc18dfa1 100755 --- a/web/style/admin.css +++ b/web/style/admin.css @@ -34,4 +34,12 @@ .witesmall {font-size: small; color: #ffffff; text-decoration:none;} .witex-small {font-size: x-small; color: #ffffff; text-decoration:none;} - .lynx {display:none;} \ No newline at end of file + .lynx {display:none;} + + .editfieldname { + font-size: large; + color: #ffffff; + font-weight: bold; + text-decoration:none; + background-color: #dddddd; + } \ No newline at end of file -- 2.11.0