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