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