roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r349597 - in /incubator/roller/trunk: src/org/roller/pojos/WeblogEntryData.java src/org/roller/presentation/velocity/PageModel.java src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java web/WEB-INF/classes/comments.vm
Date Tue, 29 Nov 2005 02:50:54 GMT
Author: snoopdave
Date: Mon Nov 28 18:50:49 2005
New Revision: 349597

URL: http://svn.apache.org/viewcvs?rev=349597&view=rev
Log:
Missed these in previous commit

Modified:
    incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
    incubator/roller/trunk/web/WEB-INF/classes/comments.vm

Modified: incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java?rev=349597&r1=349596&r2=349597&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java Mon Nov 28 18:50:49 2005
@@ -647,22 +647,29 @@
     /**
      * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.CommentData"
      */
-    public List getComments()
-    {
-        return getComments(true);
+    public List getComments() {
+        return getComments(true, true);
     }
     
     /**
      * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.CommentData"
      */
-    public List getComments(boolean ignoreSpam)
-    {
+    public List getComments(boolean ignoreSpam, boolean approvedOnly) {
         List list = new ArrayList();
-        try
-        {
-            return RollerFactory.getRoller().getWeblogManager().getComments(getId(), ignoreSpam);
-        }
-        catch (RollerException alreadyLogged) {}
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            return wmgr.getComments(
+                    getWebsite(),
+                    this,
+                    null,  // search String
+                    null,  // startDate
+                    null,  // endDate
+                    null,  // pending
+                    approvedOnly ? Boolean.TRUE : null, // approved
+                    ignoreSpam ? Boolean.FALSE : null,  // spam
+                     0,    // offset
+                    -1);   // no limit
+        } catch (RollerException alreadyLogged) {}
         return list;
     }
 

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java?rev=349597&r1=349596&r2=349597&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java Mon Nov 28
18:50:49 2005
@@ -15,7 +15,6 @@
 import org.roller.config.RollerRuntimeConfig;
 import org.roller.model.BookmarkManager;
 import org.roller.model.RefererManager;
-import org.roller.model.Roller;
 import org.roller.model.RollerFactory;
 import org.roller.pojos.Template;
 import org.roller.model.UserManager;
@@ -168,42 +167,35 @@
     
     //------------------------------------------------------------------------
     
-    /** Encapsulates WeblogManager.getComments().size() */
-    public int getCommentCount(String entryId)
-    {
-        try
-        {
-            return mWeblogMgr.getComments( entryId ).size();
-        }
-        catch (RollerException e)
-        {
-            mLogger.error("PageModel getCommentCount()", e);
-        }
+    /** Get number of approved non-spam comments for entry */
+    public int getCommentCount(String entryId) {
+        return getCommentCount(entryId, true, true);
+    }
+    
+    /** Get number of approved non-spam comments for entry */
+    public int getCommentCount(String entryId, boolean noSpam, boolean approvedOnly) {
+        try {
+            WeblogEntryData entry = mWeblogMgr.retrieveWeblogEntry(entryId);
+            return entry.getComments(noSpam, approvedOnly).size();
+        } catch (RollerException alreadyLogged) {}
         return 0;
     }
     
     //------------------------------------------------------------------------
-    
+     
     /** Get comments for weblog entry specified by request */
-    public List getComments( WeblogEntryData entry )
-    {
+    public List getComments(WeblogEntryData entry) {
+        return getComments(entry, true, true);
+    }
+        
+    /** Get comments for weblog entry specified by request */
+    public List getComments(WeblogEntryData entry, boolean noSpam, boolean approvedOnly)
{
         List comments = new ArrayList();
-        try
-        {
-            Collection mComments = mWeblogMgr.getComments( entry.getId() );
-            
-            // wrap pojos
-            comments = new ArrayList(mComments.size());
-            Iterator it = mComments.iterator();
-            int i=0;
-            while(it.hasNext()) {
-                comments.add(i, CommentDataWrapper.wrap((CommentData) it.next()));
-                i++;
-            }
-        }
-        catch (RollerException e)
-        {
-            mLogger.error("PageModel getComments()", e);
+        List unwrappped = entry.getComments(noSpam, approvedOnly);
+        comments = new ArrayList(unwrappped.size());
+        Iterator it = unwrappped.iterator();
+        while(it.hasNext()) {
+            comments.add(CommentDataWrapper.wrap((CommentData)it.next()));
         }
         return comments;
     }
@@ -822,24 +814,29 @@
      * for this website, limited to maxCount.  
      * @return List of Comments.
      */
-    public List getRecentComments(int maxCount)
-    {
+    public List getRecentComments(int maxCount) {
         List recentComments = new ArrayList();
-        try
-        {
-            List recent = mWeblogMgr.getRecentComments(mRollerReq.getWebsite(), maxCount);
+        try {
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            List recent = wmgr.getComments(
+                    mWebsite,
+                    null,  // weblog entry
+                    null,  // search String
+                    null,  // startDate
+                    null,  // endDate
+                    null,  // pending
+                    Boolean.TRUE,  // approved only
+                    Boolean.FALSE, // no spam
+                    0,             // offset
+                    maxCount);     // no limit
             
             // wrap pojos
             recentComments = new ArrayList(recent.size());
             Iterator it = recent.iterator();
-            int i=0;
             while(it.hasNext()) {
-                recentComments.add(i, CommentDataWrapper.wrap((CommentData) it.next()));
-                i++;
+                recentComments.add(CommentDataWrapper.wrap((CommentData) it.next()));
             }
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error(e);
         }
         return recentComments;

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java?rev=349597&r1=349596&r2=349597&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
Mon Nov 28 18:50:49 2005
@@ -194,8 +194,6 @@
             EntryAttributeData att = (EntryAttributeData)atts.next();
             attributes.put(att.getName(), att.getValue());
         }
-      
-        populateSpamComments(entry);
     }
     
     public Map getAttributes()
@@ -203,24 +201,6 @@
         return attributes;
     }
     
-    /**
-     * Populate the spamComments array for this entry.
-     * @param entry
-     */
-    private void populateSpamComments(WeblogEntryData entry)
-    {
-        ArrayList spamList = new ArrayList();
-        Iterator it = entry.getComments(false).iterator();
-        while (it.hasNext()) {
-            CommentData comment = (CommentData)it.next();
-            if (comment.getSpam().booleanValue())
-            {
-                spamList.add(comment.getId());
-            }
-        }
-        spamComments = (String[])spamList.toArray(new String[spamList.size()]);
-    }
-
     /**
      * Localize the PubTime date string.
      * @param locale

Modified: incubator/roller/trunk/web/WEB-INF/classes/comments.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/WEB-INF/classes/comments.vm?rev=349597&r1=349596&r2=349597&view=diff
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/comments.vm (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/comments.vm Mon Nov 28 18:50:49 2005
@@ -97,23 +97,24 @@
         <div class="comments-head">$text.get( "macro.weblog.preview" ):</div>
     #else
         <div class="comments-head">$text.get( "macro.weblog.comments" ):</div>
-        #set( $comments = $entry.comments )
+        #set($comments = $pageModel.getComments($entry, true))
     #end
     <br/>
     #foreach( $comment in $comments )
-        #set($content = $utilities.encodeEmail($comment.content))
-        #if($escapeHtml)
-            #set($content = $utilities.escapeHTML($content))
+        #if( $comment.approved )
+            #set($content = $utilities.encodeEmail($comment.content))
+            #if($escapeHtml)
+                #set($content = $utilities.escapeHTML($content))
+            #end
+            #if($autoformat)
+                #set($content = $utilities.autoformat($content))
+            #end
+            #set($content = $utilities.addNofollow($content))
+            <div class="comment" id="comment${velocityCount}">
+                ${content}
+                #showCommentDetails($comment true)
+            </div>
         #end
-        #if($autoformat)
-            #set($content = $utilities.autoformat($content))
-        #end
-        #set($content = $utilities.addNofollow($content))
-        <div class="comment" id="comment${velocityCount}">
-        ${content}
-
-        #showCommentDetails($comment true)
-        </div>
     #end
     </div>
 #end



Mime
View raw message