commit 14986ec389e7bd4a00e5568c97f00b37b726e742
parent a58921a31b42881c1cd8d83b80ef55f6ba87c81c
Author: markseu <mark2011@mayberg.se>
Date: Mon, 29 Nov 2021 15:52:05 +0100
Updated installation with built-in web server
Diffstat:
3 files changed, 30 insertions(+), 74 deletions(-)
diff --git a/system/extensions/install.php b/system/extensions/install.php
@@ -2,7 +2,7 @@
// Install extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/install
class YellowInstall {
- const VERSION = "0.8.59";
+ const VERSION = "0.8.60";
const PRIORITY = "1";
public $yellow; // access to API
@@ -25,7 +25,7 @@ class YellowInstall {
public function processRequestInstall($scheme, $address, $base, $location, $fileName) {
$statusCode = 0;
if ($this->yellow->lookup->isContentFile($fileName) || empty($fileName)) {
- if (!$this->isAlreadyInstalled()) {
+ if ($this->yellow->system->get("updateCurrentRelease")=="none") {
$this->checkServerRequirements();
$author = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $this->yellow->page->getRequest("author")));
$email = trim($this->yellow->page->getRequest("email"));
@@ -66,7 +66,7 @@ class YellowInstall {
// Process command to install website
public function processCommandInstall($command, $text) {
- if (!$this->isAlreadyInstalled()) {
+ if ($this->yellow->system->get("updateCurrentRelease")=="none") {
$this->checkCommandRequirements();
$statusCode = $this->updateLog();
if ($command=="build" || $command=="clean") {
@@ -436,9 +436,4 @@ class YellowInstall {
list($name) = $this->yellow->toolbox->detectServerInformation();
return strtoloweru($name)=="built-in";
}
-
- // Check if website already installed
- public function isAlreadyInstalled() {
- return $this->yellow->system->get("updateCurrentRelease")!=0;
- }
}
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -64,11 +64,11 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install
-Version: 0.8.59
+Version: 0.8.60
Description: Install a brand new, shiny website.
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/install
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/install.zip
-Published: 2021-11-29 11:54:59
+Published: 2021-11-29 15:38:17
Developer: Datenstrom
Status: unlisted
system/extensions/install.php: install.php, create
@@ -129,11 +129,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.60
+Version: 0.8.61
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: 2021-11-29 12:29:53
+Published: 2021-11-29 15:34:22
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.60";
+ const VERSION = "0.8.61";
const PRIORITY = "2";
public $yellow; // access to API
public $updates; // number of updates
@@ -14,7 +14,7 @@ class YellowUpdate {
$this->yellow->system->setDefault("updateExtensionFile", "extension.ini");
$this->yellow->system->setDefault("updateLatestFile", "update-latest.ini");
$this->yellow->system->setDefault("updateCurrentFile", "update-current.ini");
- $this->yellow->system->setDefault("updateCurrentRelease", "0");
+ $this->yellow->system->setDefault("updateCurrentRelease", "none");
$this->yellow->system->setDefault("updateEventPending", "none");
$this->yellow->system->setDefault("updateEventDaily", "0");
$this->yellow->system->setDefault("updateTrashTimeout", "7776660");
@@ -396,69 +396,30 @@ class YellowUpdate {
// Update pending events
public function updateEventPending() {
- $this->updateSystemFiles();
- if ($this->yellow->system->get("updateEventPending")!="none") {
- foreach (explode(",", $this->yellow->system->get("updateEventPending")) as $token) {
- list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2);
- if ($this->yellow->extension->isExisting($extension) && ($action!="ready" && $action!="uninstall")) {
- $value = $this->yellow->extension->data[$extension];
- if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
+ if ($this->yellow->system->get("updateCurrentRelease")!="none") {
+ if ($this->yellow->system->get("updateEventPending")!="none") {
+ foreach (explode(",", $this->yellow->system->get("updateEventPending")) as $token) {
+ list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2);
+ if ($this->yellow->extension->isExisting($extension) && ($action!="ready" && $action!="uninstall")) {
+ $value = $this->yellow->extension->data[$extension];
+ if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
+ }
}
- }
- $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
- if (!$this->yellow->system->save($fileName, array("updateEventPending" => "none"))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- $this->updateSystemSettings();
- $this->updateLanguageSettings();
- }
- if ($this->yellow->system->get("updateEventDaily")<=time()) {
- foreach ($this->yellow->extension->data as $key=>$value) {
- if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("daily");
- }
- $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
- if (!$this->yellow->system->save($fileName, array("updateEventDaily" => $this->getTimestampDaily()))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- }
-
- // Update system files from a previous release
- public function updateSystemFiles() {
- 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'!");
+ $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
+ if (!$this->yellow->system->save($fileName, array("updateEventPending" => "none"))) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
}
+ $this->updateSystemSettings();
+ $this->updateLanguageSettings();
}
- $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/'!");
- }
- $this->yellow->system->load("system/extensions/yellow-system.ini");
- $this->yellow->user->load("system/extensions/yellow-user.ini");
- $this->yellow->language->load("system/extensions/yellow-language.ini");
- $this->yellow->page->error(503, "Flux capacitor is charging to 1.21 gigawatt, please reload page!");
- }
- if ($this->yellow->system->isExisting("updateNotification")) { // TODO: remove later, convert old notification
- $updateEventPending = $this->yellow->system->get("updateNotification");
- $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
- if (!$this->yellow->system->save($fileName, array("updateEventPending" => $updateEventPending))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
+ if ($this->yellow->system->get("updateEventDaily")<=time()) {
+ foreach ($this->yellow->extension->data as $key=>$value) {
+ if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("daily");
+ }
+ $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
+ if (!$this->yellow->system->save($fileName, array("updateEventDaily" => $this->getTimestampDaily()))) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
+ }
}
}
}