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-94f89814c4df
Former-commit-id: 8fca027292
pull/2/head
parent
85029d3488
commit
54fcad3551
|
|
@ -172,9 +172,27 @@ public class Themes implements Serializable {
|
|||
}
|
||||
|
||||
final ThemeProvider provider = forTheme.get();
|
||||
return provider.getThemeFileAsStream(theme.getName(),
|
||||
theme.getVersion(),
|
||||
path);
|
||||
final Optional<InputStream> result = provider
|
||||
.getThemeFileAsStream(theme.getName(), theme.getVersion(), 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.StructuredQName;
|
||||
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.StringValue;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.theming.ProcessesThemes;
|
||||
import org.libreccm.theming.Themes;
|
||||
import org.libreccm.theming.manifest.ThemeTemplate;
|
||||
import org.libreccm.theming.utils.SettingsUtils;
|
||||
import org.libreccm.theming.utils.SystemInfoUtils;
|
||||
|
|
@ -107,6 +106,9 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
|||
@Inject
|
||||
private TextUtils textUtils;
|
||||
|
||||
@Inject
|
||||
private Themes themes;
|
||||
|
||||
@Override
|
||||
public String process(final Map<String, Object> page,
|
||||
final ThemeInfo theme,
|
||||
|
|
@ -170,9 +172,17 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
|||
pathToTemplate = theme.getManifest().getDefaultTemplate();
|
||||
}
|
||||
|
||||
final InputStream xslFileInputStream = themeProvider
|
||||
.getThemeFileAsStream(theme.getName(),
|
||||
theme.getVersion(),
|
||||
// final InputStream xslFileInputStream = themeProvider
|
||||
// .getThemeFileAsStream(theme.getName(),
|
||||
// theme.getVersion(),
|
||||
// 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
|
||||
.format("Failed to open XSL file \"%s\" from theme \"%s\" for "
|
||||
|
|
|
|||
Loading…
Reference in New Issue