2018-09-07 16:20:02 +00:00
|
|
|
<?php
|
2019-02-23 14:04:34 +00:00
|
|
|
// Install extension, https://github.com/datenstrom/yellow
|
2019-02-02 15:17:56 +00:00
|
|
|
// Copyright (c) 2013-2019 Datenstrom, https://datenstrom.se
|
2018-09-07 16:20:02 +00:00
|
|
|
// This file may be used and distributed under the terms of the public license.
|
|
|
|
|
2018-10-03 13:56:04 +00:00
|
|
|
class YellowInstall {
|
2019-03-16 08:42:02 +00:00
|
|
|
const VERSION = "0.8.4";
|
2019-02-23 14:04:34 +00:00
|
|
|
const TYPE = "feature";
|
2018-10-09 12:49:48 +00:00
|
|
|
const PRIORITY = "1";
|
2018-09-07 16:20:02 +00:00
|
|
|
public $yellow; //access to API
|
|
|
|
|
|
|
|
// Handle initialisation
|
|
|
|
public function onLoad($yellow) {
|
|
|
|
$this->yellow = $yellow;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle request
|
|
|
|
public function onRequest($scheme, $address, $base, $location, $fileName) {
|
|
|
|
$statusCode = 0;
|
2018-10-03 11:24:52 +00:00
|
|
|
if ($this->yellow->lookup->isContentFile($fileName)) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$server = $this->yellow->toolbox->getServerVersion(true);
|
|
|
|
$this->checkServerRewrite($scheme, $address, $base, $location, $fileName) || die("Datenstrom Yellow requires $server rewrite module!");
|
2018-09-27 12:34:48 +00:00
|
|
|
$this->checkServerAccess() || die("Datenstrom Yellow requires $server read/write access!");
|
2018-10-03 13:56:04 +00:00
|
|
|
$statusCode = $this->processRequestInstall($scheme, $address, $base, $location, $fileName);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle command
|
|
|
|
public function onCommand($args) {
|
2018-10-03 13:56:04 +00:00
|
|
|
return $this->processCommandInstall();
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Process command to install website
|
2018-10-03 13:56:04 +00:00
|
|
|
public function processCommandInstall() {
|
2019-03-16 07:59:37 +00:00
|
|
|
$statusCode = $this->updateLog();
|
|
|
|
if ($statusCode==200) $statusCode = $this->updateLanguage();
|
2019-02-23 14:04:34 +00:00
|
|
|
if ($statusCode==200) $statusCode = $this->updateSettings($this->getSystemData());
|
|
|
|
if ($statusCode==200) $statusCode = $this->removeFiles();
|
2018-09-07 16:20:02 +00:00
|
|
|
if ($statusCode==200) {
|
|
|
|
$statusCode = 0;
|
|
|
|
} else {
|
|
|
|
echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
|
|
|
echo "Your website has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Process request to install website
|
2018-10-03 13:56:04 +00:00
|
|
|
public function processRequestInstall($scheme, $address, $base, $location, $fileName) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$name = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $_REQUEST["name"]));
|
|
|
|
$email = trim($_REQUEST["email"]);
|
|
|
|
$password = trim($_REQUEST["password"]);
|
|
|
|
$language = trim($_REQUEST["language"]);
|
2019-02-23 14:04:34 +00:00
|
|
|
$extension = trim($_REQUEST["extension"]);
|
2018-09-07 16:20:02 +00:00
|
|
|
$status = trim($_REQUEST["status"]);
|
2019-03-16 07:59:37 +00:00
|
|
|
$statusCode = $this->updateLog();
|
|
|
|
$statusCode = max($statusCode, $this->updateLanguage());
|
2019-02-23 14:04:34 +00:00
|
|
|
$this->yellow->content->pages["root/"] = array();
|
2018-09-07 16:20:02 +00:00
|
|
|
$this->yellow->page = new YellowPage($this->yellow);
|
|
|
|
$this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName);
|
2018-10-03 13:56:04 +00:00
|
|
|
$this->yellow->page->parseData($this->getRawDataInstall(), false, $statusCode, $this->yellow->page->get("pageError"));
|
2018-09-28 12:07:09 +00:00
|
|
|
$this->yellow->page->safeMode = false;
|
2018-10-03 13:56:04 +00:00
|
|
|
if ($status=="install") $status = $this->updateUser($email, $password, $name, $language)==200 ? "ok" : "error";
|
2019-02-23 14:04:34 +00:00
|
|
|
if ($status=="ok") $status = $this->updateExtension($extension)==200 ? "ok" : "error";
|
2018-09-07 16:20:02 +00:00
|
|
|
if ($status=="ok") $status = $this->updateContent($language, "Home", "/")==200 ? "ok" : "error";
|
|
|
|
if ($status=="ok") $status = $this->updateContent($language, "About", "/about/")==200 ? "ok" : "error";
|
2019-02-02 15:17:56 +00:00
|
|
|
if ($status=="ok") $status = $this->updateContent($language, "Footer", "/shared/footer")==200 ? "ok" : "error";
|
2019-03-16 07:59:37 +00:00
|
|
|
if ($status=="ok") $status = $this->updateSettings($this->getSystemData())==200 ? "ok" : "error";
|
|
|
|
if ($status=="ok") $status = $this->removeFiles()==200 ? "done" : "error";
|
2018-09-07 16:20:02 +00:00
|
|
|
if ($status=="done") {
|
|
|
|
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
|
|
|
|
$statusCode = $this->yellow->sendStatus(303, $location);
|
|
|
|
} else {
|
|
|
|
$statusCode = $this->yellow->sendPage();
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2019-03-16 07:59:37 +00:00
|
|
|
// Update log
|
|
|
|
public function updateLog() {
|
|
|
|
$statusCode = 200;
|
|
|
|
$fileName = $this->yellow->system->get("extensionDir").$this->yellow->system->get("logFile");
|
|
|
|
if (!is_file($fileName)) {
|
|
|
|
$serverVersion = $this->yellow->toolbox->getServerVersion();
|
|
|
|
$this->yellow->log("info", "Datenstrom Yellow ".YellowCore::VERSION.", PHP ".PHP_VERSION.", $serverVersion");
|
|
|
|
if (!$this->yellow->isCommandLine()) {
|
|
|
|
$server = $this->yellow->toolbox->getServerVersion(true);
|
|
|
|
$this->yellow->log("info", "Checked $server server configuration");
|
|
|
|
}
|
|
|
|
if (!is_file($fileName)) {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error(500, "Can't write file '$fileName'!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update language
|
|
|
|
public function updateLanguage() {
|
2018-09-07 16:20:02 +00:00
|
|
|
$statusCode = 200;
|
2019-02-23 14:04:34 +00:00
|
|
|
$path = $this->yellow->system->get("extensionDir")."install-languages.zip";
|
|
|
|
if (is_file($path) && $this->yellow->extensions->isExisting("update")) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$zip = new ZipArchive();
|
|
|
|
if ($zip->open($path)===true) {
|
2019-02-23 14:04:34 +00:00
|
|
|
$languages = $this->detectBrowserLanguages("en, de, fr");
|
|
|
|
$languagesFound = array();
|
|
|
|
foreach ($languages as $language) $languagesFound[$language] = "";
|
2018-09-07 16:20:02 +00:00
|
|
|
if (preg_match("#^(.*\/).*?$#", $zip->getNameIndex(0), $matches)) $pathBase = $matches[1];
|
2019-02-25 20:50:19 +00:00
|
|
|
$fileData = $zip->getFromName($pathBase.$this->yellow->system->get("updateExtensionFile"));
|
2018-09-07 16:20:02 +00:00
|
|
|
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
|
|
|
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
|
|
|
if (!empty($matches[1]) && !empty($matches[2]) && strposu($matches[1], "/")) {
|
2019-03-16 07:59:37 +00:00
|
|
|
list($dummy, $entry) = explode(",", $matches[2], 3);
|
2019-02-24 19:12:17 +00:00
|
|
|
$flags = explode(",", $matches[2]);
|
|
|
|
$language = array_pop($flags);
|
2019-02-23 14:04:34 +00:00
|
|
|
if (preg_match("/^(.*)\.php$/", basename($entry), $tokens) && in_array($language, $languages)) {
|
|
|
|
$languagesFound[$language] = $tokens[1];
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
$languagesFound = array_slice(array_filter($languagesFound, "strlen"), 0, 3);
|
2018-09-07 16:20:02 +00:00
|
|
|
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
|
|
|
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
2019-02-23 14:04:34 +00:00
|
|
|
if (lcfirst($matches[1])=="extension") $extension = lcfirst($matches[2]);
|
2018-09-07 16:20:02 +00:00
|
|
|
if (lcfirst($matches[1])=="published") $modified = strtotime($matches[2]);
|
|
|
|
if (!empty($matches[1]) && !empty($matches[2]) && strposu($matches[1], "/")) {
|
2019-03-16 07:59:37 +00:00
|
|
|
$fileName = $matches[1];
|
|
|
|
list($dummy, $entry) = explode(",", $matches[2], 3);
|
2019-02-23 14:04:34 +00:00
|
|
|
$fileData = $zip->getFromName($pathBase.basename($entry));
|
2019-03-16 08:42:02 +00:00
|
|
|
if (preg_match("/^(.*).php$/", basename($entry), $tokens) && in_array($tokens[1], $languagesFound) && !is_file($fileName)) {
|
|
|
|
$statusCode = $this->yellow->extensions->get("update")->updateExtensionFile($fileName, $fileData, $modified, 0, 0, "create", false, $extension);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-03-16 08:42:02 +00:00
|
|
|
if (preg_match("/^(.*)-language\.txt$/", basename($entry), $tokens) && in_array($tokens[1], $languagesFound) && !is_file($fileName)) {
|
|
|
|
$statusCode = $this->yellow->extensions->get("update")->updateExtensionFile($fileName, $fileData, $modified, 0, 0, "create", false, $extension);
|
2019-03-16 07:59:37 +00:00
|
|
|
$this->yellow->log($statusCode==200 ? "info" : "error", "Install language '".ucfirst($tokens[1])."'");
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-03-16 07:59:37 +00:00
|
|
|
if ($statusCode!=200) break;
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$zip->close();
|
|
|
|
if ($statusCode==200) {
|
2019-02-23 14:04:34 +00:00
|
|
|
$this->yellow->text->load($this->yellow->system->get("extensionDir").$this->yellow->system->get("languageFile"), "");
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error(500, "Can't open file '$path'!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update user
|
|
|
|
public function updateUser($email, $password, $name, $language) {
|
|
|
|
$statusCode = 200;
|
2019-02-23 14:04:34 +00:00
|
|
|
if (!empty($email) && !empty($password) && $this->yellow->extensions->isExisting("edit")) {
|
|
|
|
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
|
2019-03-16 07:59:37 +00:00
|
|
|
if (!$this->yellow->extensions->get("edit")->users->save($fileNameUser, $email, $password, $name, $language)) {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
|
|
|
}
|
|
|
|
$this->yellow->log($statusCode==200 ? "info" : "error", "Install webmaster '".strtok($name, " ")."'");
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Update extension
|
|
|
|
public function updateExtension($extension) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$statusCode = 200;
|
2019-02-23 14:04:34 +00:00
|
|
|
$path = $this->yellow->system->get("extensionDir");
|
|
|
|
if (!empty($extension) && $this->yellow->extensions->isExisting("update")) {
|
2018-09-07 16:20:02 +00:00
|
|
|
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
|
2018-10-03 13:56:04 +00:00
|
|
|
if (preg_match("/^install-(.*?)\./", basename($entry), $matches)) {
|
2019-02-23 14:04:34 +00:00
|
|
|
if (strtoloweru($matches[1])==strtoloweru($extension)) {
|
2019-03-16 07:59:37 +00:00
|
|
|
$statusCode = $this->yellow->extensions->get("update")->updateExtensionArchive($entry, "install");
|
2018-09-07 16:20:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2018-09-18 11:04:15 +00:00
|
|
|
// Update content
|
2018-09-07 16:20:02 +00:00
|
|
|
public function updateContent($language, $name, $location) {
|
|
|
|
$statusCode = 200;
|
|
|
|
if ($language!="en") {
|
2018-10-03 13:56:04 +00:00
|
|
|
$titleOld = "Title: ".$this->yellow->text->getText("install{$name}Title", "en");
|
|
|
|
$titleNew = "Title: ".$this->yellow->text->getText("install{$name}Title", $language);
|
|
|
|
$textOld = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", "en"));
|
|
|
|
$textNew = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", $language));
|
2018-09-07 16:20:02 +00:00
|
|
|
$fileName = $this->yellow->lookup->findFileFromLocation($location);
|
|
|
|
$fileData = strreplaceu("\r\n", "\n", $this->yellow->toolbox->readFile($fileName));
|
|
|
|
$fileData = strreplaceu($titleOld, $titleNew, $fileData);
|
2018-09-18 11:04:15 +00:00
|
|
|
$fileData = strreplaceu($textOld, $textNew, $fileData);
|
2018-09-07 16:20:02 +00:00
|
|
|
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Update settings
|
|
|
|
public function updateSettings($settings) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$statusCode = 200;
|
2019-02-23 14:04:34 +00:00
|
|
|
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
|
|
|
|
if (!$this->yellow->system->save($fileName, $settings)) {
|
2018-09-07 16:20:02 +00:00
|
|
|
$statusCode = 500;
|
2019-02-23 14:04:34 +00:00
|
|
|
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Remove files used by installation
|
|
|
|
public function removeFiles() {
|
2018-10-03 11:24:52 +00:00
|
|
|
$statusCode = 200;
|
|
|
|
if (function_exists("opcache_reset")) opcache_reset();
|
2019-02-23 14:04:34 +00:00
|
|
|
$path = $this->yellow->system->get("extensionDir");
|
2018-10-03 11:24:52 +00:00
|
|
|
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
|
2018-10-03 13:56:04 +00:00
|
|
|
if (preg_match("/^install-(.*?)\./", basename($entry), $matches)) {
|
2018-10-03 11:24:52 +00:00
|
|
|
if (!$this->yellow->toolbox->deleteFile($entry)) {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error($statusCode, "Can't delete file '$entry'!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
$path = $this->yellow->system->get("extensionDir")."install.php";
|
2018-10-03 11:24:52 +00:00
|
|
|
if ($statusCode==200 && !$this->yellow->toolbox->deleteFile($path)) {
|
|
|
|
$statusCode = 500;
|
|
|
|
$this->yellow->page->error($statusCode, "Can't delete file '$path'!");
|
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
if ($statusCode==200) unset($this->yellow->extensions->extensions["install"]);
|
2018-10-03 11:24:52 +00:00
|
|
|
return $statusCode;
|
|
|
|
}
|
|
|
|
|
2018-09-07 16:20:02 +00:00
|
|
|
// Check web server rewrite
|
|
|
|
public function checkServerRewrite($scheme, $address, $base, $location, $fileName) {
|
|
|
|
$curlHandle = curl_init();
|
2019-02-23 14:04:34 +00:00
|
|
|
$location = $this->yellow->system->get("resourceLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
|
2018-09-07 16:20:02 +00:00
|
|
|
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
|
|
|
|
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::VERSION).")";
|
|
|
|
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
|
|
|
$rawData = curl_exec($curlHandle);
|
|
|
|
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($curlHandle);
|
|
|
|
return !empty($rawData) && $statusCode==200;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check web server read/write access
|
|
|
|
public function checkServerAccess() {
|
2019-02-23 14:04:34 +00:00
|
|
|
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
|
|
|
|
return $this->yellow->system->save($fileName, array());
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Detect web browser languages
|
|
|
|
public function detectBrowserLanguages($languagesDefault) {
|
|
|
|
$languages = array();
|
2018-09-07 16:20:02 +00:00
|
|
|
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
|
|
|
|
foreach (preg_split("/\s*,\s*/", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $string) {
|
|
|
|
list($language) = explode(";", $string);
|
2019-02-23 14:04:34 +00:00
|
|
|
if (!empty($language)) array_push($languages, $language);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (preg_split("/\s*,\s*/", $languagesDefault) as $language) {
|
2019-02-23 14:04:34 +00:00
|
|
|
if (!empty($language)) array_push($languages, $language);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
return array_unique($languages);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Return system data, detect server URL
|
|
|
|
public function getSystemData() {
|
2018-09-07 16:20:02 +00:00
|
|
|
$data = array();
|
|
|
|
foreach ($_REQUEST as $key=>$value) {
|
2019-02-23 14:04:34 +00:00
|
|
|
if (!$this->yellow->system->isExisting($key)) continue;
|
2018-09-07 16:20:02 +00:00
|
|
|
$data[$key] = trim($value);
|
|
|
|
}
|
|
|
|
$data["timezone"] = $this->yellow->toolbox->getTimezone();
|
|
|
|
$data["staticUrl"] = $this->yellow->toolbox->getServerUrl();
|
2018-10-03 11:24:52 +00:00
|
|
|
if ($this->yellow->isCommandLine()) $data["staticUrl"] = getenv("URL");
|
2018-09-07 16:20:02 +00:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2018-10-03 13:56:04 +00:00
|
|
|
// Return raw data for install page
|
|
|
|
public function getRawDataInstall() {
|
2019-02-23 14:04:34 +00:00
|
|
|
$language = $this->yellow->toolbox->detectBrowserLanguage($this->yellow->text->getLanguages(), $this->yellow->system->get("language"));
|
|
|
|
$this->yellow->text->setLanguage($language);
|
|
|
|
$rawData = "---\nTitle:".$this->yellow->text->get("installTitle")."\nLanguage:$language\nNavigation:navigation\n---\n";
|
|
|
|
$rawData .= "<form class=\"install-form\" action=\"".$this->yellow->page->getLocation(true)."\" method=\"post\">\n";
|
|
|
|
$rawData .= "<p><label for=\"name\">".$this->yellow->text->get("editSignupName")."</label><br /><input class=\"form-control\" type=\"text\" maxlength=\"64\" name=\"name\" id=\"name\" value=\"\"></p>\n";
|
|
|
|
$rawData .= "<p><label for=\"email\">".$this->yellow->text->get("editSignupEmail")."</label><br /><input class=\"form-control\" type=\"text\" maxlength=\"64\" name=\"email\" id=\"email\" value=\"\"></p>\n";
|
|
|
|
$rawData .= "<p><label for=\"password\">".$this->yellow->text->get("editSignupPassword")."</label><br /><input class=\"form-control\" type=\"password\" maxlength=\"64\" name=\"password\" id=\"password\" value=\"\"></p>\n";
|
|
|
|
if (count($this->yellow->text->getLanguages())>1) {
|
|
|
|
$rawData .= "<p>";
|
|
|
|
foreach ($this->yellow->text->getLanguages() as $language) {
|
|
|
|
$checked = $language==$this->yellow->text->language ? " checked=\"checked\"" : "";
|
|
|
|
$rawData .= "<label for=\"$language\"><input type=\"radio\" name=\"language\" id=\"$language\" value=\"$language\"$checked> ".$this->yellow->text->getTextHtml("languageDescription", $language)."</label><br />";
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
$rawData .= "</p>\n";
|
|
|
|
}
|
|
|
|
if (count($this->getExtensionsInstall())>1) {
|
|
|
|
$rawData .= "<p>".$this->yellow->text->get("installExtension")."<p>";
|
|
|
|
foreach ($this->getExtensionsInstall() as $extension) {
|
|
|
|
$checked = $extension=="website" ? " checked=\"checked\"" : "";
|
|
|
|
$rawData .= "<label for=\"$extension\"><input type=\"radio\" name=\"extension\" id=\"$extension\" value=\"$extension\"$checked> ".ucfirst($extension)."</label><br />";
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
$rawData .= "</p>\n";
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
$rawData .= "<input class=\"btn\" type=\"submit\" value=\"".$this->yellow->text->get("editOkButton")."\" />\n";
|
|
|
|
$rawData .= "<input type=\"hidden\" name=\"status\" value=\"install\" />\n";
|
|
|
|
$rawData .= "</form>\n";
|
2018-09-07 16:20:02 +00:00
|
|
|
return $rawData;
|
|
|
|
}
|
|
|
|
|
2019-02-23 14:04:34 +00:00
|
|
|
// Return extensions for install page
|
|
|
|
public function getExtensionsInstall() {
|
|
|
|
$extensions = array("website");
|
|
|
|
$path = $this->yellow->system->get("extensionDir");
|
2018-09-07 16:20:02 +00:00
|
|
|
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false, false) as $entry) {
|
2019-02-23 14:04:34 +00:00
|
|
|
if (preg_match("/^install-(.*?)\./", $entry, $matches) && $matches[1]!="languages") array_push($extensions, $matches[1]);
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
2019-02-23 14:04:34 +00:00
|
|
|
return $extensions;
|
2018-09-07 16:20:02 +00:00
|
|
|
}
|
|
|
|
}
|