commit 4a764668581f8647a94abb2260df4bba27174319
parent e028179e4ce44e0424c3b51fdc5028c501ebe2d4
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date: Wed, 1 Jul 2020 22:04:52 +0200
Merge branch 'master' of https://github.com/datenstrom/yellow
Diffstat:
4 files changed, 38 insertions(+), 50 deletions(-)
diff --git a/system/extensions/command.php b/system/extensions/command.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCommand {
- const VERSION = "0.8.15";
+ const VERSION = "0.8.16";
const TYPE = "feature";
const PRIORITY = "3";
public $yellow; //access to API
@@ -173,9 +173,7 @@ class YellowCommand {
// Request static file
public function requestStaticFile($scheme, $address, $base, $location) {
- $parts = explode(":", $address, 2);
- $serverName = isset($parts[0]) ? $parts[0] : "";
- $serverPort = isset($parts[1]) ? $parts[1] : "";
+ list($serverName, $serverPort) = $this->yellow->toolbox->getTextList($address, ":", 2);
if (empty($serverPort)) $serverPort = $scheme=="https" ? 443 : 80;
$_SERVER["HTTPS"] = $scheme=="https" ? "on" : "off";
$_SERVER["SERVER_PROTOCOL"] = "HTTP/1.1";
@@ -514,7 +512,7 @@ class YellowCommand {
foreach ($this->yellow->extensions->extensions as $key=>$value) {
if (method_exists($value["obj"], "onCommandHelp")) {
foreach (preg_split("/[\r\n]+/", $value["obj"]->onCommandHelp()) as $line) {
- list($command) = explode(" ", $line);
+ list($command, $dummy) = $this->yellow->toolbox->getTextList($line, " ", 2);
if (!empty($command) && !isset($data[$command])) $data[$command] = $line;
}
}
diff --git a/system/extensions/core.php b/system/extensions/core.php
@@ -346,9 +346,6 @@ class YellowCore {
$this->system->set("coreServerScheme", $scheme);
$this->system->set("coreServerAddress", $address);
$this->system->set("coreServerBase", $base);
- $this->system->set("serverScheme", $scheme); //TODO: remove later, for backwards compatibility
- $this->system->set("serverAddress", $address);
- $this->system->set("serverBase", $base);
if (defined("DEBUG") && DEBUG>=3) echo "YellowCore::getRequestInformation $scheme://$address$base<br/>\n";
}
$location = substru($this->toolbox->detectServerLocation(), strlenu($base));
@@ -493,10 +490,6 @@ class YellowPage {
$value = $this->yellow->system->get($key);
if (!empty($key) && !strempty($value)) $this->set($key, $value);
}
- $this->set("navigation", "navigation"); //TODO: remove later, for backwards compatibility
- $this->set("header", "header");
- $this->set("sidebar", "sidebar");
- $this->set("footer", "footer");
if (preg_match("/^(\xEF\xBB\xBF)?\-\-\-[\r\n]+(.+?)\-\-\-[\r\n]+/s", $this->rawData, $parts)) {
$this->metaDataOffsetBytes = strlenb($parts[0]);
foreach (preg_split("/[\r\n]+/", $parts[2]) as $line) {
@@ -1221,7 +1214,7 @@ class YellowContent {
if (empty($location)) {
$rootLocations = $this->yellow->lookup->findRootLocations();
foreach ($rootLocations as $rootLocation) {
- list($rootLocation, $fileName) = explode(" ", $rootLocation, 2);
+ list($rootLocation, $fileName) = $this->yellow->toolbox->getTextList($rootLocation, " ", 2);
$page = new YellowPage($this->yellow);
$page->setRequestInformation($scheme, $address, $base, $rootLocation, $fileName);
$page->parseData("", false, 0);
@@ -3031,7 +3024,7 @@ class YellowToolbox {
public function detectBrowserLanguage($languages, $languageDefault) {
$languageFound = $languageDefault;
foreach (preg_split("/\s*,\s*/", $this->getServer("HTTP_ACCEPT_LANGUAGE")) as $string) {
- list($language) = explode(";", $string);
+ list($language, $dummy) = $this->getTextList($string, ";", 2);
if (!empty($language) && in_array($language, $languages)) {
$languageFound = $language;
break;
diff --git a/system/extensions/edit.php b/system/extensions/edit.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowEdit {
- const VERSION = "0.8.26";
+ const VERSION = "0.8.27";
const TYPE = "feature";
public $yellow; //access to API
public $response; //web response
@@ -497,7 +497,7 @@ class YellowEdit {
$email = $emailSource = trim($this->yellow->page->getRequest("email"));
$this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action"));
if ($this->response->status=="ok") {
- list($email, $hash) = explode(":", $this->users->getUser($email, "pending"), 2);
+ list($email, $hash) = $this->yellow->toolbox->getTextList($this->users->getUser($email, "pending"), ":", 2);
if (!$this->users->isExisting($email) || empty($hash)) $this->response->status = "done";
}
if ($this->response->status=="ok") {
diff --git a/system/extensions/update.php b/system/extensions/update.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowUpdate {
- const VERSION = "0.8.20";
+ const VERSION = "0.8.22";
const TYPE = "feature";
const PRIORITY = "2";
public $yellow; //access to API
@@ -56,16 +56,6 @@ class YellowUpdate {
// Handle update
public function onUpdate($action) {
- if ($action=="update") { //TODO: remove later, converts old server settings
- if ($this->yellow->system->isExisting("staticUrl")) {
- $coreStaticUrl = $this->yellow->system->get("staticUrl");
- $coreServerUrl = empty($this->yellow->system->get("serverUrl")) ? "auto" : $this->yellow->system->get("serverUrl");
- $coreServerTimezone = $this->yellow->system->get("timezone");
- $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
- $this->yellow->system->save($fileName, array("coreStaticUrl" => $coreStaticUrl, "coreServerUrl" => $coreServerUrl,
- "coreServerTimezone" => $coreServerTimezone));
- }
- }
if ($action=="update") { //TODO: remove later, converts old content settings
if ($this->yellow->system->isExisting("multiLanguageMode")) {
$coreMultiLanguageMode = $this->yellow->system->get("multiLanguageMode");
@@ -99,33 +89,40 @@ class YellowUpdate {
}
}
if ($action=="update") { //TODO: remove later, converts old layout files
- if ($this->yellow->system->isExisting("navigation")) {
- $navigation = $this->yellow->system->get("navigation");
- $path = $this->yellow->system->get("coreLayoutDirectory");
+ if ($this->yellow->system->isExisting("coreLayoutDir")) {
+ $path = $this->yellow->system->get("coreLayoutDir");
foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) {
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
- $fileDataNew = str_replace("system->get(\"serverScheme\")", "system->get(\"coreServerScheme\")", $fileDataNew);
- $fileDataNew = str_replace("system->get(\"serverAddress\")", "system->get(\"coreServerAddress\")", $fileDataNew);
- $fileDataNew = str_replace("system->get(\"serverBase\")", "system->get(\"coreServerBase\")", $fileDataNew);
- $fileDataNew = str_replace("system->get(\"imageLocation\")", "system->get(\"coreImageLocation\")", $fileDataNew);
- $fileDataNew = str_replace("system->get(\"extensionLocation\")", "system->get(\"coreExtensionLocation\")", $fileDataNew);
- $fileDataNew = str_replace("system->get(\"resourceLocation\")", "system->get(\"coreResourceLocation\")", $fileDataNew);
- $fileDataNew = str_replace("text->getHtml(\"paginationPrevious\")", "text->getHtml(\"corePaginationPrevious\")", $fileDataNew);
- $fileDataNew = str_replace("text->getHtml(\"paginationNext\")", "text->getHtml(\"corePaginationNext\")", $fileDataNew);
+ $fileDataNew = str_replace("yellow->getLayoutArgs", "yellow->getLayoutArguments", $fileDataNew);
+ $fileDataNew = str_replace("toolbox->getLocationArgs", "toolbox->getLocationArguments", $fileDataNew);
+ $fileDataNew = str_replace("toolbox->getTextArgs", "toolbox->getTextArguments", $fileDataNew);
+ $fileDataNew = str_replace("toolbox->normaliseArgs", "toolbox->normaliseArguments", $fileDataNew);
+ $fileDataNew = str_replace("toolbox->isLocationArgs", "toolbox->isLocationArguments", $fileDataNew);
+ $fileDataNew = str_replace("\$this->yellow->page->get(\"navigation\")", "\"navigation\"", $fileDataNew);
$fileDataNew = str_replace("\$this->yellow->page->get(\"header\")", "\"header\"", $fileDataNew);
$fileDataNew = str_replace("\$this->yellow->page->get(\"sidebar\")", "\"sidebar\"", $fileDataNew);
$fileDataNew = str_replace("\$this->yellow->page->get(\"footer\")", "\"footer\"", $fileDataNew);
- $fileDataNew = str_replace("\$this->yellow->page->get(\"navigation\")", "\"$navigation\"", $fileDataNew);
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
$this->yellow->log("error", "Can't write file '$entry'!");
}
}
}
}
+ if ($action=="update") { //TODO: remove later, converts old commandline
+ if ($this->yellow->system->isExisting("coreStaticDir")) {
+ $fileName = "yellow.php";
+ $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName);
+ $fileDataNew = str_replace("make websites", "make small websites", $fileDataNew);
+ $fileDataNew = str_replace("command(\$argv[1], \$argv[2], \$argv[3], \$argv[4], \$argv[5], \$argv[6], \$argv[7])", "command()", $fileDataNew);
+ if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
+ }
+ }
+ }
if ($action=="startup") {
if ($this->yellow->system->get("updateNotification")!="none") {
foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) {
- list($extension, $action) = explode("/", $token, 2);
+ list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2);
if ($this->yellow->extensions->isExisting($extension) && ($action!="startup" && $action!="uninstall")) {
$value = $this->yellow->extensions->extensions[$extension];
if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($action);
@@ -339,7 +336,7 @@ class YellowUpdate {
if (empty($extensions)) {
foreach ($dataCurrent as $key=>$value) {
if (isset($dataLatest[$key])) {
- list($version) = explode(",", $dataLatest[$key]);
+ list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($dataLatest[$key], ",", 3);
if (strnatcasecmp($dataCurrent[$key], $version)<0) $data[$key] = $dataLatest[$key];
if (isset($dataModified[$key]) && !empty($version) && $force) $data[$key] = $dataLatest[$key];
}
@@ -349,7 +346,7 @@ class YellowUpdate {
$found = false;
foreach ($dataCurrent as $key=>$value) {
if (isset($dataLatest[$key])) {
- list($version) = explode(",", $dataLatest[$key]);
+ list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($dataLatest[$key], ",", 3);
if (strtoloweru($key)==strtoloweru($extension) && !empty($version)) {
$data[$key] = $dataLatest[$key];
$dataModified = array_intersect_key($dataModified, $data);
@@ -366,7 +363,7 @@ class YellowUpdate {
}
if ($statusCode==200) {
foreach (array_merge($dataModified, $data) as $key=>$value) {
- list($version) = explode(",", $value);
+ list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($value, ",", 3);
if (!isset($dataModified[$key]) || $force) {
echo ucfirst($key)." $version\n";
} else {
@@ -381,8 +378,8 @@ class YellowUpdate {
public function showExtensions() {
list($statusCode, $dataLatest) = $this->getExtensionsVersion(true, true);
foreach ($dataLatest as $key=>$value) {
- list($version, $url, $description) = explode(",", $value, 3);
- echo ucfirst($key).": $description\n";
+ list($dummy1, $dummy2, $text) = $this->yellow->toolbox->getTextList($value, ",", 3);
+ echo ucfirst($key).": $text\n";
}
if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->get("pageError")."\n";
return $statusCode;
@@ -395,7 +392,7 @@ class YellowUpdate {
$fileExtension = $this->yellow->system->get("coreDownloadExtension");
foreach ($data as $key=>$value) {
$fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
- list($version, $url) = explode(",", $value);
+ list($dummy1, $url, $dummy2) = $this->yellow->toolbox->getTextList($value, ",", 3);
list($statusCode, $fileData) = $this->getExtensionFile($url);
if (empty($fileData) || !$this->yellow->toolbox->createFile($fileName.$fileExtension, $fileData)) {
$statusCode = 500;
@@ -462,7 +459,7 @@ class YellowUpdate {
if (lcfirst($matches[1])=="language") $language = $matches[2];
if (!empty($matches[1]) && !empty($matches[2]) && strposu($matches[1], "/")) {
$fileName = $matches[1];
- list($dummy, $entry, $flags) = explode(",", $matches[2], 3);
+ list($dummy, $entry, $flags) = $this->yellow->toolbox->getTextList($matches[2], ",", 3);
foreach ($rootPages as $page) {
list($fileNameSource, $fileNameDestination) = $this->getExtensionsFileNames($fileName, $entry, $flags, $language, $pathBase, $page);
$fileData = $zip->getFromName($fileNameSource);
@@ -594,7 +591,7 @@ class YellowUpdate {
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if (!empty($matches[1]) && !empty($matches[2])) {
$extension = lcfirst($matches[1]);
- list($version) = explode(",", $matches[2]);
+ list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($matches[2], ",", 3);
$data[$extension] = $rawFormat ? $matches[2] : $version;
}
}
@@ -616,7 +613,7 @@ class YellowUpdate {
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if (!empty($matches[1]) && !empty($matches[2])) {
$fileName = $matches[1];
- list($extension) = explode(",", lcfirst($matches[2]), 3);
+ list($extension, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList(lcfirst($matches[2]), ",", 3);
if (!isset($data[$extension])) {
$data[$extension] = $fileName;
} else {
@@ -641,7 +638,7 @@ class YellowUpdate {
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if (!empty($matches[1]) && !empty($matches[2])) {
$fileName = $matches[1];
- list($extensionNew, $dummy, $flags) = explode(",", lcfirst($matches[2]), 3);
+ list($extensionNew, $dummy, $flags) = $this->yellow->toolbox->getTextList(lcfirst($matches[2]), ",", 3);
if ($extension!=$extensionNew) {
$extension = $extensionNew;
$lastPublished = $this->yellow->toolbox->getFileModified($fileName);