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