Updated core, image formats

This commit is contained in:
markseu 2024-04-20 22:53:17 +02:00
parent e73b6a34dc
commit 123ec7dfdc
7 changed files with 109 additions and 124 deletions

View file

@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
system/themes/copenhagen.png: copenhagen.png, create system/themes/copenhagen.png: copenhagen.png, create
Extension: Core Extension: Core
Version: 0.9.3 Version: 0.9.4
Description: Core functionality of your website. Description: Core functionality of your website.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-10 10:17:55 Published: 2024-04-20 15:24:55
Status: available Status: available
system/workers/core.php: core.php, create, update system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update system/extensions/core.php: coreupdate.txt, update
@ -212,14 +212,14 @@ Status: available
system/workers/dutch.php: dutch.php, create, update system/workers/dutch.php: dutch.php, create, update
Extension: Edit Extension: Edit
Version: 0.9.3 Version: 0.9.4
Description: Edit your website in a web browser. Description: Edit your website in a web browser.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-10 10:25:08 Published: 2024-04-20 15:10:16
Status: available Status: available
system/workers/edit.php: edit.php, create, update system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update system/workers/edit.css: edit.css, create, update
@ -431,14 +431,14 @@ system/workers/icon.css: icon.css, create, update
system/workers/icon.woff: icon.woff, create, update system/workers/icon.woff: icon.woff, create, update
Extension: Image Extension: Image
Version: 0.9.1 Version: 0.9.2
Description: Add images and thumbnails. Description: Add images and thumbnails.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:56:26 Published: 2024-04-20 15:25:01
Status: available Status: available
system/workers/image.php: image.php, create, update system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional media/images/photo.jpg: photo.jpg, create, optional

View file

@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings # Datenstrom Yellow extension settings
Extension: Core Extension: Core
Version: 0.9.3 Version: 0.9.4
Description: Core functionality of your website. Description: Core functionality of your website.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-10 10:17:55 Published: 2024-04-20 15:24:55
Status: available Status: available
system/workers/core.php: core.php, create, update system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update system/extensions/core.php: coreupdate.txt, update
@ -20,14 +20,14 @@ system/layouts/navigation.html: navigation.html, create, update, careful
system/layouts/pagination.html: pagination.html, create, update, careful system/layouts/pagination.html: pagination.html, create, update, careful
Extension: Edit Extension: Edit
Version: 0.9.3 Version: 0.9.4
Description: Edit your website in a web browser. Description: Edit your website in a web browser.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-10 10:25:08 Published: 2024-04-20 15:10:16
Status: available Status: available
system/workers/edit.php: edit.php, create, update system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update system/workers/edit.css: edit.css, create, update
@ -48,14 +48,14 @@ Status: available
system/workers/generate.php: generate.php, create, update system/workers/generate.php: generate.php, create, update
Extension: Image Extension: Image
Version: 0.9.1 Version: 0.9.2
Description: Add images and thumbnails. Description: Add images and thumbnails.
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:56:26 Published: 2024-04-20 15:25:01
Status: available Status: available
system/workers/image.php: image.php, create, update system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional media/images/photo.jpg: photo.jpg, create, optional

View file

