mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit c73728b9b1def19e874bac90d6b2bcc0a2b98628
parent 6b036e259f1b9bd1382cda93b6e4e87a169b6815
Author: markseu <mark2011@mayberg.se>
Date:   Tue, 27 Oct 2020 16:32:34 +0100

Better handling of old settings files

Diffstat:
Msystem/extensions/core.php | 4++--
Msystem/extensions/update-current.ini | 8++++----
Msystem/extensions/update.php | 70++++++++++++++++++++++++++++++++++++----------------------------------
3 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core class YellowCore { - const VERSION = "0.8.25"; + const VERSION = "0.8.26"; const RELEASE = "0.8.16"; public $page; // current page public $content; // content files @@ -177,7 +177,7 @@ class YellowCore { $languageError = $this->lookup->findLanguageFromFile($fileName, $this->system->get("language")); if (is_file($fileNameError)) { $rawData = $this->toolbox->readFile($fileNameError); - } elseif ($this->language->isExisting($languageError)) { + } elseif ($this->language->isText("coreError${statusCode}Title", $languageError)) { $rawData = "---\nTitle: ".$this->language->getText("coreError${statusCode}Title", $languageError)."\n"; $rawData .= "Layout: error\n---\n".$this->language->getText("coreError${statusCode}Text", $languageError); } else { diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -21,11 +21,11 @@ Tag: feature system/extensions/command.php: command.php, create, update Extension: Core -Version: 0.8.25 +Version: 0.8.26 Description: Core functionality of the website. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip -Published: 2020-10-26 23:15:09 +Published: 2020-10-27 16:19:30 Developer: Datenstrom Tag: feature system/extensions/core.php: core.php, create, update @@ -90,11 +90,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful Extension: Update -Version: 0.8.37 +Version: 0.8.39 Description: Keep your website up to date. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip -Published: 2020-10-26 15:03:12 +Published: 2020-10-27 16:18:21 Developer: Datenstrom Tag: feature system/extensions/update.php: update.php, create, update diff --git a/system/extensions/update.php b/system/extensions/update.php @@ -2,7 +2,7 @@ // Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update class YellowUpdate { - const VERSION = "0.8.37"; + const VERSION = "0.8.39"; const PRIORITY = "2"; public $yellow; // access to API public $updates; // number of updates @@ -57,6 +57,7 @@ class YellowUpdate { // Handle update public function onUpdate($action) { if ($action=="ready") { + $this->convertSystemSettings(); if ($this->yellow->system->get("updateNotification")!="none") { foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) { list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2); @@ -100,38 +101,7 @@ class YellowUpdate { } if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n"); } - if ($action=="update") { // TODO: remove later, convert old settings files - if (is_dir("system/settings/")) { - $fileNameSource = "system/settings/system.ini"; - $fileNameDestination = "system/extensions/yellow-system.ini"; - if (is_file($fileNameSource)) { - $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileNameSource); - $fileDataNew = str_replace("user.ini", "yellow-user.ini", $fileDataNew); - $fileDataNew = str_replace("language.ini", "yellow-language.ini", $fileDataNew); - if (!$this->yellow->toolbox->createFile($fileNameDestination, $fileDataNew)) { - $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); - } - } - $fileNameSource = "system/settings/user.ini"; - $fileNameDestination = "system/extensions/yellow-user.ini"; - if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { - $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); - } - $fileNameSource = "system/settings/language.ini"; - $fileNameDestination = "system/extensions/yellow-language.ini"; - if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { - $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); - } - if (!$this->yellow->toolbox->deleteDirectory("system/settings/", - $this->yellow->system->get("coreTrashDirectory"))) { - $this->yellow->log("error", "Can't delete directory 'system/settings/'!"); - } else { - $this->yellow->page->error(500, "The flux capacitor is charging, please reload page!"); - $this->yellow->log("info", "Convert old settings files"); - } - } - } - if ($action=="update") { // TODO: remove later, convert old layout files + if ($action=="update") { // TODO: remove later, convert layout files $path = $this->yellow->system->get("coreLayoutDirectory"); foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) { $key = str_replace("pages", "", $this->yellow->lookup->normaliseName(basename($entry), true, true)); @@ -149,6 +119,38 @@ class YellowUpdate { } } + // Convert system settings + public function convertSystemSettings() { + if (is_dir("system/settings/")) { // TODO: remove later, convert settings files + $fileNameSource = "system/settings/system.ini"; + $fileNameDestination = "system/extensions/yellow-system.ini"; + if (is_file($fileNameSource)) { + $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileNameSource); + $fileDataNew = str_replace("user.ini", "yellow-user.ini", $fileDataNew); + $fileDataNew = str_replace("language.ini", "yellow-language.ini", $fileDataNew); + if (!$this->yellow->toolbox->createFile($fileNameDestination, $fileDataNew)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + } + $fileNameSource = "system/settings/user.ini"; + $fileNameDestination = "system/extensions/yellow-user.ini"; + if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + $fileNameSource = "system/settings/language.ini"; + $fileNameDestination = "system/extensions/yellow-language.ini"; + if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + if (!$this->yellow->toolbox->deleteDirectory("system/settings/", $this->yellow->system->get("coreTrashDirectory"))) { + $this->yellow->log("error", "Can't delete directory 'system/settings/'!"); + } else { + $this->yellow->log("info", "Convert settings files"); + } + $this->yellow->page->error(503, "The flux capacitor is charging, please reload page!"); + } + } + // Update system settings after update notification public function updateSystemSettings() { $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); @@ -223,7 +225,7 @@ class YellowUpdate { } } - // Update timestamp settings in regular intervalls + // Update timestamp settings in regular intervals public function updateTimestampSettings($key) { $timestamp = $timeOffset = 0; foreach(str_split($this->yellow->system->get("sitename")) as $char) {