From 04a0e8ea34c241fdf6bd30b11f5242656f9cd1c2 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 3 Jan 2017 12:01:25 +0100 Subject: Updater: keep custom theme preference with the new theme setting --- application/Updater.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'application/Updater.php') diff --git a/application/Updater.php b/application/Updater.php index 38de3350..621c7238 100644 --- a/application/Updater.php +++ b/application/Updater.php @@ -279,6 +279,35 @@ class Updater $this->conf->write($this->isLoggedIn); return true; } + + /** + * New setting: theme name. If the default theme is used, nothing to do. + * + * If the user uses a custom theme, raintpl_tpl dir is updated to the parent directory, + * and the current theme is set as default in the theme setting. + * + * @return bool true if the update is successful, false otherwise. + */ + public function updateMethodDefaultTheme() + { + // raintpl_tpl isn't the root template directory anymore. + // We run the update only if this folder still contains the template files. + $tplDir = $this->conf->get('resource.raintpl_tpl'); + $tplFile = $tplDir . '/linklist.html'; + if (! file_exists($tplFile)) { + return true; + } + + $parent = dirname($tplDir); + $this->conf->set('resource.raintpl_tpl', $parent); + $this->conf->set('resource.theme', trim(str_replace($parent, '', $tplDir), '/')); + $this->conf->write($this->isLoggedIn); + + // Dependency injection gore + RainTPL::$tpl_dir = $tplDir; + + return true; + } } /** -- cgit v1.2.3