diff options
Diffstat (limited to 'application/Updater.php')
-rw-r--r-- | application/Updater.php | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/application/Updater.php b/application/Updater.php index 38de3350..eb03c6d3 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -69,7 +69,7 @@ class Updater | |||
69 | return $updatesRan; | 69 | return $updatesRan; |
70 | } | 70 | } |
71 | 71 | ||
72 | if ($this->methods == null) { | 72 | if ($this->methods === null) { |
73 | throw new UpdaterException('Couldn\'t retrieve Updater class methods.'); | 73 | throw new UpdaterException('Couldn\'t retrieve Updater class methods.'); |
74 | } | 74 | } |
75 | 75 | ||
@@ -279,6 +279,51 @@ class Updater | |||
279 | $this->conf->write($this->isLoggedIn); | 279 | $this->conf->write($this->isLoggedIn); |
280 | return true; | 280 | return true; |
281 | } | 281 | } |
282 | |||
283 | /** | ||
284 | * New setting: theme name. If the default theme is used, nothing to do. | ||
285 | * | ||
286 | * If the user uses a custom theme, raintpl_tpl dir is updated to the parent directory, | ||
287 | * and the current theme is set as default in the theme setting. | ||
288 | * | ||
289 | * @return bool true if the update is successful, false otherwise. | ||
290 | */ | ||
291 | public function updateMethodDefaultTheme() | ||
292 | { | ||
293 | // raintpl_tpl isn't the root template directory anymore. | ||
294 | // We run the update only if this folder still contains the template files. | ||
295 | $tplDir = $this->conf->get('resource.raintpl_tpl'); | ||
296 | $tplFile = $tplDir . '/linklist.html'; | ||
297 | if (! file_exists($tplFile)) { | ||
298 | return true; | ||
299 | } | ||
300 | |||
301 | $parent = dirname($tplDir); | ||
302 | $this->conf->set('resource.raintpl_tpl', $parent); | ||
303 | $this->conf->set('resource.theme', trim(str_replace($parent, '', $tplDir), '/')); | ||
304 | $this->conf->write($this->isLoggedIn); | ||
305 | |||
306 | // Dependency injection gore | ||
307 | RainTPL::$tpl_dir = $tplDir; | ||
308 | |||
309 | return true; | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Move the file to inc/user.css to data/user.css. | ||
314 | * | ||
315 | * Note: Due to hardcoded paths, it's not unit testable. But one line of code should be fine. | ||
316 | * | ||
317 | * @return bool true if the update is successful, false otherwise. | ||
318 | */ | ||
319 | public function updateMethodMoveUserCss() | ||
320 | { | ||
321 | if (! is_file('inc/user.css')) { | ||
322 | return true; | ||
323 | } | ||
324 | |||
325 | return rename('inc/user.css', 'data/user.css'); | ||
326 | } | ||
282 | } | 327 | } |
283 | 328 | ||
284 | /** | 329 | /** |