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 TopicPostsRSS extends GenericRSS 61 { 62 private List posts; 63 protected RSS rss; 64 protected String forumLink; 65 66 public TopicPostsRSS(String title, String description, int topicId, 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/list/" + topicId 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/list/" + p.getTopicId() 91 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION) 92 + "#" + p.getId()); 93 94 this.rss.addItem(item); 95 } 96 97 super.setRSS(this.rss); 98 } 99 } 100 | Popular Tags |