IDEMPIERE-6085 HTMLExtension doesn't handle HTML_REPORT_THEME that starts with "~./" (#2288)

This commit is contained in:
hengsin 2024-04-09 21:08:20 +08:00 committed by Carlos Ruiz
parent 42fb2de77d
commit 81660c7fc7
2 changed files with 17 additions and 8 deletions

View File

@ -24,17 +24,20 @@ import org.apache.ecs.xhtml.body;
public interface IHTMLExtension {
/**
* @return css class prefix for report element
* Get CSS class prefix for HTML report element
* @return CSS class prefix for HTML report element
*/
public String getClassPrefix();
/**
* @return url to report css
* Get URL to report CSS
* @return URL to report CSS
*/
public String getStyleURL();
/**
* @return url to report js
* Get URL to report javascript
* @return URL to report javascript
*/
public String getScriptURL();
@ -61,11 +64,13 @@ public interface IHTMLExtension {
public void setWebAttribute (body reportBody);
/**
* @return absolute path to css style file
* Get absolute local file path to CSS file (typically for embedding the file content to HTML report)
* @return absolute local file path to CSS file
*/
public String getFullPathStyle ();
/**
* Get one or more links (<link ... >) to web font
* @return one or more links for web font
*/
String getWebFontLinks();

View File

@ -65,14 +65,14 @@ public class HTMLExtension implements IHTMLExtension {
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
if (! theme.startsWith("/") && !theme.startsWith("~./"))
if (!theme.startsWith("/") && !theme.startsWith(ThemeManager.ZK_URL_PREFIX_FOR_CLASSPATH_RESOURCE))
theme = "/" + theme;
if (! theme.endsWith("/"))
theme = theme + "/";
this.classPrefix = classPrefix;
this.componentId = componentId;
if (theme.startsWith("~./")) {
if (theme.startsWith(ThemeManager.ZK_URL_PREFIX_FOR_CLASSPATH_RESOURCE)) {
if (Executions.getCurrent() != null) {
this.styleURL = Executions.encodeURL(theme + "css/report.css");
}
@ -197,12 +197,16 @@ public class HTMLExtension implements IHTMLExtension {
@Override
public String getFullPathStyle() {
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
if (! theme.startsWith("/"))
if (!theme.startsWith("/") && !theme.startsWith(ThemeManager.ZK_URL_PREFIX_FOR_CLASSPATH_RESOURCE))
theme = "/" + theme;
if (!theme.endsWith("/"))
theme = theme + "/";
String resFile = theme + "css/report.css";
// translate ~./ url to classpath url
if (theme.startsWith(ThemeManager.ZK_URL_PREFIX_FOR_CLASSPATH_RESOURCE))
resFile = ThemeManager.toClassPathResourcePath(resFile);
URL urlFile = this.getClass().getResource(resFile);
if (urlFile == null) {
resFile = "/css/report.css"; // default