@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core // Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore { class YellowCore {
const VERSION = "0.9.3"; const VERSION = "0.9.4";
const RELEASE = "0.9"; const RELEASE = "0.9";
public $content; // content files public $content; // content files
public $media; // media files public $media; // media files
@ -82,8 +82,6 @@ class YellowCore {
$this->system->set("coreServerInstallDirectory", $pathInstall); $this->system->set("coreServerInstallDirectory", $pathInstall);
$this->system->set("coreServerRootDirectory", $pathRoot); $this->system->set("coreServerRootDirectory", $pathRoot);
$this->system->set("coreServerHomeDirectory", $pathHome); $this->system->set("coreServerHomeDirectory", $pathHome);
$this->system->set("coreExtensionLocation", "/assets/"); // TODO: remove later, for backwards compatibility
$this->system->set("coreThemeLocation", "/assets/"); // TODO: remove later, for backwards compatibility
register_shutdown_function(array($this, "processFatalError")); register_shutdown_function(array($this, "processFatalError"));
if ($this->system->get("coreDebugMode")>=1) { if ($this->system->get("coreDebugMode")>=1) {
ini_set("display_errors", 1); ini_set("display_errors", 1);
@ -730,7 +728,6 @@ class YellowSystem {
} }
return !is_array_empty($values) ? $values : array($valueDefault); return !is_array_empty($values) ? $values : array($valueDefault);
} }
public function getValues($key) { return $this->getAvailable($key); } //TODO: remove later, for backwards compatibility
// Return system settings // Return system settings
public function getSettings($filterStart = "", $filterEnd = "") { public function getSettings($filterStart = "", $filterEnd = "") {
@ -1861,7 +1858,7 @@ class YellowLookup {
// Check if file is a well-known file type // Check if file is a well-known file type
public function isSafeFile($fileName) { public function isSafeFile($fileName) {
return preg_match("/\.(css|gif|ico|js|jpg|map|png|scss|svg|woff|woff2)$/", $fileName); return preg_match("/\.(css|gif|ico|js|jpeg|jpg|map|png|scss|svg|woff|woff2)$/", $fileName);
} }
// Check if file is valid // Check if file is valid
@ -2013,6 +2010,7 @@ class YellowToolbox {
"ico" => "image/x-icon", "ico" => "image/x-icon",
"js" => "application/javascript", "js" => "application/javascript",
"json" => "application/json", "json" => "application/json",
"jpeg" => "image/jpeg",
"jpg" => "image/jpeg", "jpg" => "image/jpeg",
"md" => "text/markdown", "md" => "text/markdown",
"png" => "image/png", "png" => "image/png",
@ -2139,9 +2137,6 @@ class YellowToolbox {
return $ok; return $ok;
} }
// TODO: remove later, for backwards compatibility
public function createFile($fileName, $fileData, $mkdir = false) { return $this->writeFile($fileName, $fileData, $mkdir); }
// Append file // Append file
public function appendFile($fileName, $fileData, $mkdir = false) { public function appendFile($fileName, $fileData, $mkdir = false) {
$ok = false; $ok = false;
@ -2788,7 +2783,7 @@ class YellowToolbox {
return array($width, $height); return array($width, $height);
} }
// Detect image width, height, orientation and type for GIF/JPG/PNG/SVG // Detect image width, height, orientation and type for GIF/JPEG/PNG/SVG
public function detectImageInformation($fileName, $fileType = "") { public function detectImageInformation($fileName, $fileType = "") {
$width = $height = $orientation = 0; $width = $height = $orientation = 0;
$type = ""; $type = "";
@ -2803,7 +2798,7 @@ class YellowToolbox {
$height = (ord($dataHeader[3])<<8) + ord($dataHeader[2]); $height = (ord($dataHeader[3])<<8) + ord($dataHeader[2]);
$type = $fileType; $type = $fileType;
} }
} elseif ($fileType=="jpg") { } elseif ($fileType=="jpeg" || $fileType=="jpg") {
$dataBufferSizeMax = filesize($fileName); $dataBufferSizeMax = filesize($fileName);
$dataBufferSize = min($dataBufferSizeMax, 4096); $dataBufferSize = min($dataBufferSizeMax, 4096);
if ($dataBufferSize) $dataBuffer = fread($fileHandle, $dataBufferSize); if ($dataBufferSize) $dataBuffer = fread($fileHandle, $dataBufferSize);
@ -2987,10 +2982,6 @@ class YellowToolbox {
public function isNotModified($lastModifiedFormatted) { public function isNotModified($lastModifiedFormatted) {
return $this->getServer("HTTP_IF_MODIFIED_SINCE")==$lastModifiedFormatted; return $this->getServer("HTTP_IF_MODIFIED_SINCE")==$lastModifiedFormatted;
} }
// TODO: remove later, for backwards compatibility
public function normaliseArguments($text, $appendSlash = true, $filterStrict = true) { return $this->yellow->lookup->normaliseArguments($text, $appendSlash, $filterStrict); }
public function normalisePath($text) { return $this->yellow->lookup->normalisePath($text); }
} }
class YellowPage { class YellowPage {
@ -3164,10 +3155,6 @@ class YellowPage {
$output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type); $output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type);
if (!is_null($output)) break; if (!is_null($output)) break;
} }
if (method_exists($value["object"], "onParseContentShortcut")) { //TODO: remove later, for backwards compatibility
$output = $value["object"]->onParseContentShortcut($this, $name, $text, $type);
if (!is_null($output)) break;
}
} }
if (is_null($output)) { if (is_null($output)) {
if ($name=="yellow" && $type=="inline" && $text=="error") { if ($name=="yellow" && $type=="inline" && $text=="error") {
@ -3180,9 +3167,6 @@ class YellowPage {
return $output; return $output;
} }
// TODO: remove later, for backwards compatibility
public function parseContentShortcut($name, $text, $type) { return $this->parseContentElement($name, $text, "", $type); }
// Parse page // Parse page
public function parsePage() { public function parsePage() {
$this->parsePageLayout($this->get("layout")); $this->parsePageLayout($this->get("layout"));
@ -3567,10 +3551,6 @@ class YellowPage {
public function isPage($key) { public function isPage($key) {
return isset($this->sharedPages[$key]); return isset($this->sharedPages[$key]);
} }
// TODO: remove later, for backwards compatibility
public function getContent($rawFormat = false) { return $rawFormat ? $this->getContentRaw() : $this->getContentHtml(); }
public function getExtra($name) { return $this->getExtraHtml($name); }
} }
class YellowPageCollection extends ArrayObject { class YellowPageCollection extends ArrayObject {
@ -3984,7 +3964,6 @@ function substrb() {
function is_string_empty($string) { function is_string_empty($string) {
return is_null($string) || $string===""; return is_null($string) || $string==="";
} }
function strempty($string) { return is_null($string) || $string===""; } //TODO: remove later, for backwards compatibility
// Check if array is empty // Check if array is empty
function is_array_empty($array) { function is_array_empty($array) {

View file

@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit // Edit extension, https://github.com/annaesvensson/yellow-edit
class YellowEdit { class YellowEdit {
const VERSION = "0.9.3"; const VERSION = "0.9.4";
public $yellow; // access to API public $yellow; // access to API
public $response; // web response public $response; // web response
public $merge; // text merge public $merge; // text merge
@ -16,7 +16,7 @@ class YellowEdit {
$this->yellow->system->setDefault("editSiteEmail", "noreply"); $this->yellow->system->setDefault("editSiteEmail", "noreply");
$this->yellow->system->setDefault("editLocation", "/edit/"); $this->yellow->system->setDefault("editLocation", "/edit/");
$this->yellow->system->setDefault("editUploadNewLocation", "/media/@group/@filename"); $this->yellow->system->setDefault("editUploadNewLocation", "/media/@group/@filename");
$this->yellow->system->setDefault("editUploadExtensions", ".gif, .jpg, .mp3, .ogg, .pdf, .png, .svg, .zip"); $this->yellow->system->setDefault("editUploadExtensions", ".gif, .jpeg, .jpg, .mp3, .ogg, .pdf, .png, .svg, .zip");
$this->yellow->system->setDefault("editKeyboardShortcuts", "ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview"); $this->yellow->system->setDefault("editKeyboardShortcuts", "ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview");
$this->yellow->system->setDefault("editToolbarButtons", "auto"); $this->yellow->system->setDefault("editToolbarButtons", "auto");
$this->yellow->system->setDefault("editEndOfLine", "auto"); $this->yellow->system->setDefault("editEndOfLine", "auto");
@ -1535,7 +1535,7 @@ class YellowEditResponse {
$fileType = $this->yellow->toolbox->getFileType($fileNameShort); $fileType = $this->yellow->toolbox->getFileType($fileNameShort);
$locationMedia = $this->yellow->system->get("coreMediaLocation"); $locationMedia = $this->yellow->system->get("coreMediaLocation");
$locationGroup = $this->yellow->system->get("coreDownloadLocation"); $locationGroup = $this->yellow->system->get("coreDownloadLocation");
if (preg_match("/(gif|jpg|png|svg)$/", $fileType)) { if (preg_match("/(gif|jpeg|jpg|png|svg)$/", $fileType)) {
$locationGroup = $this->yellow->system->get("coreImageLocation"); $locationGroup = $this->yellow->system->get("coreImageLocation");
} }
if (preg_match("#^$locationMedia(.+?)\/#", $locationGroup, $matches)) { if (preg_match("#^$locationMedia(.+?)\/#", $locationGroup, $matches)) {

View file

@ -2,7 +2,7 @@
// Image extension, https://github.com/annaesvensson/yellow-image // Image extension, https://github.com/annaesvensson/yellow-image
class YellowImage { class YellowImage {
const VERSION = "0.9.1"; const VERSION = "0.9.2";
public $yellow; // access to API public $yellow; // access to API
// Handle initialisation // Handle initialisation
@ -10,8 +10,8 @@ class YellowImage {
$this->yellow = $yellow; $this->yellow = $yellow;
$this->yellow->system->setDefault("imageUploadWidthMax", "1280"); $this->yellow->system->setDefault("imageUploadWidthMax", "1280");
$this->yellow->system->setDefault("imageUploadHeightMax", "1280"); $this->yellow->system->setDefault("imageUploadHeightMax", "1280");
$this->yellow->system->setDefault("imageUploadJpgQuality", "80"); $this->yellow->system->setDefault("imageUploadJpegQuality", "80");
$this->yellow->system->setDefault("imageThumbnailJpgQuality", "80"); $this->yellow->system->setDefault("imageThumbnailJpegQuality", "80");
} }
// Handle update // Handle update
@ -59,19 +59,19 @@ class YellowImage {
$this->yellow->toolbox->detectImageInformation($fileName, $file->get("type")); $this->yellow->toolbox->detectImageInformation($fileName, $file->get("type"));
$widthMax = $this->yellow->system->get("imageUploadWidthMax"); $widthMax = $this->yellow->system->get("imageUploadWidthMax");
$heightMax = $this->yellow->system->get("imageUploadHeightMax"); $heightMax = $this->yellow->system->get("imageUploadHeightMax");
if ($type=="gif" || $type=="jpg" || $type=="png") { if ($type=="gif" || $type=="jpeg" || $type=="png") {
if ($widthInput>$widthMax || $heightInput>$heightMax) { if ($widthInput>$widthMax || $heightInput>$heightMax) {
list($widthOutput, $heightOutput) = $this->getImageDimensionsFit($widthInput, $heightInput, $widthMax, $heightMax); list($widthOutput, $heightOutput) = $this->getImageDimensionsFit($widthInput, $heightInput, $widthMax, $heightMax);
$image = $this->loadImage($fileName, $type); $image = $this->loadImage($fileName, $type);
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput); $image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
$image = $this->orientImage($image, $orientation); $image = $this->orientImage($image, $orientation);
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpgQuality"))) { if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpegQuality"))) {
$file->error(500, "Can't write file '$fileName'!"); $file->error(500, "Can't write file '$fileName'!");
} }
} elseif ($orientation>1) { } elseif ($orientation>1) {
$image = $this->loadImage($fileName, $type); $image = $this->loadImage($fileName, $type);
$image = $this->orientImage($image, $orientation); $image = $this->orientImage($image, $orientation);
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpgQuality"))) { if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpegQuality"))) {
$file->error(500, "Can't write file '$fileName'!"); $file->error(500, "Can't write file '$fileName'!");
} }
} }
@ -100,7 +100,7 @@ class YellowImage {
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput); $image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
$image = $this->orientImage($image, $orientation); $image = $this->orientImage($image, $orientation);
if (is_file($fileNameOutput)) $this->yellow->toolbox->deleteFile($fileNameOutput); if (is_file($fileNameOutput)) $this->yellow->toolbox->deleteFile($fileNameOutput);
if (!$this->saveImage($image, $fileNameOutput, $type, $this->yellow->system->get("imageThumbnailJpgQuality")) || if (!$this->saveImage($image, $fileNameOutput, $type, $this->yellow->system->get("imageThumbnailJpegQuality")) ||
!$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) { !$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) {
$this->yellow->page->error(500, "Can't write file '$fileNameOutput'!"); $this->yellow->page->error(500, "Can't write file '$fileNameOutput'!");
} }
@ -126,9 +126,9 @@ class YellowImage {
public function loadImage($fileName, $type) { public function loadImage($fileName, $type) {
$image = false; $image = false;
switch ($type) { switch ($type) {
case "gif": $image = @imagecreatefromgif($fileName); break; case "gif": $image = @imagecreatefromgif($fileName); break;
case "jpg": $image = @imagecreatefromjpeg($fileName); break; case "jpeg": $image = @imagecreatefromjpeg($fileName); break;
case "png": $image = @imagecreatefrompng($fileName); break; case "png": $image = @imagecreatefrompng($fileName); break;
} }
return $image; return $image;
} }
@ -137,9 +137,9 @@ class YellowImage {
public function saveImage($image, $fileName, $type, $quality) { public function saveImage($image, $fileName, $type, $quality) {
$ok = false; $ok = false;
switch ($type) { switch ($type) {
case "gif": $ok = @imagegif($image, $fileName); break; case "gif": $ok = @imagegif($image, $fileName); break;
case "jpg": $ok = @imagejpeg($image, $fileName, $quality); break; case "jpeg": $ok = @imagejpeg($image, $fileName, $quality); break;
case "png": $ok = @imagepng($image, $fileName); break; case "png": $ok = @imagepng($image, $fileName); break;
} }
return $ok; return $ok;
} }

View file

@ -381,7 +381,7 @@ class YellowInstall {
if (!$this->isServerBuiltin()) { if (!$this->isServerBuiltin()) {
$curlHandle = curl_init(); $curlHandle = curl_init();
list($scheme, $address, $base) = $this->yellow->lookup->getRequestInformation(); list($scheme, $address, $base) = $this->yellow->lookup->getRequestInformation();
$location = $this->yellow->system->get("coreThemeLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css"; $location = $this->yellow->system->get("coreAssetLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location); $url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
curl_setopt($curlHandle, CURLOPT_URL, $url); curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowInstall/".YellowInstall::VERSION).")"; curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowInstall/".YellowInstall::VERSION).")";

View file

@ -390,15 +390,17 @@ class YellowUpdate {
} }
} }
if ($this->yellow->system->get("updateEventPending")!="none") { if ($this->yellow->system->get("updateEventPending")!="none") {
foreach (explode(",", $this->yellow->system->get("updateEventPending")) as $token) { foreach (preg_split("/\s*,\s*/", $this->yellow->system->get("updateEventPending")) as $token) {
list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2); list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2);
if ($this->yellow->extension->isExisting($extension) && $action!="uninstall") { if ($action!="uninstall") {
$value = $this->yellow->extension->data[$extension]; $this->updateSystemSettings($extension, $action);
if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action); $this->updateLanguageSettings($extension, $action);
if ($this->yellow->extension->isExisting($extension)) {
$value = $this->yellow->extension->data[$extension];
if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
}
} }
} }
$this->updateSystemSettings("all", $action);
$this->updateLanguageSettings("all", $action);
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
if (!$this->yellow->system->save($fileName, array("updateEventPending" => "none"))) { if (!$this->yellow->system->save($fileName, array("updateEventPending" => "none"))) {
$this->yellow->toolbox->log("error", "Can't write file '$fileName'!"); $this->yellow->toolbox->log("error", "Can't write file '$fileName'!");
@ -470,29 +472,31 @@ class YellowUpdate {
$statusCode = 200; $statusCode = 200;
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName); $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName);
if ($action=="install" || $action=="update") { if (!is_string_empty($extension)) {
$fileDataStart = $fileDataSettings = ""; $regex = "/^".ucfirst($extension)."[A-Z]+/";
$settings = new YellowArray(); if ($action=="install" || $action=="update") {
$settings->exchangeArray($this->yellow->system->settingsDefaults->getArrayCopy()); $fileDataStart = $fileDataSettings = "";
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { $settings = new YellowArray();
if (preg_match("/^\#/", $line)) { $settings->exchangeArray($this->yellow->system->settingsDefaults->getArrayCopy());
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n"; foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
continue; if (preg_match("/^\#/", $line)) {
} if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) { continue;
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) { }
$settings[$matches[1]] = $matches[2]; if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) {
if (!preg_match($regex, $matches[1]) || $settings->isExisting($matches[1])) {
$settings[$matches[1]] = $matches[2];
}
}
} }
} }
} foreach ($settings as $key=>$value) {
foreach ($settings as $key=>$value) { $fileDataSettings .= ucfirst($key).(is_string_empty($value) ? ":\n" : ": $value\n");
$fileDataSettings .= ucfirst($key).(is_string_empty($value) ? ":\n" : ": $value\n"); }
} $fileDataNew = $fileDataStart.$fileDataSettings;
$fileDataNew = $fileDataStart.$fileDataSettings; } elseif ($action=="uninstall") {
} elseif ($action=="uninstall") {
if (!is_string_empty($extension)) {
$fileDataNew = ""; $fileDataNew = "";
$regex = "/^".ucfirst($extension)."[A-Z]+/";
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) { if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue; if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue;
@ -513,58 +517,60 @@ class YellowUpdate {
$statusCode = 200; $statusCode = 200;
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile"); $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile");
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName); $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName);
if ($action=="install" || $action=="update") { if (!is_string_empty($extension) && ucfirst($extension)!="Language") {
$fileDataStart = $fileDataSettings = $language = ""; $regex = "/^".ucfirst($extension)."[A-Z]+/";
$settings = new YellowArray(); if ($action=="install" || $action=="update") {
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { $fileDataStart = $fileDataSettings = $language = "";
if (preg_match("/^\#/", $line)) { $settings = new YellowArray();
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n"; foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
continue; if (preg_match("/^\#/", $line)) {
} if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) { continue;
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) { }
if (lcfirst($matches[1])=="language") { if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
if (!is_array_empty($settings)) { if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) {
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n"; if (lcfirst($matches[1])=="language") {
foreach ($settings as $key=>$value) { if (!is_array_empty($settings)) {
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n"; if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
foreach ($settings as $key=>$value) {
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
}
} }
} $language = $matches[2];
$language = $matches[2]; $settings = new YellowArray();
$settings = new YellowArray(); $settings["language"] = $language;
$settings["language"] = $language; $settings["languageLocale"] = "n/a";
$settings["languageLocale"] = "n/a"; $settings["languageDescription"] = "n/a";
$settings["languageDescription"] = "n/a"; $settings["languageTranslator"] = "Unknown";
$settings["languageTranslator"] = "Unknown"; foreach ($this->yellow->language->settingsDefaults as $key=>$value) {
foreach ($this->yellow->language->settingsDefaults as $key=>$value) { $require = preg_match("/^([a-z]*)[A-Z]+/", $key, $tokens) ? $tokens[1] : "core";
$require = preg_match("/^([a-z]*)[A-Z]+/", $key, $tokens) ? $tokens[1] : "core"; if ($require=="language") $require = "core";
if ($require=="language") $require = "core"; if ($this->yellow->extension->isExisting($require)) {
if ($this->yellow->extension->isExisting($require)) { if ($this->yellow->language->isText($key, $language)) {
if ($this->yellow->language->isText($key, $language)) { $settings[$key] = $this->yellow->language->getText($key, $language);
$settings[$key] = $this->yellow->language->getText($key, $language); } else {
} else { $settings[$key] = $this->yellow->language->getText($key, "en");
$settings[$key] = $this->yellow->language->getText($key, "en"); }
} }
} }
} }
} if (!is_string_empty($language)) {
if (!is_string_empty($language)) { if (!preg_match($regex, $matches[1]) || $settings->isExisting($matches[1])) {
$settings[$matches[1]] = $matches[2]; $settings[$matches[1]] = $matches[2];
}
}
} }
} }
} }
} if (!is_array_empty($settings)) {
if (!is_array_empty($settings)) { if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n"; foreach ($settings as $key=>$value) {
foreach ($settings as $key=>$value) { $fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n"; }
} }
} $fileDataNew = $fileDataStart.$fileDataSettings;
$fileDataNew = $fileDataStart.$fileDataSettings; } elseif ($action=="uninstall") {
} elseif ($action=="uninstall") {
if (!is_string_empty($extension) && ucfirst($extension)!="Language") {
$fileDataNew = ""; $fileDataNew = "";
$regex = "/^".ucfirst($extension)."[A-Z]+/";
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) { if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue; if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue;