commit 80cf21003c8a84c7d869eebbc2ae0062673e9ee8
parent e18aa5b14a3c79b7adc936793c0cf84e1d9e5177
Author: markseu <mark2011@mayberg.se>
Date: Sun, 28 Jun 2020 19:16:07 +0200
Updated extensions for new API
Diffstat:
5 files changed, 24 insertions(+), 27 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
@@ -1214,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);
@@ -3024,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/install.php b/system/extensions/install.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowInstall {
- const VERSION = "0.8.25";
+ const VERSION = "0.8.26";
const TYPE = "feature";
const PRIORITY = "1";
public $yellow; //access to API
@@ -109,9 +109,8 @@ class YellowInstall {
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], "/")) {
- list($dummy, $entry) = explode(",", $matches[2], 3);
- $flags = explode(",", $matches[2]);
- $language = array_pop($flags);
+ list($dummy, $entry, $flags) = $this->yellow->toolbox->getTextList($matches[2], ",", 3);
+ $language = array_pop(explode(",", $flags));
if (preg_match("/^(.*)\.php$/", basename($entry), $tokens) && in_array($language, $languages)) {
$languagesFound[$language] = $tokens[1];
}
@@ -127,7 +126,7 @@ class YellowInstall {
if (lcfirst($matches[1])=="published") $modified = strtotime($matches[2]);
if (!empty($matches[1]) && !empty($matches[2]) && strposu($matches[1], "/")) {
$fileName = $matches[1];
- list($dummy, $entry) = explode(",", $matches[2], 3);
+ list($dummy1, $entry, $dummy2) = $this->yellow->toolbox->getTextList($matches[2], ",", 3);
$fileData = $zip->getFromName($pathBase.basename($entry));
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);
@@ -306,7 +305,7 @@ class YellowInstall {
public function detectBrowserLanguages($languagesDefault) {
$languages = array();
foreach (preg_split("/\s*,\s*/", $this->yellow->toolbox->getServer("HTTP_ACCEPT_LANGUAGE")) as $string) {
- list($language) = explode(";", $string);
+ list($language, $dummy) = $this->yellow->toolbox->getTextList($string, ";", 2);
if (!empty($language)) array_push($languages, $language);
}
foreach (preg_split("/\s*,\s*/", $languagesDefault) as $language) {
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.21";
+ const VERSION = "0.8.22";
const TYPE = "feature";
const PRIORITY = "2";
public $yellow; //access to API
@@ -122,7 +122,7 @@ class YellowUpdate {
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);
@@ -336,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];
}
@@ -346,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);
@@ -363,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 {
@@ -378,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;
@@ -392,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;
@@ -459,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);
@@ -591,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;
}
}
@@ -613,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 {
@@ -638,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);