01: package ru.emdev.EmForge.wiki.web.bean;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05:
06: import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
07:
08: import com.ecyrd.jspwiki.WikiException;
09: import com.ecyrd.jspwiki.plugin.WeblogEntryPlugin;
10:
11: /** Controller for News page
12: *
13: * @author spopov
14: *
15: */
16: public class NewsController extends BaseWikiControllerImpl {
17: protected final Log logger = LogFactory.getLog(getClass());
18:
19: private final String STR_NEWS = "News";
20:
21: @Override
22: protected void init() {
23: setPageName(STR_NEWS);
24: try {
25: if (!isPageExists()) {
26: createNewWikiPage(STR_NEWS, getNewsScript());
27: }
28: } catch (WikiException e) {
29: logger.error("NewsController cannot be initialized: ", e);
30: return;
31: }
32: }
33:
34: @Override
35: public String getTitleImpl() {
36: return STR_NEWS;
37: }
38:
39: @Override
40: public Crumb getTrailCrumbInfo() {
41: return new Crumb(STR_NEWS, "news");
42: }
43:
44: /**
45: * @see ru.emdev.EmForge.web.bean.BaseControllerImpl#getSelectionItemOnMainMenu()
46: */
47: @Override
48: public MainMenuItem getSelectionItemOnMainMenu() {
49: return MainMenuItem.NEWS;
50: }
51:
52: private String getNewsScript() {
53: String result = "!!! Project News\n"
54: + "[{INSERT WeblogPlugin}]";
55: return result;
56: }
57:
58: public boolean isCanAddEntry() {
59: return isCanEditPage();
60: }
61:
62: public String addNewEntry() throws Exception {
63: WeblogEntryPlugin weblogPlugin = new WeblogEntryPlugin();
64: String newEntryPage = weblogPlugin.getNewEntryPage(
65: m_wikiEngine, "News");
66:
67: // navigate to this page
68: redirect("edit/" + newEntryPage);
69: return null;
70: }
71:
72: }
|