From adc4aee80f7cd3242f65f0b316af2b560a64712c Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Wed, 7 Dec 2016 11:58:25 +0100 Subject: Change templates set through administration UI --- application/ApplicationUtils.php | 1 + application/PageBuilder.php | 2 +- application/Utils.php | 10 ++++++++++ application/config/ConfigManager.php | 1 + application/config/ConfigPhp.php | 3 ++- 5 files changed, 15 insertions(+), 2 deletions(-) (limited to 'application') diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index 7f963e97..a0f482b0 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php @@ -150,6 +150,7 @@ class ApplicationUtils 'inc', 'plugins', $conf->get('resource.raintpl_tpl'), + $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme'), ) as $path) { if (! is_readable(realpath($path))) { $errors[] = '"'.$path.'" directory is not readable'; diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 32c7f9f1..e226a77d 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -79,7 +79,7 @@ class PageBuilder $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); $this->tpl->assign('token', getToken($this->conf)); // To be removed with a proper theme configuration. - $this->tpl->assign('conf', $this->conf); + $this->tpl->assign('theme', $this->conf->get('resource.theme', 'default')); } /** diff --git a/application/Utils.php b/application/Utils.php index 35d65224..7556d3c9 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -270,3 +270,13 @@ function normalize_spaces($string) { return preg_replace('/\s{2,}/', ' ', trim($string)); } + +function getAllTheme($raintpl_tpl) +{ + $allTheme = glob($raintpl_tpl.'/*', GLOB_ONLYDIR); + foreach ($allTheme as $value) { + $themes[] = str_replace($raintpl_tpl.'/', '', $value); + } + + return $themes; +} diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index ca8918b5..a401887c 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -299,6 +299,7 @@ class ConfigManager $this->setEmpty('resource.log', 'data/log.txt'); $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt'); $this->setEmpty('resource.raintpl_tpl', 'tpl/'); + $this->setEmpty('resource.theme', 'default'); $this->setEmpty('resource.raintpl_tmp', 'tmp/'); $this->setEmpty('resource.thumbnails_cache', 'cache'); $this->setEmpty('resource.page_cache', 'pagecache'); diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index 27187b66..2eb68d80 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php @@ -41,6 +41,7 @@ class ConfigPhp implements ConfigIO 'resource.log' => 'config.LOG_FILE', 'resource.update_check' => 'config.UPDATECHECK_FILENAME', 'resource.raintpl_tpl' => 'config.RAINTPL_TPL', + 'resource.theme' => 'config.theme', 'resource.raintpl_tmp' => 'config.RAINTPL_TMP', 'resource.thumbnails_cache' => 'config.CACHEDIR', 'resource.page_cache' => 'config.PAGECACHE', @@ -99,7 +100,7 @@ class ConfigPhp implements ConfigIO $configStr .= '$GLOBALS[\'' . $key . '\'] = ' . var_export($conf[$key], true) . ';' . PHP_EOL; } } - + // Store all $conf['config'] foreach ($conf['config'] as $key => $value) { $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL; -- cgit v1.2.3