Author: agilliland
Date: Fri May 11 09:51:00 2007
New Revision: 537232

URL: http://svn.apache.org/viewvc?view=rev&rev=537232
Log:
struts2 version of global comment managment page.  there are still some bugs in 
these new struts2 versions which will be fixed in a subsequent revision.


Added:
    
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagement.java
    
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagementBean.java
    roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagement.jsp
    
roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagementSidebar.jsp
Modified:
    roller/trunk/src/org/apache/roller/util/MailUtil.java

Added: 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagement.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagement.java?view=auto&rev=537232
==============================================================================
--- 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagement.java
 (added)
+++ 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagement.java
 Fri May 11 09:51:00 2007
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.admin.struts2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.business.RollerFactory;
+import org.apache.roller.business.WeblogManager;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.ui.core.util.struts2.KeyValueObject;
+import org.apache.roller.util.cache.CacheManager;
+import org.apache.roller.ui.core.util.struts2.UIAction;
+import org.apache.roller.util.Utilities;
+
+
+/**
+ * Action for managing global set of comments.
+ */
+public class GlobalCommentManagement extends UIAction {
+    
+    private static Log log = LogFactory.getLog(GlobalCommentManagement.class);
+    
+    // bean for managing submitted data
+    private GlobalCommentManagementBean bean = new 
GlobalCommentManagementBean();
+    
+    // list of comments to display
+    private List comments = Collections.EMPTY_LIST;
+    
+    // first comment in the list
+    private CommentData firstComment = null;
+    
+    // last comment in the list
+    private CommentData lastComment = null;
+    
+    // are there more results for the query?
+    private boolean moreResults = false;
+    
+    // link to previous page of results
+    private String prevLink = null;
+    
+    // linke to next page of results
+    private String nextLink = null;
+    
+    // indicates number of comments that would be deleted by bulk removal
+    // a non-zero value here indicates bulk removal is a valid option
+    private int bulkDeleteCount = 0;
+    
+    
+    public GlobalCommentManagement() {
+        this.actionName = "globalCommentManagement";
+        this.desiredMenu = "admin";
+        this.pageTitle = "commentManagement.title";
+    }
+    
+    
+    // admin role required
+    public String requiredUserRole() {
+        return "admin";
+    }
+    
+    // no weblog required
+    public boolean isWeblogRequired() {
+        return false;
+    }
+    
+    
+    public void loadComments() {
+        
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            List comments = wmgr.getComments(
+                    null,
+                    null,
+                    getBean().getSearchString(),
+                    getBean().getStartDate(),
+                    getBean().getEndDate(),
+                    getBean().getStatus(),
+                    true, // reverse  chrono order
+                    getBean().getOffset(),
+                    getBean().getCount() + 1);
+            
+            if(comments != null) {
+                if(comments.size() > getBean().getCount()) {
+                    comments.remove(comments.size()-1);
+                    setMoreResults(true);
+                }
+                
+                setComments(comments);
+                setFirstComment((CommentData)comments.get(0));
+                setLastComment((CommentData)comments.get(comments.size()-1));
+                loadNextPrevLinks(isMoreResults());
+            }
+        } catch (RollerException ex) {
+            log.error("Error looking up comments", ex);
+            // TODO: i18n
+            addError("Error looking up comments");
+        }
+    }
+
+    
+    // show comment management page
+    public String execute() {
+        
+        // load list of comments from query
+        loadComments();
+        
+        // load bean data using comments list
+        getBean().loadCheckboxes(getComments());
+        
+        return LIST;
+    }
+    
+    
+    /**
+     * Query for a specific subset of comments based on various criteria.
+     */
+    public String query() {
+        
+        // load list of comments from query
+        loadComments();
+        
+        // load bean data using comments list
+        getBean().loadCheckboxes(getComments());
+        
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            List allMatchingComments = wmgr.getComments(
+                    null,
+                    null,
+                    getBean().getSearchString(),
+                    getBean().getStartDate(),
+                    getBean().getEndDate(),
+                    getBean().getStatus(),
+                    true, // reverse  chrono order
+                    0,
+                    -1);
+            
+            if(allMatchingComments.size() > getBean().getCount()) {
+                setBulkDeleteCount(allMatchingComments.size());
+            }
+            
+        } catch (RollerException ex) {
+            log.error("Error looking up comments", ex);
+            // TODO: i18n
+            addError("Error looking up comments");
+        }
+        
+        return LIST;
+    }
+    
+    
+    /**
+     * Bulk delete all comments matching query criteria.
+     */
+    public String delete() {
+        
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            int deleted = wmgr.removeMatchingComments(
+                    null,
+                    null,
+                    getBean().getSearchString(),
+                    getBean().getStartDate(),
+                    getBean().getEndDate(),
+                    getBean().getStatus());
+            
+            // TODO: i18n
+            addMessage("Successfully deleted "+deleted+" comments");
+            
+            // reset form and load fresh comments list
+            setBean(new GlobalCommentManagementBean());
+            
+            return execute();
+            
+        } catch (RollerException ex) {
+            log.error("Error doing bulk delete", ex);
+            // TODO: i18n
+            addError("Bulk delete failed due to unexpected error");
+        }
+        
+        return LIST;
+    }
+    
+    
+    /**
+     * Update a list of comments.
+     */
+    public String update() {
+        
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            
+            List flushList = new ArrayList();
+            
+            // delete all comments with delete box checked
+            List<String> deletes = 
Arrays.asList(getBean().getDeleteComments());
+            if(deletes != null && deletes.size() > 0) {
+                log.debug("Processing deletes - "+deletes.size());
+                
+                CommentData deleteComment = null;
+                for(String deleteId : deletes) {
+                    deleteComment = wmgr.getComment(deleteId);
+                    wmgr.removeComment(deleteComment);
+                    flushList.add(deleteComment);
+                }
+            }
+            
+            // loop through IDs of all comments displayed on page
+            List spamIds = Arrays.asList(getBean().getSpamComments());
+            log.debug(spamIds.size()+" comments marked as spam");
+            
+            String[] ids = 
Utilities.stringToStringArray(getBean().getIds(),",");
+            for (int i=0; i < ids.length; i++) {
+                log.debug("processing id - "+ ids[i]);
+                
+                // if we already deleted it then skip forward
+                if(deletes.contains(ids[i])) {
+                    log.debug("Already deleted, skipping - "+ids[i]);
+                    continue;
+                }
+                
+                CommentData comment = wmgr.getComment(ids[i]);
+                
+                // mark/unmark spam
+                if (spamIds.contains(ids[i]) && 
+                        !CommentData.SPAM.equals(comment.getStatus())) {
+                    log.debug("Marking as spam - "+comment.getId());
+                    comment.setStatus(CommentData.SPAM);
+                    wmgr.saveComment(comment);
+                    
+                    flushList.add(comment);
+                } else if(CommentData.SPAM.equals(comment.getStatus())) {
+                    log.debug("Marking as approved - "+comment.getId());
+                    comment.setStatus(CommentData.APPROVED);
+                    wmgr.saveComment(comment);
+                    
+                    flushList.add(comment);
+                }
+            }
+            
+            RollerFactory.getRoller().flush();
+            
+            // notify caches of changes
+            for (Iterator comments=flushList.iterator(); comments.hasNext();) {
+                CacheManager.invalidate((CommentData)comments.next());
+            }
+            
+            addMessage("commentManagement.updateSuccess");
+            
+            // reset form and load fresh comments list
+            setBean(new GlobalCommentManagementBean());
+            
+            return execute();
+            
+        } catch (Exception ex) {
+            log.error("ERROR updating comments", ex);
+            addError("commentManagement.updateError", ex.toString());
+        }
+        
+        return LIST;
+    }
+    
+    
+    private void loadNextPrevLinks(boolean moreResults) {
+        
+    }
+    
+    
+    public List getCommentStatusOptions() {
+        
+        List opts = new ArrayList();
+        
+        opts.add(new KeyValueObject("ALL", getText("commentManagement.all")));
+        opts.add(new KeyValueObject("ONLY_PENDING", 
getText("commentManagement.onlyPending")));
+        opts.add(new KeyValueObject("ONLY_APPROVED", 
getText("commentManagement.onlyApproved")));
+        opts.add(new KeyValueObject("ONLY_DISAPPROVED", 
getText("commentManagement.onlyDisapproved")));
+        
+        return opts;
+    }
+    
+    public List getSpamStatusOptions() {
+        
+        List opts = new ArrayList();
+        
+        opts.add(new KeyValueObject("ALL", getText("commentManagement.all")));
+        opts.add(new KeyValueObject("NO_SPAM", 
getText("commentManagement.noSpam")));
+        opts.add(new KeyValueObject("ONLY_SPAM", 
getText("commentManagement.onlySpam")));
+        
+        return opts;
+    }
+    
+    
+    public GlobalCommentManagementBean getBean() {
+        return bean;
+    }
+
+    public void setBean(GlobalCommentManagementBean bean) {
+        this.bean = bean;
+    }
+
+    public List getComments() {
+        return comments;
+    }
+
+    public void setComments(List comments) {
+        this.comments = comments;
+    }
+
+    public int getBulkDeleteCount() {
+        return bulkDeleteCount;
+    }
+
+    public void setBulkDeleteCount(int bulkDeleteCount) {
+        this.bulkDeleteCount = bulkDeleteCount;
+    }
+
+    public CommentData getFirstComment() {
+        return firstComment;
+    }
+
+    public void setFirstComment(CommentData firstComment) {
+        this.firstComment = firstComment;
+    }
+
+    public CommentData getLastComment() {
+        return lastComment;
+    }
+
+    public void setLastComment(CommentData lastComment) {
+        this.lastComment = lastComment;
+    }
+
+    public String getPrevLink() {
+        return prevLink;
+    }
+
+    public void setPrevLink(String prevLink) {
+        this.prevLink = prevLink;
+    }
+
+    public String getNextLink() {
+        return nextLink;
+    }
+
+    public void setNextLink(String nextLink) {
+        this.nextLink = nextLink;
+    }
+
+    public boolean isMoreResults() {
+        return moreResults;
+    }
+
+    public void setMoreResults(boolean moreResults) {
+        this.moreResults = moreResults;
+    }
+    
+}

Added: 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagementBean.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagementBean.java?view=auto&rev=537232
==============================================================================
--- 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagementBean.java
 (added)
+++ 
roller/trunk/src/org/apache/roller/ui/admin/struts2/GlobalCommentManagementBean.java
 Fri May 11 09:51:00 2007
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.admin.struts2;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.DateUtil;
+import org.apache.roller.util.Utilities;
+
+
+/**
+ * A bean for managing comments.
+ */
+public class GlobalCommentManagementBean {
+    
+    private String searchString = null;
+    private Date startDate = null;
+    private Date endDate = null;
+    private String spamString = "ALL";
+    private String approvedString = "ALL";
+    private int count = 30;
+    private int offset = 0;
+    
+    private String[] spamComments = new String[0];
+    private String[] deleteComments = new String[0];
+    
+    // Limit updates to just this set of comma-separated IDs
+    private String ids = null;
+    
+    
+    public void loadCheckboxes(List comments) {
+        
+        List<String> allComments = new ArrayList();
+        List<String> spamList = new ArrayList();
+        
+        Iterator it = comments.iterator();
+        while (it.hasNext()) {
+            CommentData comment = (CommentData)it.next();
+            allComments.add(comment.getId());
+            
+            if (CommentData.SPAM.equals(comment.getStatus())) {
+                spamList.add(comment.getId());
+            }
+        }
+        
+        String[] idArray = (String[]) allComments.toArray(new 
String[allComments.size()]);
+        this.setIds(Utilities.stringArrayToString(idArray,","));
+        
+        spamComments = (String[])spamList.toArray(
+            new String[spamList.size()]);
+    }
+    
+    
+    public String getStatus() {
+        if (approvedString.equals("ONLY_APPROVED")) {
+            return CommentData.APPROVED;
+        } else if (approvedString.equals("ONLY_DISAPPROVED")) {
+            return CommentData.DISAPPROVED;
+        } else if (approvedString.equals("ONLY_PENDING")) {
+            return CommentData.PENDING;
+        } else if (spamString.equals("ONLY_SPAM")) {
+            return CommentData.SPAM;
+        } else if (spamString.equals("NO_SPAM")) {
+            // all status' except spam
+            // special situation, so this doesn't map to a persisted comment 
status
+            return "ALL_IGNORE_SPAM";
+        } else {
+            // shows *all* comments, regardless of status
+            return null;
+        }
+    }
+    
+    
+    public int getCount() {
+        return count;
+    }
+    
+    public void setCount(int count) {
+        this.count = count;
+    }
+    
+    public int getOffset() {
+        return offset;
+    }
+    
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+    
+    public String getSpamString() {
+        return spamString;
+    }
+    
+    public void setSpamString(String spamString) {
+        this.spamString = spamString;
+    }
+    
+    public String getPendingString() {
+        return approvedString;
+    }
+    
+    public void setPendingString(String pendingString) {
+        this.approvedString = pendingString;
+    }
+    
+    public String getIds() {
+        return ids;
+    }
+    
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+    
+    public String getSearchString() {
+        return searchString;
+    }
+    
+    public void setSearchString(String searchString) {
+        this.searchString = searchString;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public String[] getSpamComments() {
+        return spamComments;
+    }
+
+    public void setSpamComments(String[] spamComments) {
+        this.spamComments = spamComments;
+    }
+
+    public String[] getDeleteComments() {
+        return deleteComments;
+    }
+
+    public void setDeleteComments(String[] deleteComments) {
+        this.deleteComments = deleteComments;
+    }
+    
+}

Modified: roller/trunk/src/org/apache/roller/util/MailUtil.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/util/MailUtil.java?view=diff&rev=537232&r1=537231&r2=537232
==============================================================================
--- roller/trunk/src/org/apache/roller/util/MailUtil.java (original)
+++ roller/trunk/src/org/apache/roller/util/MailUtil.java Fri May 11 09:51:00 
2007
@@ -19,6 +19,9 @@
 package org.apache.roller.util;
 
 import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 import java.util.ResourceBundle;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -38,7 +41,9 @@
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.UserManager;
 import org.apache.roller.config.RollerRuntimeConfig;
+import org.apache.roller.pojos.PermissionsData;
 import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
 
 
@@ -63,6 +68,76 @@
         } catch (NamingException ex) {
             throw new RollerException("ERROR: Notification email(s) not sent, "
                     + "Roller's mail session not properly configured", ex);
+        }
+    }
+    
+    
+    /**
+     * Send an email notice that a new pending entry has been submitted.
+     */
+    public static void sendPendingEntryNotice(WeblogEntryData entry) 
+            throws RollerException {
+        
+        Session mailSession = getMailSession();
+        if(mailSession == null) {
+            throw new RollerException("Couldn't get mail Session");
+        }
+        
+        try {
+            UserManager umgr = RollerFactory.getRoller().getUserManager();
+            
+            String userName = entry.getCreator().getUserName();
+            String from = entry.getCreator().getEmailAddress();
+            String cc[] = new String[] {from};
+            String bcc[] = new String[0];
+            String to[];
+            String subject;
+            String content;
+            
+            // list of enabled website authors and admins
+            ArrayList reviewers = new ArrayList();
+            List websiteUsers = umgr.getUsers(
+                    entry.getWebsite(), Boolean.TRUE, null, null, 0, -1);
+            
+            // build list of reviewers (website users with author permission)
+            Iterator websiteUserIter = websiteUsers.iterator();
+            while (websiteUserIter.hasNext()) {
+                UserData websiteUser = (UserData)websiteUserIter.next();
+                if (entry.getWebsite().hasUserPermissions(
+                        websiteUser, PermissionsData.AUTHOR)
+                        && websiteUser.getEmailAddress() != null) {
+                    reviewers.add(websiteUser.getEmailAddress());
+                }
+            }
+            to = (String[])reviewers.toArray(new String[reviewers.size()]);
+            
+            // Figure URL to entry edit page
+            String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
+            String editURL = rootURL
+                    + "/roller-ui/authoring/weblog.do?method=edit&entryId=" + 
entry.getId();
+            
+            ResourceBundle resources = ResourceBundle.getBundle(
+                    "ApplicationResources", 
entry.getWebsite().getLocaleInstance());
+            StringBuffer sb = new StringBuffer();
+            sb.append(
+                    MessageFormat.format(
+                    resources.getString("weblogEntry.pendingEntrySubject"),
+                    new Object[] {
+                entry.getWebsite().getName(),
+                entry.getWebsite().getHandle()
+            }));
+            subject = sb.toString();
+            sb = new StringBuffer();
+            sb.append(
+                    MessageFormat.format(
+                    resources.getString("weblogEntry.pendingEntryContent"),
+                    new Object[] { userName, userName, editURL })
+                    );
+            content = sb.toString();
+            MailUtil.sendTextMessage(
+                    mailSession, from, to, cc, bcc, subject, content);
+        } catch (MessagingException e) {
+            log.error("ERROR: Problem sending pending entry notification 
email.");
         }
     }
     

Added: roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagement.jsp
URL: 
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagement.jsp?view=auto&rev=537232
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagement.jsp 
(added)
+++ roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagement.jsp Fri 
May 11 09:51:00 2007
@@ -0,0 +1,335 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  The ASF licenses this file to You
+  under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.  For additional information regarding
+  copyright in this work, please see the NOTICE file in the top level
+  directory of this distribution.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %>
+
+<script type="text/javascript">
+<!-- 
+function setChecked(val, name) {
+    len = document.globalCommentManagement.elements.length;
+    var i=0;
+    for( i=0 ; i<len ; i++) {
+        if (document.globalCommentManagement.elements[i].name == name) { 
+           document.globalCommentManagement.elements[i].checked=val;
+        }
+    }
+}
+function bulkDelete() {
+    if (window.confirm('<s:text 
name="commentManagement.confirmBulkDelete"><s:param value="bulkDeleteCount" 
/></s:text>')) {
+        document.commentQueryForm.method.value = "bulkDelete";
+        document.commentQueryForm.submit();
+    }
+}
+
+function createRequestObject() {
+    var ro;
+    var browser = navigator.appName;
+    if (browser == "Microsoft Internet Explorer") {
+        ro = new ActiveXObject("Microsoft.XMLHTTP");
+    } else {
+        ro = new XMLHttpRequest();
+    }
+    return ro;
+}
+var http = createRequestObject();
+var init = false;
+var isBusy = false;
+
+function readMoreComment(id) {
+    url = "<%= request.getContextPath() 
%>/roller-ui/authoring/commentdata?id=" + id;
+    if (isBusy) return;
+    isBusy = true;
+    http.open('get', url);
+    http.onreadystatechange = handleCommentResponse;
+    http.send(null);
+}
+
+function handleCommentResponse() {
+    if (http.readyState == 4) {
+        comment = eval("(" + http.responseText + ")"); 
+        commentDiv = document.getElementById("comment-" + comment.id);
+        commentDiv.textContent = comment.content;
+        linkDiv = document.getElementById("link-" + comment.id);
+        linkDiv.parentNode.removeChild(linkDiv);
+    }
+    isBusy = false;
+}
+-->
+</script>
+
+<p class="subtitle">
+    <s:text name="commentManagement.subtitle" />
+</p>
+
+<p class="pagetip"><s:text name="commentManagement.globalTip" /></p>
+
+<s:if test="comments.isEmpty">
+    <s:text name="commentManagement.noCommentsFound" />
+</s:if>
+
+<s:else>
+
+<%-- ============================================================= --%>
+<%-- Comment table / form with checkboxes --%>
+<%-- ============================================================= --%>
+
+<s:form action="globalCommentManagement!update">
+    <s:hidden name="bean.ids" />
+    <s:hidden name="bean.offset" />
+    <s:hidden name="bean.count" />
+    <s:hidden name="bean.startDateString" />
+    <s:hidden name="bean.endDateString" />
+    <s:hidden name="bean.pendingString" />
+    <s:hidden name="bean.spamString" />
+    
+<%-- ============================================================= --%>
+<%-- Number of comments and date message --%>
+<%-- ============================================================= --%>
+        
+<div class="tablenav">
+    
+    <div style="float:left;">
+        <s:text name="commentManagement.nowShowing">
+            <s:param value="comments.size()" />
+        </s:text>
+    </div>
+    <div style="float:right;">
+        <s:date name="firstComment.postTime" format="MM/dd/yy hh:mm a" />
+        --- 
+        <s:date name="lastComment.postTime" format="MM/dd/yy hh:mm a" />
+    </div>
+    <br />
+    
+    
+    <%-- ============================================================= --%>
+    <%-- Next / previous links --%>
+    <%-- ============================================================= --%>
+        
+    <s:if test="prevLink != null && nextLink != null">
+        <br /><center>
+            &laquo;
+            <a href='<s:property value="prevLink" />'>
+            <s:text name="commentManagement.prev" /></a>
+            | <a href='<s:property value="nextLink" />'>
+            <s:text name="commentManagement.next" /></a>
+            &raquo;
+        </center><br />
+    </s:if>
+    <s:elseif test="prevLink != null">
+        <br /><center>
+            &laquo;
+            <a href='<s:property value="prevLink" />'>
+            <s:text name="commentManagement.prev" /></a>
+            | <s:text name="commentManagement.next" />
+            &raquo;
+        </center><br />
+    </s:elseif>
+    <s:elseif test="nextLink != null">
+        <br /><center>
+            &laquo;
+            <s:text name="commentManagement.prev" />
+            | <a class="" href='<s:property value="nextLink" />'>
+            <s:text name="commentManagement.next" /></a>
+            &raquo;
+        </center><br />
+    </s:elseif>
+    <s:else><br /></s:else>
+    
+</div> <%-- class="tablenav" --%>
+
+        
+<%-- ============================================================= --%>
+<%-- Bulk comment delete link --%>
+<%-- ============================================================= --%>
+        
+<s:if test="bulkDeleteCount > 0">
+    <p>
+        <s:text name="commentManagement.bulkDeletePrompt1">
+            <s:param value="bulkDeleteCount" />
+        </s:text>
+        <a href="#" onclick="bulkDelete()">
+            <s:text name="commentManagement.bulkDeletePrompt2" />
+        </a>
+    </p>
+</s:if>
+
+
+<table class="rollertable" width="100%">
+
+<%-- ======================================================== --%>
+<%-- Comment table header --%>
+           
+<tr>
+    <th class="rollertable" width="5%">
+        <s:text name="commentManagement.columnSpam" />
+    </th>
+    <th class="rollertable" width="5%" >
+        <s:text name="commentManagement.columnDelete" />
+    </th>
+    <th class="rollertable">
+        <s:text name="commentManagement.columnComment" />
+    </th>
+</tr>
+
+<%-- ======================================================== --%>
+<%-- Select ALL and NONE buttons --%>
+           
+    <tr class="actionrow">
+        <td align="center">
+            <s:text name="commentManagement.select" /><br/>
+            
+            <a href="#" onclick='setChecked(1,"spamComments")'>
+            <s:text name="commentManagement.all" /></a><br />  
+            
+            <a href="#" onclick='setChecked(0,"spamComments")'>
+            <s:text name="commentManagement.none" /></a>
+        </td>
+        <td align="center">
+            <s:text name="commentManagement.select" /><br/>
+            
+            <a href="#" onclick='setChecked(1,"deleteComments")'>
+            <s:text name="commentManagement.all" /></a><br /> 
+            
+            <a href="#" onclick='setChecked(0,"deleteComments")'>
+            <s:text name="commentManagement.none" /></a>
+        </td>
+        <td align="right">
+            <br />
+            <span class="pendingCommentBox">&nbsp;&nbsp;&nbsp;&nbsp;</span>
+            <s:text name="commentManagement.pending" />&nbsp;&nbsp;
+            <span class="spamCommentBox">&nbsp;&nbsp;&nbsp;&nbsp;</span> 
+            <s:text name="commentManagement.spam" />&nbsp;&nbsp;
+        </td>
+    </tr>
+
+
+<%-- ========================================================= --%>
+<%-- Loop through comments --%>
+<%-- ========================================================= --%>
+
+<s:iterator id="comment" value="comments" status="rowstatus">
+<tr>
+    <td>
+        <%-- a bit funky to use checkbox list here, but using checkbox didn't 
work for me :(
+             we are effectively just creating a checkbox list of 1 item for 
each iteration of our collection --%>
+        <s:checkboxlist name="bean.spamComments" list="{#comment}" 
listKey="id" listValue="name" />
+    </td>
+    <td>
+        <%-- a bit funky to use checkbox list here, but using checkbox didn't 
work for me :(
+             we are effectively just creating a checkbox list of 1 item for 
each iteration of our collection --%>
+        <s:checkboxlist name="bean.deleteComments" list="{#comment}" 
listKey="id" listValue="name" />
+    </td>
+    
+    <%-- ======================================================== --%>
+    <%-- Display comment details and text --%>
+           
+    <%-- <td> with style if comment is spam or pending --%>               
+    <s:if test="#comment.status == 'SPAM'">
+        <td class="spamcomment"> 
+    </s:if>
+    <s:elseif test="#comment.status == 'PENDING'">
+        <td class="pendingcomment"> 
+    </s:elseif>
+    <s:else>
+        <td>
+    </s:else>
+    
+    <%-- comment details table in table --%>
+    <table style="border:none; padding:0px; margin:0px">                       
  
+        <tr>
+            <td style="border: none; padding:0px;">
+            <s:text name="commentManagement.entryTitled" /></td>
+            <td class="details" style="border: none; padding:0px;">  
+                <a href='<s:property value="#comment.weblogEntry.permalink" 
/>'>
+                <s:property value="#comment.weblogEntry.title" /></a>
+            </td>
+        </tr>  
+        
+        <tr>
+            <td style="border: none; padding:0px;">
+            <s:text name="commentManagement.commentBy" /></td>
+            <td class="details" style="border: none; padding:0px;">
+                <s:if test="#comment.email != null && #comment.name != null">
+                    <s:text name="commentManagement.commentByBoth" >
+                        <s:param><s:property value="#comment.name" /></s:param>
+                        <s:param><s:property value="#comment.email" 
/></s:param>
+                        <s:param value="mailto" />
+                        <s:param><s:property value="#comment.remoteHost" 
/></s:param>
+                    </s:text>
+                </s:if>
+                <s:elseif test="#comment.email == null && #comment.name == 
null">
+                    <s:text name="commentManagement.commentByIP" >
+                        <s:param><s:property value="#comment.remoteHost" 
/></s:param>
+                    </s:text>
+                </s:elseif>
+                <s:else>
+                    <s:text name="commentManagement.commentByName" >
+                        <s:param><s:property value="#comment.name" /></s:param>
+                        <s:param><s:property value="#comment.remoteHost" 
/></s:param>
+                    </s:text>
+                </s:else>
+                
+                <s:if test="#comment.url != null">
+                    <br /><a href='<s:property value="#comment.url" />'>
+                    <str:truncateNicely upper="60" 
appendToEnd="..."><s:property value="#comment.url" /></str:truncateNicely></a>
+                </s:if>
+            </td>
+        </tr>                                
+        <tr>
+            <td style="border: none; padding:0px;">
+            <s:text name="commentManagement.postTime" /></td>
+            <td class="details" style="border: none; padding:0px;">
+            <s:property value="#comment.postTime" /></td>
+        </tr>                                       
+    </table> <%-- end comment details table in table --%>
+                
+    <%-- comment content --%>
+    <br />
+    <span class="details">
+        
+    <s:if test="#comment.content.length > 1000">
+        <pre><div id="comment-<s:property value="#comment.id"/>"><str:wordWrap 
width="72"><str:truncateNicely upper="1000" appendToEnd="..."><s:property 
value="#comment.content" escape="true" 
/></str:truncateNicely></str:wordWrap></div></pre>                              
      
+        <div id="link-<s:property value="#comment.id"/>">
+            <a onclick='readMoreComment("<s:property value="#comment.id"/>")'>
+                <s:text name="commentManagement.readmore" />
+            </a>
+        </div>
+    </s:if>
+    <s:else>
+        <pre><str:wordWrap><s:property value="#comment.content" escape="true" 
/></str:wordWrap></pre>   
+    </s:else>
+        
+    </span>
+    
+    </td>
+</tr>
+</s:iterator>
+</table>
+<br />
+
+<%-- ========================================================= --%>
+<%-- Save changes and  cancel buttons --%>
+<%-- ========================================================= --%>
+            
+<s:submit key="commentManagement.update" />
+&nbsp;
+<s:submit key="application.cancel" action="globalCommentManagement" />
+
+</s:form>
+
+</s:else>

Added: 
roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagementSidebar.jsp
URL: 
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagementSidebar.jsp?view=auto&rev=537232
==============================================================================
--- 
roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagementSidebar.jsp 
(added)
+++ 
roller/trunk/web/WEB-INF/jsps/admin/struts2/GlobalCommentManagementSidebar.jsp 
Fri May 11 09:51:00 2007
@@ -0,0 +1,91 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  The ASF licenses this file to You
+  under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.  For additional information regarding
+  copyright in this work, please see the NOTICE file in the top level
+  directory of this distribution.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<div class="sidebarFade">
+    <div class="menu-tr">
+        <div class="menu-tl">
+
+<div class="sidebarInner">
+
+<h3><s:text name="commentManagement.sidebarTitle" /></h3>
+<hr size="1" noshade="noshade" />
+
+<p><s:text name="commentManagement.sidebarDescription" /></p>
+    
+ <s:form action="globalCommentManagement!query">
+        
+    <div class="sideformrow">
+        <label for="searchString" class="sideformrow"><s:text 
name="commentManagement.searchString" />:</label>   
+        <s:textfield name="bean.searchString" />
+    </div>
+    <br />
+    <br />
+    
+    <div class="sideformrow">
+        <label for="startDateString" class="sideformrow"><s:text 
name="commentManagement.startDate" />:</label>
+        <s:datetimepicker name="bean.startDate" />
+    </div>
+        
+    <div class="sideformrow">
+        <label for="endDateString" class="sideformrow"><s:text 
name="commentManagement.endDate" />:</label>
+        <s:datetimepicker name="bean.endDate" />
+    </div>
+    <br />
+    <br />
+  
+    <div class="sideformrow">
+        <label for="pendingString" class="sideformrow">
+            <s:text name="commentManagement.pendingStatus" />
+            <br />
+            <br />
+            <br />
+            <br />            
+            <br />
+        </label> 
+        <div>
+            <s:radio name="approvedString" list="commentStatusOptions" 
listKey="key" listValue="value" />
+        </div>
+    </div> 
+    <br />
+
+    <div class="sideformrow">
+        <label for="spamString" class="sideformrow">
+            <s:text name="commentManagement.spamStatus" />   
+            <br />
+            <br />
+            <br />
+            <br />
+        </label>
+        <div>
+            <s:radio name="spamString" list="spamStatusOptions" listKey="key" 
listValue="value" />
+        </div>
+    </div>
+    <br />
+    
+    <s:submit key="commentManagement.query" />
+            
+</s:form>
+
+<br />
+<br />
+</div> <!-- sidebarInner -->
+
+        </div>
+    </div>
+</div>


Reply via email to