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.util.Properties;
33
34 import javax.servlet.http.HttpServletRequest;
35
36
42 public class LiferayURLConstructor implements URLConstructor {
43
44 public String getForwardPage(HttpServletRequest request) {
45 return "Wiki.jsp";
46 }
47
48 public void initialize(
49 com.ecyrd.jspwiki.WikiEngine engine, Properties props) {
50 }
51
52 public String makeURL(
53 String context, String name, boolean absolute, String parameters) {
54
55 if (Validator.isNotNull(parameters)) {
56 if (context.equals(WikiContext.ATTACH)) {
57 parameters = StringPool.QUESTION + parameters;
58 }
59 else if (context.equals(WikiContext.NONE)) {
60 if (name.indexOf(StringPool.QUESTION) != -1) {
61 parameters = "&" + parameters;
62 }
63 else {
64 parameters = StringPool.QUESTION + parameters;
65 }
66 }
67 else {
68 parameters = "&" + parameters;
69 }
70 }
71 else {
72 parameters = StringPool.BLANK;
73 }
74
75 String path;
76
77 if (context.equals(WikiContext.EDIT)) {
78 path =
79 "[$BEGIN_PAGE_TITLE_EDIT$]" + name + "[$END_PAGE_TITLE_EDIT$]";
80 }
81 else if (context.equals(WikiContext.VIEW)) {
82 path = "[$BEGIN_PAGE_TITLE$]" + name + "[$END_PAGE_TITLE$]";
83 }
84 else if (context.equals(WikiContext.ATTACH)) {
85 if (name.indexOf(StringPool.SLASH) == -1) {
86 path =
87 "[$ATTACHMENT_URL_PREFIX$][$WIKI_PAGE_NAME$]/" +
88 HttpUtil.encodeURL(name);
89 }
90 else {
91 path = "[$ATTACHMENT_URL_PREFIX$]" + HttpUtil.encodeURL(name);
92 }
93 }
94 else {
95 path = name;
96 }
97
98 return path + parameters;
99 }
100
101 public String parsePage(
102 String context, HttpServletRequest request, String encoding) {
103
104 return "Wiki.jsp";
105 }
106
107 }