Fix fallback chain
Engine: default in info.txt will now lead to the template to use template/default as fallback before the default-template (2k11 currently). An approach to fix #130 Also, template_engine is not automatically set to default, as this was implicitly always the case
This commit is contained in:
parent
4efba7e295
commit
99c1f4c87c
@ -71,7 +71,12 @@ if ($serendipity['GET']['adminAction'] == 'install' ) {
|
||||
serendipity_plugin_api::hook_event('backend_templates_install', $serendipity['GET']['theme'], $themeInfo);
|
||||
|
||||
serendipity_set_config_var('template', htmlspecialchars($serendipity['GET']['theme']));
|
||||
serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default');
|
||||
|
||||
// template_engine was set by default to default, which screws up the fallback chain (to the default-template first)
|
||||
serendipity_set_config_var('template_engine', null);
|
||||
if ($themeInfo['engine']) {
|
||||
serendipity_set_config_var('template_engine', $themeInfo['engine']);
|
||||
}
|
||||
serendipity_set_config_var('last_template_change', time());
|
||||
|
||||
$data["adminAction"] = "install";
|
||||
|
@ -88,7 +88,6 @@ function serendipity_remove_config_var($name, $authorid = 0) {
|
||||
* @param string The name of the configuration value
|
||||
* @param string The value of the configuration item
|
||||
* @param int The ID of the owner of the config value (0: global)
|
||||
* @return null
|
||||
*/
|
||||
function serendipity_set_config_var($name, $val, $authorid = 0) {
|
||||
global $serendipity;
|
||||
@ -263,11 +262,11 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') {
|
||||
$directories = array();
|
||||
|
||||
$directories[] = isset($serendipity['template']) ? $serendipity['template'] . '/' : '';
|
||||
if (isset($serendipity['template_engine']) && (stristr($file, 'admin/') === false || $serendipity['template_engine'] != 'default')) {
|
||||
$p = explode(',', $serendipity['template_engine']);
|
||||
foreach($p AS $te) {
|
||||
$directories[] = trim($te) . '/';
|
||||
}
|
||||
if (isset($serendipity['template_engine'])) {
|
||||
$p = explode(',', $serendipity['template_engine']);
|
||||
foreach($p AS $te) {
|
||||
$directories[] = trim($te) . '/';
|
||||
}
|
||||
}
|
||||
|
||||
$directories[] = $serendipity['defaultTemplate'] .'/';
|
||||
|
@ -117,33 +117,24 @@ class Serendipity_Smarty extends Smarty
|
||||
Set all directory setters
|
||||
Smarty will always use the first template found in order of the given array. Move the least significant directory to the end.
|
||||
*/
|
||||
|
||||
// initiate templateDir setter
|
||||
$this->setTemplateDir(array(S9Y_TEMPLATE_USERDEFAULT));
|
||||
|
||||
// set addTemplate array with the blogs used template anyway
|
||||
$serendipity['addTemplateDir'] = array($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['defaultTemplate']);
|
||||
/*
|
||||
Note: Ian
|
||||
BEWARE: Bulletproof and default template do not have any engine settings, so the next will be empty. This is why adding defaultTemplate was necessary.
|
||||
*/
|
||||
// merge engine only templates to addTemplate array
|
||||
$p = explode(',', $serendipity['template_engine']);
|
||||
foreach($p AS $te) {
|
||||
$serendipity['addTemplateDir'][] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $te;
|
||||
}
|
||||
$template_engine = serendipity_get_config_var('template_engine');
|
||||
$template_dirs = array();
|
||||
if ($template_engine) {
|
||||
$template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $template_engine;
|
||||
}
|
||||
$template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['defaultTemplate'];
|
||||
// add secure dir to template path, in case engine did have entries
|
||||
$serendipity['addTemplateDir'][] = S9Y_TEMPLATE_SECUREDIR;
|
||||
// disable plugin dir as added template dir is not adviced, if set security is enabled (backend & frontend need access to fetch plugin templates)
|
||||
$serendipity['addTemplateDir'][] = $serendipity['serendipityPath'] . 'plugins';
|
||||
// add default template to addTemplate array, if not already set in engine
|
||||
$serendipity['addTemplateDir'][] = S9Y_TEMPLATE_FALLBACK;
|
||||
if (S9Y_TEMPLATE_SECUREDIR != $serendipity['serendipityPath'] . $serendipity['templatePath']) {
|
||||
$template_dirs[] = S9Y_TEMPLATE_SECUREDIR;
|
||||
}
|
||||
|
||||
// expand smarty objects (add)TemplateDir setter with $serendipity['addTemplateDir'] as is
|
||||
$this->addTemplateDir($serendipity['addTemplateDir']);
|
||||
|
||||
// setTemplateDir again to unified getTemplateDir() to avoid doubles for (engine, default and main templates)
|
||||
$this->setTemplateDir(array_values(array_unique($this->getTemplateDir()))); // reset keys to be unique
|
||||
// disable plugin dir as added template dir is not adviced, if set security is enabled (backend & frontend need access to fetch plugin templates)
|
||||
$template_dirs[] = $serendipity['serendipityPath'] . 'plugins';
|
||||
// add default template to addTemplate array, if not already set in engine
|
||||
$template_dirs[] = S9Y_TEMPLATE_FALLBACK;
|
||||
|
||||
$this->setTemplateDir($template_dirs);
|
||||
|
||||
$this->setCompileDir($serendipity['serendipityPath'] . PATH_SMARTY_COMPILE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user