1 package net.sourceforge.blogentis.feed;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.util.List;
26 import java.util.Map;
27
28 import net.sourceforge.blogentis.om.PostPeer;
29 import net.sourceforge.blogentis.plugins.BlogPluginService;
30 import net.sourceforge.blogentis.plugins.base.IPostViewExtensionPoint;
31 import net.sourceforge.blogentis.utils.AbsoluteLinkURL;
32 import net.sourceforge.blogentis.utils.BlogPropertyCache;
33 import net.sourceforge.blogentis.utils.PresentationalProperties;
34
35 import org.apache.torque.TorqueException;
36 import org.apache.torque.util.Criteria;
37 import org.apache.turbine.util.RunData;
38
39 /***
40 * @author abas
41 */
42 public class PostFeed
43 extends Feed {
44
45 private static final String[] searchableColumns = {PostPeer.TITLE,
46 PostPeer.SHORT_DESCRIPTION, PostPeer.FULL_TEXT};
47
48 protected PostFeed(RunData data) {
49 super(data);
50
51 }
52
53 public List getItems(Criteria c)
54 throws TorqueException {
55 c.add(PostPeer.POST_TYPE, PostPeer.PUBLISHED_TYPE);
56 return PostPeer.doSelectJoinBlog(c);
57 }
58
59 protected PresentationalProperties getProperties() {
60 if (pp.getSection() != null && pp.getBlog() != null)
61 return BlogPropertyCache.getInstance()
62 .getSectionProperties(pp.getBlog());
63 return BlogPropertyCache.getInstance().getBlogProperties(pp.getBlog());
64 }
65
66 public String[] getSearchColumns() {
67 return searchableColumns;
68 }
69
70 public String getTimeColumn() {
71 return PostPeer.POSTED_TIME;
72 }
73
74 protected void fixFeedDescription(Map m) {
75 AbsoluteLinkURL link = (AbsoluteLinkURL)m.get(FeedModifier.FEED_LINK);
76 if (data.getParameters().getString("all", "-").equals("content")) {
77 link.setTemplate(link.getTemplate() + "/all/content");
78 m.put("blogentis:show-full-content", "1");
79 }
80 m.put(FeedModifier.FEED_LINK, link);
81 if (!m.containsKey(FeedModifier.FEED_TITLE))
82 m.put(FeedModifier.FEED_TITLE, "blogentis aggregate feed");
83 if (!m.containsKey(FeedModifier.FEED_DESCRIPTION))
84 m.put(FeedModifier.FEED_DESCRIPTION, "All posts at "
85 + new AbsoluteLinkURL()
86 .toString());
87 }
88
89 public List getItemsTranslated()
90 throws TorqueException {
91 List l = getItems();
92 IPostViewExtensionPoint pExt = (IPostViewExtensionPoint)BlogPluginService
93 .locateExtensionPoint(data.getBlog(),
94 IPostViewExtensionPoint.class);
95 if (pExt != null)
96 l = pExt.doPostViewExtensions(data, l);
97 return l;
98 }
99 }