1
22
23 package com.liferay.portlet.wiki.engines.jspwiki;
24
25 import com.ecyrd.jspwiki.WikiContext;
26 import com.ecyrd.jspwiki.url.URLConstructor;
27
28 import com.liferay.portal.kernel.util.HttpUtil;
29 import com.liferay.portal.kernel.util.StringPool;
30 import com.liferay.portal.kernel.util.Validator;
31
32 import java.io.IOException;
33
34 import java.util.Properties;
35
36 import javax.servlet.http.HttpServletRequest;
37
38
44 public class LiferayURLConstructor implements URLConstructor {
45
46 public String getForwardPage(HttpServletRequest req) {
47 return "Wiki.jsp";
48 }
49
50 public void initialize(
51 com.ecyrd.jspwiki.WikiEngine engine, Properties props) {
52 }
53
54 public String makeURL(
55 String context, String name, boolean absolute, String parameters) {
56
57 if (Validator.isNotNull(parameters)) {
58 if (context.equals(WikiContext.ATTACH)) {
59 parameters = StringPool.QUESTION + parameters;
60 }
61 else if (context.equals(WikiContext.NONE)) {
62 if (name.indexOf(StringPool.QUESTION) != -1) {
63 parameters = "&" + parameters;
64 }
65 else {
66 parameters = StringPool.QUESTION + parameters;
67 }
68 }
69 else {
70 parameters = "&" + parameters;
71 }
72 }
73 else {
74 parameters = StringPool.BLANK;
75 }
76
77 String path;
78
79 if (context.equals(WikiContext.EDIT)) {
80 path =
81 "[$BEGIN_PAGE_TITLE_EDIT$]" + name + "[$END_PAGE_TITLE_EDIT$]";
82 }
83 else if (context.equals(WikiContext.VIEW)) {
84 path = "[$BEGIN_PAGE_TITLE$]" + name + "[$END_PAGE_TITLE$]";
85 }
86 else if (context.equals(WikiContext.ATTACH)) {
87 if (name.indexOf(StringPool.SLASH) == -1) {
88 path =
89 "[$ATTACHMENT_URL_PREFIX$][$WIKI_PAGE_NAME$]/" +
90 HttpUtil.encodeURL(name);
91 }
92 else {
93 path = "[$ATTACHMENT_URL_PREFIX$]" + HttpUtil.encodeURL(name);
94 }
95 }
96 else {
97 path = name;
98 }
99
100 return path + parameters;
101 }
102
103 public String parsePage(
104 String context, HttpServletRequest req, String encoding)
105 throws IOException {
106
107 return "Wiki.jsp";
108 }
109
110 }