String themeLocation = (String) builtInThemes.get(themeName);
if (themeLocation == null) {
log.debug("Unknown theme name '" + themeName + "' specified.");
}
AddResource addResource = AddResourceFactory.getInstance(context);
if ((imageLocation != null) || (themeLocation != null)) {
// Generate a javascript variable containing a reference to the
// directory containing theme image files, for use by the theme
// javascript file. If neither of these is defined (ie a custom
// theme was specified but no imageLocation) then presumably the
// theme.js file uses some other mechanism to determine where
// its image files are.
StringBuffer buf = new StringBuffer();
buf.append("var my");
buf.append(themeName);
buf.append("Base='");
ExternalContext externalContext = context.getExternalContext();
if (imageLocation != null) {
buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
imageLocation + "/" + themeName)));
}
else {
buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
HtmlJSCookMenuRenderer.class, themeLocation)));
}
buf.append("';");
addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, buf.toString());
}
if ((javascriptLocation != null) || (themeLocation != null)) {
// Generate a <script> tag in the page header pointing to the
// theme.js file for this theme. If neither of these is defined
// then presumably the theme.js file is referenced by a <script>
// tag hard-wired into the page or inserted via some other means.
if (javascriptLocation != null) {
// For now, assume that if the user specified a location for a custom
// version of the jscookMenu.js file then the theme.js file can be found
// in the same location.
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + themeName
+ "/theme.js");
}
else {
// Using a built-in theme, so we know where the theme.js file is.
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, themeName
+ "/theme.js");
}
}
if ((styleLocation != null) || (themeLocation != null)) {
// Generate a <link type="text/css"> tag in the page header pointing to
// the theme stylesheet. If neither of these is defined then presumably
// the stylesheet is referenced by a <link> tag hard-wired into the page
// or inserted via some other means.
if (styleLocation != null) {
addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/" + themeName + "/theme.css");
}
else {
addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, themeName
+ "/theme.css");
}
}
}