001
014
015 package com.liferay.portlet.wiki.engines.jspwiki;
016
017 import com.ecyrd.jspwiki.WikiContext;
018 import com.ecyrd.jspwiki.url.URLConstructor;
019
020 import com.liferay.portal.kernel.util.HttpUtil;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.util.Validator;
023
024 import java.util.Properties;
025
026 import javax.servlet.http.HttpServletRequest;
027
028
031 public class LiferayURLConstructor implements URLConstructor {
032
033 public String getForwardPage(HttpServletRequest request) {
034 return "Wiki.jsp";
035 }
036
037 public void initialize(
038 com.ecyrd.jspwiki.WikiEngine engine, Properties props) {
039 }
040
041 public String makeURL(
042 String context, String name, boolean absolute, String parameters) {
043
044 if (Validator.isNotNull(parameters)) {
045 if (context.equals(WikiContext.ATTACH)) {
046 parameters = StringPool.QUESTION + parameters;
047 }
048 else if (context.equals(WikiContext.NONE)) {
049 if (name.indexOf(StringPool.QUESTION) != -1) {
050 parameters = "&" + parameters;
051 }
052 else {
053 parameters = StringPool.QUESTION + parameters;
054 }
055 }
056 else {
057 parameters = "&" + parameters;
058 }
059 }
060 else {
061 parameters = StringPool.BLANK;
062 }
063
064 String path;
065
066 if (context.equals(WikiContext.EDIT)) {
067 path =
068 "[$BEGIN_PAGE_TITLE_EDIT$]" + name + "[$END_PAGE_TITLE_EDIT$]";
069 }
070 else if (context.equals(WikiContext.VIEW)) {
071 path = "[$BEGIN_PAGE_TITLE$]" + name + "[$END_PAGE_TITLE$]";
072 }
073 else if (context.equals(WikiContext.ATTACH)) {
074 if (name.indexOf(StringPool.SLASH) == -1) {
075 path =
076 "[$ATTACHMENT_URL_PREFIX$][$WIKI_PAGE_NAME$]/" +
077 HttpUtil.encodeURL(name);
078 }
079 else {
080 path = "[$ATTACHMENT_URL_PREFIX$]" + HttpUtil.encodeURL(name);
081 }
082 }
083 else {
084 path = name;
085 }
086
087 return path + parameters;
088 }
089
090 public String parsePage(
091 String context, HttpServletRequest request, String encoding) {
092
093 return "Wiki.jsp";
094 }
095
096 }