EventPropertiesStep
Formatter angepaßt, so daß nun auch die Zeitzone berücksichtigt wird git-svn-id: https://svn.libreccm.org/ccm/trunk@741 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a3e451f01a
commit
48b8c77d0e
|
|
@ -111,7 +111,8 @@ public class EventPropertiesStep extends SimpleEditStep {
|
||||||
if (e.getStartTime() == null) {
|
if (e.getStartTime() == null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getStartDate());
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getStartDate());
|
||||||
} else {
|
} else {
|
||||||
Date startDateTime = new Date(e.getStartDate().getTime() + e.getStartTime().getTime());
|
int timezoneOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar.getInstance().get(Calendar.DST_OFFSET) / (60 * 1000);
|
||||||
|
Date startDateTime = new Date(e.getStartDate().getTime() + e.getStartTime().getTime() + timezoneOffset);
|
||||||
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(startDateTime);
|
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(startDateTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +135,8 @@ public class EventPropertiesStep extends SimpleEditStep {
|
||||||
if (e.getEndTime() == null) {
|
if (e.getEndTime() == null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getEndDate());
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getEndDate());
|
||||||
} else {
|
} else {
|
||||||
Date endDateTime = new Date(e.getEndDate().getTime() + e.getEndTime().getTime());
|
int timezoneOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar.getInstance().get(Calendar.DST_OFFSET) / (60 * 1000);
|
||||||
|
Date endDateTime = new Date(e.getEndDate().getTime() + e.getEndTime().getTime() + timezoneOffset);
|
||||||
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(endDateTime);
|
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(endDateTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,103 +77,98 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class PageTransformer implements PresentationManager {
|
public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger(PageTransformer.class);
|
||||||
(PageTransformer.class);
|
|
||||||
|
|
||||||
// this keeps track of all of the XSLParameters that can be added to
|
// this keeps track of all of the XSLParameters that can be added to
|
||||||
// stylesheets
|
// stylesheets
|
||||||
private static final HashMap s_XSLParameters = new HashMap();
|
private static final HashMap s_XSLParameters = new HashMap();
|
||||||
|
|
||||||
|
|
||||||
// load the default xsl parameter generators
|
// load the default xsl parameter generators
|
||||||
static {
|
static {
|
||||||
registerXSLParameterGenerator
|
registerXSLParameterGenerator("contextPath",
|
||||||
("contextPath",
|
new XSLParameterGenerator() {
|
||||||
new XSLParameterGenerator() {
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
|
||||||
return request.getContextPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
public String generateValue(HttpServletRequest request) {
|
||||||
("root-context-prefix",
|
return request.getContextPath();
|
||||||
new XSLParameterGenerator() {
|
}
|
||||||
public String generateValue(HttpServletRequest request) {
|
});
|
||||||
return Web.getConfig().getDispatcherContextPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
registerXSLParameterGenerator("root-context-prefix",
|
||||||
("context-prefix",
|
new XSLParameterGenerator() {
|
||||||
new XSLParameterGenerator() {
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
|
||||||
return Web.getContext().getRequestURL().getContextPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
public String generateValue(HttpServletRequest request) {
|
||||||
("static-prefix",
|
return Web.getConfig().getDispatcherContextPath();
|
||||||
new XSLParameterGenerator() {
|
}
|
||||||
public String generateValue(HttpServletRequest request) {
|
});
|
||||||
return Web.getContext().getRequestURL().getContextPath() +
|
|
||||||
com.arsdigita.web.URL.STATIC_DIR;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
registerXSLParameterGenerator("context-prefix",
|
||||||
("dispatcher-prefix",
|
new XSLParameterGenerator() {
|
||||||
new XSLParameterGenerator() {
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
|
||||||
return com.arsdigita.web.URL.getDispatcherPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
public String generateValue(HttpServletRequest request) {
|
||||||
("dcp-on-buttons",
|
return Web.getContext().getRequestURL().getContextPath();
|
||||||
new XSLParameterGenerator() {
|
}
|
||||||
public String generateValue(HttpServletRequest request) {
|
});
|
||||||
if (Bebop.getConfig().doubleClickProtectionOnButtons()) {
|
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
|
||||||
("dcp-on-links",
|
|
||||||
new XSLParameterGenerator() {
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
|
||||||
if (Bebop.getConfig().doubleClickProtectionOnLinks()) {
|
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
registerXSLParameterGenerator("static-prefix",
|
||||||
("user-agent",
|
new XSLParameterGenerator() {
|
||||||
new XSLParameterGenerator() {
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
|
||||||
return request.getHeader("User-Agent");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerXSLParameterGenerator
|
public String generateValue(HttpServletRequest request) {
|
||||||
("negotiated-language",
|
return Web.getContext().getRequestURL().getContextPath()
|
||||||
new XSLParameterGenerator() {
|
+ com.arsdigita.web.URL.STATIC_DIR;
|
||||||
public String generateValue(HttpServletRequest request) {
|
}
|
||||||
return DispatcherHelper.getNegotiatedLocale().getLanguage();
|
});
|
||||||
}
|
|
||||||
});
|
registerXSLParameterGenerator("dispatcher-prefix",
|
||||||
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
|
public String generateValue(HttpServletRequest request) {
|
||||||
|
return com.arsdigita.web.URL.getDispatcherPath();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerXSLParameterGenerator("dcp-on-buttons",
|
||||||
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
|
public String generateValue(HttpServletRequest request) {
|
||||||
|
if (Bebop.getConfig().doubleClickProtectionOnButtons()) {
|
||||||
|
return "true";
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerXSLParameterGenerator("dcp-on-links",
|
||||||
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
|
public String generateValue(HttpServletRequest request) {
|
||||||
|
if (Bebop.getConfig().doubleClickProtectionOnLinks()) {
|
||||||
|
return "true";
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerXSLParameterGenerator("user-agent",
|
||||||
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
|
public String generateValue(HttpServletRequest request) {
|
||||||
|
return request.getHeader("User-Agent");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerXSLParameterGenerator("negotiated-language",
|
||||||
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
|
public String generateValue(HttpServletRequest request) {
|
||||||
|
return DispatcherHelper.getNegotiatedLocale().getLanguage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX These need to move somewhere else.
|
// XXX These need to move somewhere else.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used to indicate that all xsl templates used should
|
* This is used to indicate that all xsl templates used should
|
||||||
* be pulled from the disk and not from the cache. If this
|
* be pulled from the disk and not from the cache. If this
|
||||||
|
|
@ -181,7 +176,6 @@ public class PageTransformer implements PresentationManager {
|
||||||
* all XSL Stylesheets are pulled from the disk, not the cache
|
* all XSL Stylesheets are pulled from the disk, not the cache
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_XSL_NONE = "cacheXSLNone";
|
public static final String CACHE_XSL_NONE = "cacheXSLNone";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used to indicate that the "fancy errors" should be
|
* This is used to indicate that the "fancy errors" should be
|
||||||
* used and that the errors should be placed in the request
|
* used and that the errors should be placed in the request
|
||||||
|
|
@ -189,28 +183,22 @@ public class PageTransformer implements PresentationManager {
|
||||||
* with this name in the request with the value of Boolean.TRUE
|
* with this name in the request with the value of Boolean.TRUE
|
||||||
*/
|
*/
|
||||||
public static final String FANCY_ERRORS = "fancyErrors";
|
public static final String FANCY_ERRORS = "fancyErrors";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State flag for preventing caching in every case.
|
* State flag for preventing caching in every case.
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_NONE = "none";
|
public static final String CACHE_NONE = "none";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State flag for per-user caching.
|
* State flag for per-user caching.
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_USER = "user";
|
public static final String CACHE_USER = "user";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State flag for enabling caching in every case.
|
* State flag for enabling caching in every case.
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_WORLD = "world";
|
public static final String CACHE_WORLD = "world";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State flag for disabling HTTP header caching.
|
* State flag for disabling HTTP header caching.
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_DISABLE = "disable";
|
public static final String CACHE_DISABLE = "disable";
|
||||||
|
|
||||||
private static String s_defaultCachePolicy = CACHE_DISABLE;
|
private static String s_defaultCachePolicy = CACHE_DISABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -228,8 +216,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
* Sets the content type of the response and then gets the PrintWriter
|
* Sets the content type of the response and then gets the PrintWriter
|
||||||
*/
|
*/
|
||||||
private PrintWriter getWriter(final HttpServletResponse resp,
|
private PrintWriter getWriter(final HttpServletResponse resp,
|
||||||
final String contentType,
|
final String contentType,
|
||||||
final String charset) {
|
final String charset) {
|
||||||
Assert.exists(contentType);
|
Assert.exists(contentType);
|
||||||
Assert.exists(charset);
|
Assert.exists(charset);
|
||||||
|
|
||||||
|
|
@ -241,9 +229,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
s_log.warn("Using getOutputStream instead of getWriter");
|
s_log.warn("Using getOutputStream instead of getWriter");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new PrintWriter
|
return new PrintWriter(new OutputStreamWriter(resp.getOutputStream(),
|
||||||
(new OutputStreamWriter(resp.getOutputStream(),
|
charset));
|
||||||
charset));
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -258,8 +245,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
* <code>PresentationManager</code> interface.
|
* <code>PresentationManager</code> interface.
|
||||||
*/
|
*/
|
||||||
public void servePage(final Document doc,
|
public void servePage(final Document doc,
|
||||||
final HttpServletRequest req,
|
final HttpServletRequest req,
|
||||||
final HttpServletResponse resp) {
|
final HttpServletResponse resp) {
|
||||||
servePage(doc, req, resp, null);
|
servePage(doc, req, resp, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,11 +265,11 @@ public class PageTransformer implements PresentationManager {
|
||||||
* to the Transformer
|
* to the Transformer
|
||||||
*/
|
*/
|
||||||
public void servePage(final Document doc,
|
public void servePage(final Document doc,
|
||||||
final HttpServletRequest req,
|
final HttpServletRequest req,
|
||||||
final HttpServletResponse resp,
|
final HttpServletResponse resp,
|
||||||
final Map params) {
|
final Map params) {
|
||||||
if (resp.isCommitted()) {
|
if (resp.isCommitted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Assert.isEnabled()) {
|
if (Assert.isEnabled()) {
|
||||||
Assert.exists(doc, Document.class);
|
Assert.exists(doc, Document.class);
|
||||||
|
|
@ -293,8 +280,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
Profiler.startOp("XSLT");
|
Profiler.startOp("XSLT");
|
||||||
try {
|
try {
|
||||||
final String charset = Globalization.getDefaultCharset(Kernel
|
final String charset = Globalization.getDefaultCharset(Kernel.getContext().getLocale());
|
||||||
.getContext().getLocale());
|
|
||||||
|
|
||||||
final String output = req.getParameter("output");
|
final String output = req.getParameter("output");
|
||||||
s_log.info("output=" + output);
|
s_log.info("output=" + output);
|
||||||
|
|
@ -308,8 +294,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
// Get the stylesheet transformer object corresponding to the
|
// Get the stylesheet transformer object corresponding to the
|
||||||
// current request.
|
// current request.
|
||||||
final XSLTemplate template = Templating.getTemplate(req,
|
final XSLTemplate template = Templating.getTemplate(req,
|
||||||
fancyErrors, !Boolean.TRUE.equals(req
|
fancyErrors, !Boolean.TRUE.equals(req.getAttribute(CACHE_XSL_NONE)));
|
||||||
.getAttribute(CACHE_XSL_NONE)));
|
|
||||||
|
|
||||||
DeveloperSupport.endStage("PresMgr get stylesheet");
|
DeveloperSupport.endStage("PresMgr get stylesheet");
|
||||||
|
|
||||||
|
|
@ -337,8 +322,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
final Map.Entry entry = (Map.Entry) entries.next();
|
||||||
|
|
||||||
xf.setParameter((String) entry.getKey(), entry
|
xf.setParameter((String) entry.getKey(), entry.getValue());
|
||||||
.getValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,10 +351,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
// copy and paste from BasePresentationManager
|
// copy and paste from BasePresentationManager
|
||||||
if (Kernel.getConfig().isDebugEnabled()) {
|
if (Kernel.getConfig().isDebugEnabled()) {
|
||||||
Document origDoc = (Document) req
|
Document origDoc = (Document) req.getAttribute("com.arsdigita.xml.Document");
|
||||||
.getAttribute("com.arsdigita.xml.Document");
|
Debugger.addDebugger(new TransformationDebugger(template.getSource(), template.getDependents()));
|
||||||
Debugger.addDebugger(new TransformationDebugger(template
|
|
||||||
.getSource(), template.getDependents()));
|
|
||||||
writer.print(Debugger.getDebugging(req));
|
writer.print(Debugger.getDebugging(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,15 +372,10 @@ public class PageTransformer implements PresentationManager {
|
||||||
// Get the stylesheet transformer object corresponding to
|
// Get the stylesheet transformer object corresponding to
|
||||||
// the
|
// the
|
||||||
// current request.
|
// current request.
|
||||||
template = Templating
|
template = Templating.getTemplate(
|
||||||
.getTemplate(
|
req,
|
||||||
req,
|
Boolean.TRUE.equals(req.getAttribute(PageTransformer.FANCY_ERRORS)),
|
||||||
Boolean.TRUE
|
!Boolean.TRUE.equals(req.getAttribute(PageTransformer.CACHE_XSL_NONE)));
|
||||||
.equals(req
|
|
||||||
.getAttribute(PageTransformer.FANCY_ERRORS)),
|
|
||||||
!Boolean.TRUE
|
|
||||||
.equals(req
|
|
||||||
.getAttribute(PageTransformer.CACHE_XSL_NONE)));
|
|
||||||
endTransaction(req);
|
endTransaction(req);
|
||||||
} finally {
|
} finally {
|
||||||
DeveloperSupport.endStage("PresMgr get stylesheet");
|
DeveloperSupport.endStage("PresMgr get stylesheet");
|
||||||
|
|
@ -436,7 +413,6 @@ public class PageTransformer implements PresentationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the current transaction. Is a performance optimization to end ASAP before
|
* Ends the current transaction. Is a performance optimization to end ASAP before
|
||||||
* serving the page.
|
* serving the page.
|
||||||
|
|
@ -458,9 +434,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
* parameter name then all previous calls are overwritten and
|
* parameter name then all previous calls are overwritten and
|
||||||
* only the last registered generator is used.
|
* only the last registered generator is used.
|
||||||
*/
|
*/
|
||||||
public static void registerXSLParameterGenerator
|
public static void registerXSLParameterGenerator(String parameterName,
|
||||||
(String parameterName,
|
XSLParameterGenerator parameterGenerator) {
|
||||||
XSLParameterGenerator parameterGenerator) {
|
|
||||||
s_XSLParameters.put(parameterName, parameterGenerator);
|
s_XSLParameters.put(parameterName, parameterGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,15 +455,14 @@ public class PageTransformer implements PresentationManager {
|
||||||
return s_XSLParameters.keySet();
|
return s_XSLParameters.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This takes a name and request and returns the value that should
|
* This takes a name and request and returns the value that should
|
||||||
* be used in the XSL for the given name
|
* be used in the XSL for the given name
|
||||||
*/
|
*/
|
||||||
public static String getXSLParameterValue(String name,
|
public static String getXSLParameterValue(String name,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
XSLParameterGenerator generator =
|
XSLParameterGenerator generator =
|
||||||
(XSLParameterGenerator)s_XSLParameters.get(name);
|
(XSLParameterGenerator) s_XSLParameters.get(name);
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
return generator.generateValue(request);
|
return generator.generateValue(request);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -500,20 +474,19 @@ public class PageTransformer implements PresentationManager {
|
||||||
* This takes in a transformer and adds all of the registered
|
* This takes in a transformer and adds all of the registered
|
||||||
* xsl paraemters.
|
* xsl paraemters.
|
||||||
*/
|
*/
|
||||||
public static void addXSLParameters(Transformer transformer,
|
public static void addXSLParameters(Transformer transformer,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
final Iterator entries = s_XSLParameters.entrySet().iterator();
|
final Iterator entries = s_XSLParameters.entrySet().iterator();
|
||||||
|
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
final Map.Entry entry = (Map.Entry) entries.next();
|
||||||
|
|
||||||
String value = ((XSLParameterGenerator)entry.getValue())
|
String value = ((XSLParameterGenerator) entry.getValue()).generateValue(request);
|
||||||
.generateValue(request);
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// XSL does not like nulls
|
// XSL does not like nulls
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
transformer.setParameter((String) entry.getKey(), value);
|
transformer.setParameter((String) entry.getKey(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,8 @@ public final class KernelContext {
|
||||||
/**
|
/**
|
||||||
* @return the locale for the current session
|
* @return the locale for the current session
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
/** use {@link DispatcherHelper.getNegotiatedLocale()} instead */
|
||||||
public final Locale getLocale() {
|
public final Locale getLocale() {
|
||||||
return m_locale;
|
return m_locale;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue