CCM NG: Load files from a theme from the master theme if the child theme does not have the file
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5222 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
3cfb48f938
commit
978aee6088
|
|
@ -172,9 +172,27 @@ public class Themes implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
final ThemeProvider provider = forTheme.get();
|
final ThemeProvider provider = forTheme.get();
|
||||||
return provider.getThemeFileAsStream(theme.getName(),
|
final Optional<InputStream> result = provider
|
||||||
theme.getVersion(),
|
.getThemeFileAsStream(theme.getName(), theme.getVersion(), path);
|
||||||
path);
|
|
||||||
|
if (result.isPresent()) {
|
||||||
|
return result;
|
||||||
|
} else if (theme.getManifest().getMasterTheme() == null
|
||||||
|
|| theme.getManifest().getMasterTheme().isEmpty()
|
||||||
|
|| theme.getManifest().getMasterTheme().matches("\\s*")) {
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
final Optional<ThemeInfo> masterTheme = getTheme(
|
||||||
|
theme.getManifest().getMasterTheme(),
|
||||||
|
theme.getVersion());
|
||||||
|
|
||||||
|
if (masterTheme.isPresent()) {
|
||||||
|
return getFileFromTheme(masterTheme.get(), path);
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,12 @@ import net.sf.saxon.om.Item;
|
||||||
import net.sf.saxon.om.Sequence;
|
import net.sf.saxon.om.Sequence;
|
||||||
import net.sf.saxon.om.StructuredQName;
|
import net.sf.saxon.om.StructuredQName;
|
||||||
import net.sf.saxon.trans.XPathException;
|
import net.sf.saxon.trans.XPathException;
|
||||||
import net.sf.saxon.value.Int64Value;
|
|
||||||
import net.sf.saxon.value.IntegerValue;
|
|
||||||
import net.sf.saxon.value.SequenceType;
|
import net.sf.saxon.value.SequenceType;
|
||||||
import net.sf.saxon.value.StringValue;
|
import net.sf.saxon.value.StringValue;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.theming.ProcessesThemes;
|
import org.libreccm.theming.ProcessesThemes;
|
||||||
|
import org.libreccm.theming.Themes;
|
||||||
import org.libreccm.theming.manifest.ThemeTemplate;
|
import org.libreccm.theming.manifest.ThemeTemplate;
|
||||||
import org.libreccm.theming.utils.SettingsUtils;
|
import org.libreccm.theming.utils.SettingsUtils;
|
||||||
import org.libreccm.theming.utils.SystemInfoUtils;
|
import org.libreccm.theming.utils.SystemInfoUtils;
|
||||||
|
|
@ -107,6 +106,9 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
@Inject
|
@Inject
|
||||||
private TextUtils textUtils;
|
private TextUtils textUtils;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Themes themes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String process(final Map<String, Object> page,
|
public String process(final Map<String, Object> page,
|
||||||
final ThemeInfo theme,
|
final ThemeInfo theme,
|
||||||
|
|
@ -170,10 +172,18 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
pathToTemplate = theme.getManifest().getDefaultTemplate();
|
pathToTemplate = theme.getManifest().getDefaultTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
final InputStream xslFileInputStream = themeProvider
|
// final InputStream xslFileInputStream = themeProvider
|
||||||
.getThemeFileAsStream(theme.getName(),
|
// .getThemeFileAsStream(theme.getName(),
|
||||||
theme.getVersion(),
|
// theme.getVersion(),
|
||||||
pathToTemplate)
|
// pathToTemplate)
|
||||||
|
// .orElseThrow(() -> new UnexpectedErrorException(String
|
||||||
|
// .format("Failed to open XSL file \"%s\" from theme \"%s\" for "
|
||||||
|
// + "reading.",
|
||||||
|
// pathToTemplate,
|
||||||
|
// theme.getName())));
|
||||||
|
final InputStream xslFileInputStream = themes
|
||||||
|
.getFileFromTheme(theme,
|
||||||
|
pathToTemplate)
|
||||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||||
.format("Failed to open XSL file \"%s\" from theme \"%s\" for "
|
.format("Failed to open XSL file \"%s\" from theme \"%s\" for "
|
||||||
+ "reading.",
|
+ "reading.",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue