X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FUpdater.php;h=621c7238336a4e128187ca576b0d2784aaadcf86;hb=04a0e8ea34c241fdf6bd30b11f5242656f9cd1c2;hp=38de33503a417ac06c9b186298c7621a471d3667;hpb=a0df06517bada0f811b464017ce385290e02c2bf;p=github%2Fshaarli%2FShaarli.git 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; + } } /**