1 43 package net.jforum.util.rss; 44 45 import java.util.Iterator ; 46 import java.util.List ; 47 48 import net.jforum.entities.Post; 49 import net.jforum.util.preferences.ConfigKeys; 50 import net.jforum.util.preferences.SystemGlobals; 51 import net.jforum.view.forum.common.PostCommon; 52 import net.jforum.view.forum.common.ViewCommon; 53 54 60 public class UserPostsRSS extends GenericRSS 61 { 62 private List posts; 63 protected RSS rss; 64 protected String forumLink; 65 66 public UserPostsRSS(String title, String description, int userId, List posts) 67 { 68 this.forumLink = ViewCommon.getForumLink(); 69 70 this.posts = posts; 71 this.rss = new RSS(title, description, 72 SystemGlobals.getValue(ConfigKeys.ENCODING), 73 this.forumLink + "posts/listByUser/" + userId 74 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION)); 75 this.prepareRSS(); 76 } 77 78 private void prepareRSS() 79 { 80 for (Iterator iter = this.posts.iterator(); iter.hasNext(); ) { 81 Post p = (Post)iter.next(); 82 83 RSSItem item = new RSSItem(); 84 item.setAuthor(p.getPostUsername()); 85 item.setContentType(RSSAware.CONTENT_HTML); 86 item.setDescription(PostCommon.processText(p.getText())); 87 item.setPublishDate(RSSUtils.formatDate(p.getTime())); 88 item.setTitle(p.getSubject()); 89 item.setLink(this.forumLink 90 + "posts/preList/" + p.getTopicId() 91 + "/" + p.getId() 92 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION) 93 + "#" + p.getId()); 94 95 this.rss.addItem(item); 96 } 97 98 super.setRSS(this.rss); 99 } 100 } 101 | Popular Tags |