Updated install extension, must only run once

This commit is contained in:
markseu 2021-08-16 09:16:49 +02:00
parent 36dc330345
commit dcd79874f4
2 changed files with 45 additions and 30 deletions

View file

@ -2,7 +2,7 @@
// Install extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/install // Install extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/install
class YellowInstall { class YellowInstall {
const VERSION = "0.8.53"; const VERSION = "0.8.54";
const PRIORITY = "1"; const PRIORITY = "1";
public $yellow; // access to API public $yellow; // access to API
@ -25,28 +25,33 @@ class YellowInstall {
public function processRequestInstall($scheme, $address, $base, $location, $fileName) { public function processRequestInstall($scheme, $address, $base, $location, $fileName) {
$statusCode = 0; $statusCode = 0;
if ($this->yellow->lookup->isContentFile($fileName) || empty($fileName)) { if ($this->yellow->lookup->isContentFile($fileName) || empty($fileName)) {
$this->checkServerRequirements(); if (!$this->isAlreadyInstalled()) {
$author = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $this->yellow->page->getRequest("author"))); $this->checkServerRequirements();
$email = trim($this->yellow->page->getRequest("email")); $author = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $this->yellow->page->getRequest("author")));
$password = trim($this->yellow->page->getRequest("password")); $email = trim($this->yellow->page->getRequest("email"));
$language = trim($this->yellow->page->getRequest("language")); $password = trim($this->yellow->page->getRequest("password"));
$extension = trim($this->yellow->page->getRequest("extension")); $language = trim($this->yellow->page->getRequest("language"));
$status = trim($this->yellow->page->getRequest("status")); $extension = trim($this->yellow->page->getRequest("extension"));
$statusCode = $this->updateLog(); $status = trim($this->yellow->page->getRequest("status"));
$statusCode = max($statusCode, $this->updateLanguages()); $statusCode = $this->updateLog();
$this->yellow->content->pages["root/"] = array(); $statusCode = max($statusCode, $this->updateLanguages());
$this->yellow->page = new YellowPage($this->yellow); $this->yellow->content->pages["root/"] = array();
$this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName); $this->yellow->page = new YellowPage($this->yellow);
$this->yellow->page->parseData($this->getRawDataInstall(), false, $statusCode, $this->yellow->page->get("pageError")); $this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName);
if ($status=="install") $status = $this->updateExtension($extension)==200 ? "ok" : "error"; $this->yellow->page->parseData($this->getRawDataInstall(), false, $statusCode, $this->yellow->page->get("pageError"));
if ($status=="ok") $status = $this->updateUser($email, $password, $author, $language)==200 ? "ok" : "error"; if ($status=="install") $status = $this->updateExtension($extension)==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "installHome", "/")==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateUser($email, $password, $author, $language)==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "installDefault", "/shared/page-new-default")==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateContent($language, "installHome", "/")==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "installBlog", "/shared/page-new-blog")==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateContent($language, "installDefault", "/shared/page-new-default")==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "installWiki", "/shared/page-new-wiki")==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateContent($language, "installBlog", "/shared/page-new-blog")==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "coreError404", "/shared/page-error-404")==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateContent($language, "installWiki", "/shared/page-new-wiki")==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateSettings($language)==200 ? "ok" : "error"; if ($status=="ok") $status = $this->updateContent($language, "coreError404", "/shared/page-error-404")==200 ? "ok" : "error";
if ($status=="ok") $status = $this->removeInstall()==200 ? "done" : "error"; if ($status=="ok") $status = $this->updateSettings($language)==200 ? "ok" : "error";
if ($status=="ok") $status = $this->removeInstall()==200 ? "done" : "error";
} else {
$status = $this->removeInstall()==200 ? "done" : "error";
$this->yellow->log($status=="done" ? "info" : "error", "Uninstall extension 'Install ".YellowInstall::VERSION."'");
}
if ($status=="done") { if ($status=="done") {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, "/"); $location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, "/");
$statusCode = $this->yellow->sendStatus(303, $location); $statusCode = $this->yellow->sendStatus(303, $location);
@ -59,11 +64,16 @@ class YellowInstall {
// Process command to install website // Process command to install website
public function processCommandInstall() { public function processCommandInstall() {
$this->checkCommandRequirements(); if (!$this->isAlreadyInstalled()) {
$statusCode = $this->updateLog(); $this->checkCommandRequirements();
if ($statusCode==200) $statusCode = $this->updateLanguages(); $statusCode = $this->updateLog();
if ($statusCode==200) $statusCode = $this->updateSettings("en"); if ($statusCode==200) $statusCode = $this->updateLanguages();
if ($statusCode==200) $statusCode = $this->removeInstall(); if ($statusCode==200) $statusCode = $this->updateSettings("en");
if ($statusCode==200) $statusCode = $this->removeInstall();
} else {
$statusCode = $this->removeInstall();
$this->yellow->log($statusCode==200 ? "info" : "error", "Uninstall extension 'Install ".YellowInstall::VERSION."'");
}
if ($statusCode==200) { if ($statusCode==200) {
$statusCode = 0; $statusCode = 0;
} else { } else {
@ -409,4 +419,9 @@ class YellowInstall {
} }
return array_slice($extensions, 0, 3); return array_slice($extensions, 0, 3);
} }
// Check if already installed
public function isAlreadyInstalled() {
return $this->yellow->system->get("updateCurrentRelease")!=0;
}
} }

View file

@ -65,11 +65,11 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install Extension: Install
Version: 0.8.53 Version: 0.8.54
Description: Install a brand new, shiny website. Description: Install a brand new, shiny website.
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/install HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/install
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/install.zip DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/install.zip
Published: 2021-08-11 18:04:38 Published: 2021-08-16 08:47:55
Developer: Datenstrom Developer: Datenstrom
Status: unlisted Status: unlisted
system/extensions/install.php: install.php, create system/extensions/install.php: install.php, create