Updated event handling
This commit is contained in:
parent
75ab8fe6ad
commit
8869a1e459
4 changed files with 37 additions and 37 deletions
|
@ -2,7 +2,7 @@
|
|||
// Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core
|
||||
|
||||
class YellowCore {
|
||||
const VERSION = "0.8.39";
|
||||
const VERSION = "0.8.40";
|
||||
const RELEASE = "0.8.16";
|
||||
public $page; // current page
|
||||
public $content; // content files
|
||||
|
@ -37,6 +37,7 @@ class YellowCore {
|
|||
$this->system->setDefault("coreServerUrl", "auto");
|
||||
$this->system->setDefault("coreServerTimezone", "UTC");
|
||||
$this->system->setDefault("coreMultiLanguageMode", "0");
|
||||
$this->system->setDefault("coreTrashTimeout", "7776660");
|
||||
$this->system->setDefault("coreMediaLocation", "/media/");
|
||||
$this->system->setDefault("coreDownloadLocation", "/media/downloads/");
|
||||
$this->system->setDefault("coreImageLocation", "/media/images/");
|
||||
|
|
|
@ -21,11 +21,11 @@ Tag: feature
|
|||
system/extensions/command.php: command.php, create, update
|
||||
|
||||
Extension: Core
|
||||
Version: 0.8.39
|
||||
Version: 0.8.40
|
||||
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-12-16 14:56:08
|
||||
Published: 2021-01-19 11:13:22
|
||||
Developer: Datenstrom
|
||||
Tag: feature
|
||||
system/extensions/core.php: core.php, create, update
|
||||
|
@ -89,11 +89,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.48
|
||||
Version: 0.8.49
|
||||
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-01-15 17:31:05
|
||||
Published: 2021-01-15 20:31:50
|
||||
Developer: Datenstrom
|
||||
Tag: feature
|
||||
system/extensions/update.php: update.php, create, update
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update
|
||||
|
||||
class YellowUpdate {
|
||||
const VERSION = "0.8.48";
|
||||
const VERSION = "0.8.49";
|
||||
const PRIORITY = "2";
|
||||
public $yellow; // access to API
|
||||
public $updates; // number of updates
|
||||
|
@ -15,25 +15,13 @@ class YellowUpdate {
|
|||
$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("updateTrashTimeout", "7776660");
|
||||
$this->yellow->system->setDefault("updateDailyTimestamp", "0");
|
||||
$this->yellow->system->setDefault("updateNotification", "none");
|
||||
$this->yellow->system->setDefault("updateEventPending", "none");
|
||||
$this->yellow->system->setDefault("updateEventDaily", "0");
|
||||
}
|
||||
|
||||
// Handle update
|
||||
public function onUpdate($action) {
|
||||
if ($action=="clean" || $action=="daily") {
|
||||
$statusCode = 200;
|
||||
$path = $this->yellow->system->get("coreTrashDirectory");
|
||||
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, false) as $entry) {
|
||||
$expire = $this->yellow->toolbox->getFileDeleted($entry) + $this->yellow->system->get("updateTrashTimeout");
|
||||
if ($expire<=time() && !$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
|
||||
}
|
||||
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, true) as $entry) {
|
||||
$expire = $this->yellow->toolbox->getFileDeleted($entry) + $this->yellow->system->get("updateTrashTimeout");
|
||||
if ($expire<=time() && !$this->yellow->toolbox->deleteDirectory($entry)) $statusCode = 500;
|
||||
}
|
||||
if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n");
|
||||
$statusCode = 200;
|
||||
$path = $this->yellow->system->get("coreExtensionDirectory");
|
||||
$regex = "/^.*\\".$this->yellow->system->get("coreDownloadExtension")."$/";
|
||||
|
@ -41,6 +29,17 @@ class YellowUpdate {
|
|||
if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
|
||||
}
|
||||
if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n");
|
||||
$statusCode = 200;
|
||||
$path = $this->yellow->system->get("coreTrashDirectory");
|
||||
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, false) as $entry) {
|
||||
$expire = $this->yellow->toolbox->getFileDeleted($entry) + $this->yellow->system->get("coreTrashTimeout");
|
||||
if ($expire<=time() && !$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
|
||||
}
|
||||
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, true) as $entry) {
|
||||
$expire = $this->yellow->toolbox->getFileDeleted($entry) + $this->yellow->system->get("coreTrashTimeout");
|
||||
if ($expire<=time() && !$this->yellow->toolbox->deleteDirectory($entry)) $statusCode = 500;
|
||||
}
|
||||
if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n");
|
||||
}
|
||||
if ($action=="update") { // TODO: remove later, convert layout files
|
||||
$path = $this->yellow->system->get("coreLayoutDirectory");
|
||||
|
@ -189,7 +188,7 @@ class YellowUpdate {
|
|||
// Process command for pending events
|
||||
public function processCommandPending() {
|
||||
$statusCode = 0;
|
||||
$this->updateEventsPending();
|
||||
$this->updateEventPending();
|
||||
if ($this->isExtensionPending()) {
|
||||
$statusCode = $this->updateExtensions("install");
|
||||
if ($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
||||
|
@ -202,7 +201,7 @@ class YellowUpdate {
|
|||
public function processRequestPending($scheme, $address, $base, $location, $fileName) {
|
||||
$statusCode = 0;
|
||||
if ($this->yellow->lookup->isContentFile($fileName)) {
|
||||
$this->updateEventsPending();
|
||||
$this->updateEventPending();
|
||||
if($this->isExtensionPending()) {
|
||||
$statusCode = $this->updateExtensions("install");
|
||||
if ($statusCode==200) {
|
||||
|
@ -361,10 +360,10 @@ class YellowUpdate {
|
|||
}
|
||||
|
||||
// Update pending events
|
||||
public function updateEventsPending() {
|
||||
public function updateEventPending() {
|
||||
$this->updateSystemFiles();
|
||||
if ($this->yellow->system->get("updateNotification")!="none") {
|
||||
foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) {
|
||||
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];
|
||||
|
@ -372,18 +371,18 @@ class YellowUpdate {
|
|||
}
|
||||
}
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
|
||||
if (!$this->yellow->system->save($fileName, array("updateNotification" => "none"))) {
|
||||
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("updateDailyTimestamp")<=time()) {
|
||||
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("updateDailyTimestamp" => $this->getDailyTimestamp()))) {
|
||||
if (!$this->yellow->system->save($fileName, array("updateEventDaily" => $this->getTimestampDaily()))) {
|
||||
$this->yellow->log("error", "Can't write file '$fileName'!");
|
||||
}
|
||||
}
|
||||
|
@ -543,12 +542,12 @@ class YellowUpdate {
|
|||
$value = $this->yellow->extension->data[$extension];
|
||||
if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
|
||||
}
|
||||
$updateNotification = $this->yellow->system->get("updateNotification");
|
||||
if ($updateNotification=="none") $updateNotification = "";
|
||||
if (!empty($updateNotification)) $updateNotification .= ",";
|
||||
$updateNotification .= "$extension/$action";
|
||||
$updateEventPending = $this->yellow->system->get("updateEventPending");
|
||||
if ($updateEventPending=="none") $updateEventPending = "";
|
||||
if (!empty($updateEventPending)) $updateEventPending .= ",";
|
||||
$updateEventPending .= "$extension/$action";
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
|
||||
if (!$this->yellow->system->save($fileName, array("updateNotification" => $updateNotification))) {
|
||||
if (!$this->yellow->system->save($fileName, array("updateEventPending" => $updateEventPending))) {
|
||||
$statusCode = 500;
|
||||
$this->yellow->page->error(500, "Can't write file '$fileName'!");
|
||||
}
|
||||
|
@ -835,7 +834,7 @@ class YellowUpdate {
|
|||
}
|
||||
|
||||
// Return time of next daily update
|
||||
public function getDailyTimestamp() {
|
||||
public function getTimestampDaily() {
|
||||
$timeOffset = 0;
|
||||
foreach (str_split($this->yellow->system->get("sitename")) as $char) {
|
||||
$timeOffset = ($timeOffset+ord($char)) % 60;
|
||||
|
|
|
@ -12,6 +12,7 @@ CoreStaticUrl:
|
|||
CoreServerUrl: auto
|
||||
CoreServerTimezone: UTC
|
||||
CoreMultiLanguageMode: 0
|
||||
CoreTrashTimeout: 7776660
|
||||
CoreMediaLocation: /media/
|
||||
CoreDownloadLocation: /media/downloads/
|
||||
CoreImageLocation: /media/images/
|
||||
|
@ -42,9 +43,8 @@ UpdateExtensionFile: extension.ini
|
|||
UpdateLatestFile: update-latest.ini
|
||||
UpdateCurrentFile: update-current.ini
|
||||
UpdateCurrentRelease: 0
|
||||
UpdateTrashTimeout: 7776660
|
||||
UpdateDailyTimestamp: 0
|
||||
UpdateNotification: none
|
||||
UpdateEventPending: none
|
||||
UpdateEventDaily: 0
|
||||
CommandStaticBuildDirectory: public/
|
||||
CommandStaticDefaultFile: index.html
|
||||
CommandStaticErrorFile: 404.html
|
||||
|
|
Loading…
Add table
Reference in a new issue