Skip to content

Commit

Permalink
Issue #165 - allow to set configuration of children to their parents …
Browse files Browse the repository at this point in the history
…config, but on their own names.

Global options (navigation) are even carried through so that they use the central part.
This falls back in place rather nicely, I hope it REALLY works. My first tests showed no issues.
  • Loading branch information
garvinhicking committed May 28, 2014
1 parent 71e4a6c commit 1b37e41
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion docs/NEWS
Expand Up @@ -4,6 +4,9 @@
Version 2.0-beta3 ()
------------------------------------------------------------------------

* Themes using Engines are now able to use the parent's
configuration

* Prevent "new" plugin api to install double instances of plugins
that are not stackable (issue #45)

Expand Down Expand Up @@ -49,7 +52,7 @@ Version 2.0-beta3 ()
a backend theme would reference to.

* Changed 2k11's config.inc.php file to provide a more stable
call of event hooks so that other templates can also hook
call of event hooks so that other themes can also hook
their own events.

* Changed JS for category filtering and its reset button to be a
Expand Down
6 changes: 4 additions & 2 deletions include/admin/templates.inc.php
Expand Up @@ -96,11 +96,13 @@ function import(&$config) {

$data["cur_template"] = $serendipity['template'];
$data["cur_template_backend"] = $serendipity['template_backend'];
$data['cur_template_info'] = serendipity_fetchTemplateInfo($serendipity['template']);

if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) {
// NOTE: config.inc.php currently only applies to frontend configuration. Backend configuration is not planned yet, and would preferrably use a "config_backend.inc.php" file!
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $data['cur_template_info']['custom_config_engine'] . '/config.inc.php')) {
serendipity_smarty_init();
$old_template_config_groups = $template_config_groups;
include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php';
include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $data['cur_template_info']['custom_config_engine'] . '/config.inc.php';
// in case of theme switch, check to unset config_group array
if ($serendipity['GET']['adminAction'] == 'install' && $serendipity['GET']['adminModule'] == 'templates') {
// array diff - but do not do this for bulletproof, as this is the only one which needs them in case of reloads (temporary)
Expand Down
16 changes: 16 additions & 0 deletions include/functions.inc.php
Expand Up @@ -260,6 +260,22 @@ function serendipity_fetchTemplateInfo($theme, $abspath = null) {

if (@is_file($serendipity['templatePath'] . $theme . '/config.inc.php')) {
$data['custom_config'] = YES;
$data['custom_config_engine'] = $theme;
}

// Templates can depend on a possible "Engine" (i.e. "Engine: 2k11").
// We support the fallback chain also of a template's configuration, so let's check each engine for a config file.
if (!empty($data['engine'])) {
$engines = explode(',', $data['engine']);
foreach($engines AS $engine) {
$engine = trim($engine);
if (empty($engine)) continue;

if (@is_file($serendipity['templatePath'] . $engine . '/config.inc.php')) {
$data['custom_config'] = YES;
$data['custom_config_engine'] = $engine;
}
}
}

if ( $theme != 'default' && $theme != 'default-rtl'
Expand Down

0 comments on commit 1b37e41

Please sign in to comment.