Updated core, image formats
This commit is contained in:
parent
e73b6a34dc
commit
123ec7dfdc
7 changed files with 109 additions and 124 deletions
|
@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
|
|||
system/themes/copenhagen.png: copenhagen.png, create
|
||||
|
||||
Extension: Core
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Description: Core functionality of your website.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-10 10:17:55
|
||||
Published: 2024-04-20 15:24:55
|
||||
Status: available
|
||||
system/workers/core.php: core.php, create, update
|
||||
system/extensions/core.php: coreupdate.txt, update
|
||||
|
@ -212,14 +212,14 @@ Status: available
|
|||
system/workers/dutch.php: dutch.php, create, update
|
||||
|
||||
Extension: Edit
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Description: Edit your website in a web browser.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-10 10:25:08
|
||||
Published: 2024-04-20 15:10:16
|
||||
Status: available
|
||||
system/workers/edit.php: edit.php, 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
|
||||
|
||||
Extension: Image
|
||||
Version: 0.9.1
|
||||
Version: 0.9.2
|
||||
Description: Add images and thumbnails.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-image
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-04 14:56:26
|
||||
Published: 2024-04-20 15:25:01
|
||||
Status: available
|
||||
system/workers/image.php: image.php, create, update
|
||||
media/images/photo.jpg: photo.jpg, create, optional
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# Datenstrom Yellow extension settings
|
||||
|
||||
Extension: Core
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Description: Core functionality of your website.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-10 10:17:55
|
||||
Published: 2024-04-20 15:24:55
|
||||
Status: available
|
||||
system/workers/core.php: core.php, create, 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
|
||||
|
||||
Extension: Edit
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Description: Edit your website in a web browser.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-10 10:25:08
|
||||
Published: 2024-04-20 15:10:16
|
||||
Status: available
|
||||
system/workers/edit.php: edit.php, create, update
|
||||
system/workers/edit.css: edit.css, create, update
|
||||
|
@ -48,14 +48,14 @@ Status: available
|
|||
system/workers/generate.php: generate.php, create, update
|
||||
|
||||
Extension: Image
|
||||
Version: 0.9.1
|
||||
Version: 0.9.2
|
||||
Description: Add images and thumbnails.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-image
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-04 14:56:26
|
||||
Published: 2024-04-20 15:25:01
|
||||
Status: available
|
||||
system/workers/image.php: image.php, create, update
|
||||
media/images/photo.jpg: photo.jpg, create, optional
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Core extension, https://github.com/annaesvensson/yellow-core
|
||||
|
||||
class YellowCore {
|
||||
const VERSION = "0.9.3";
|
||||
const VERSION = "0.9.4";
|
||||
const RELEASE = "0.9";
|
||||
public $content; // content files
|
||||
public $media; // media files
|
||||
|
@ -82,8 +82,6 @@ class YellowCore {
|
|||
$this->system->set("coreServerInstallDirectory", $pathInstall);
|
||||
$this->system->set("coreServerRootDirectory", $pathRoot);
|
||||
$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"));
|
||||
if ($this->system->get("coreDebugMode")>=1) {
|
||||
ini_set("display_errors", 1);
|
||||
|
@ -730,7 +728,6 @@ class YellowSystem {
|
|||
}
|
||||
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
|
||||
public function getSettings($filterStart = "", $filterEnd = "") {
|
||||
|
@ -1861,7 +1858,7 @@ class YellowLookup {
|
|||
|
||||
// Check if file is a well-known file type
|
||||
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
|
||||
|
@ -2013,6 +2010,7 @@ class YellowToolbox {
|
|||
"ico" => "image/x-icon",
|
||||
"js" => "application/javascript",
|
||||
"json" => "application/json",
|
||||
"jpeg" => "image/jpeg",
|
||||
"jpg" => "image/jpeg",
|
||||
"md" => "text/markdown",
|
||||
"png" => "image/png",
|
||||
|
@ -2139,9 +2137,6 @@ class YellowToolbox {
|
|||
return $ok;
|
||||
}
|
||||
|
||||
// TODO: remove later, for backwards compatibility
|
||||
public function createFile($fileName, $fileData, $mkdir = false) { return $this->writeFile($fileName, $fileData, $mkdir); }
|
||||
|
||||
// Append file
|
||||
public function appendFile($fileName, $fileData, $mkdir = false) {
|
||||
$ok = false;
|
||||
|
@ -2788,7 +2783,7 @@ class YellowToolbox {
|
|||
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 = "") {
|
||||
$width = $height = $orientation = 0;
|
||||
$type = "";
|
||||
|
@ -2803,7 +2798,7 @@ class YellowToolbox {
|
|||
$height = (ord($dataHeader[3])<<8) + ord($dataHeader[2]);
|
||||
$type = $fileType;
|
||||
}
|
||||
} elseif ($fileType=="jpg") {
|
||||
} elseif ($fileType=="jpeg" || $fileType=="jpg") {
|
||||
$dataBufferSizeMax = filesize($fileName);
|
||||
$dataBufferSize = min($dataBufferSizeMax, 4096);
|
||||
if ($dataBufferSize) $dataBuffer = fread($fileHandle, $dataBufferSize);
|
||||
|
@ -2987,10 +2982,6 @@ class YellowToolbox {
|
|||
public function isNotModified($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 {
|
||||
|
@ -3164,10 +3155,6 @@ class YellowPage {
|
|||
$output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type);
|
||||
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 ($name=="yellow" && $type=="inline" && $text=="error") {
|
||||
|
@ -3180,9 +3167,6 @@ class YellowPage {
|
|||
return $output;
|
||||
}
|
||||
|
||||
// TODO: remove later, for backwards compatibility
|
||||
public function parseContentShortcut($name, $text, $type) { return $this->parseContentElement($name, $text, "", $type); }
|
||||
|
||||
// Parse page
|
||||
public function parsePage() {
|
||||
$this->parsePageLayout($this->get("layout"));
|
||||
|
@ -3567,10 +3551,6 @@ class YellowPage {
|
|||
public function isPage($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 {
|
||||
|
@ -3984,7 +3964,6 @@ function substrb() {
|
|||
function is_string_empty($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
|
||||
function is_array_empty($array) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Edit extension, https://github.com/annaesvensson/yellow-edit
|
||||
|
||||
class YellowEdit {
|
||||
const VERSION = "0.9.3";
|
||||
const VERSION = "0.9.4";
|
||||
public $yellow; // access to API
|
||||
public $response; // web response
|
||||
public $merge; // text merge
|
||||
|
@ -16,7 +16,7 @@ class YellowEdit {
|
|||
$this->yellow->system->setDefault("editSiteEmail", "noreply");
|
||||
$this->yellow->system->setDefault("editLocation", "/edit/");
|
||||
$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("editToolbarButtons", "auto");
|
||||
$this->yellow->system->setDefault("editEndOfLine", "auto");
|
||||
|
@ -1535,7 +1535,7 @@ class YellowEditResponse {
|
|||
$fileType = $this->yellow->toolbox->getFileType($fileNameShort);
|
||||
$locationMedia = $this->yellow->system->get("coreMediaLocation");
|
||||
$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");
|
||||
}
|
||||
if (preg_match("#^$locationMedia(.+?)\/#", $locationGroup, $matches)) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Image extension, https://github.com/annaesvensson/yellow-image
|
||||
|
||||
class YellowImage {
|
||||
const VERSION = "0.9.1";
|
||||
const VERSION = "0.9.2";
|
||||
public $yellow; // access to API
|
||||
|
||||
// Handle initialisation
|
||||
|
@ -10,8 +10,8 @@ class YellowImage {
|
|||
$this->yellow = $yellow;
|
||||
$this->yellow->system->setDefault("imageUploadWidthMax", "1280");
|
||||
$this->yellow->system->setDefault("imageUploadHeightMax", "1280");
|
||||
$this->yellow->system->setDefault("imageUploadJpgQuality", "80");
|
||||
$this->yellow->system->setDefault("imageThumbnailJpgQuality", "80");
|
||||
$this->yellow->system->setDefault("imageUploadJpegQuality", "80");
|
||||
$this->yellow->system->setDefault("imageThumbnailJpegQuality", "80");
|
||||
}
|
||||
|
||||
// Handle update
|
||||
|
@ -59,19 +59,19 @@ class YellowImage {
|
|||
$this->yellow->toolbox->detectImageInformation($fileName, $file->get("type"));
|
||||
$widthMax = $this->yellow->system->get("imageUploadWidthMax");
|
||||
$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) {
|
||||
list($widthOutput, $heightOutput) = $this->getImageDimensionsFit($widthInput, $heightInput, $widthMax, $heightMax);
|
||||
$image = $this->loadImage($fileName, $type);
|
||||
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
|
||||
$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'!");
|
||||
}
|
||||
} elseif ($orientation>1) {
|
||||
$image = $this->loadImage($fileName, $type);
|
||||
$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'!");
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class YellowImage {
|
|||
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
|
||||
$image = $this->orientImage($image, $orientation);
|
||||
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->page->error(500, "Can't write file '$fileNameOutput'!");
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ class YellowImage {
|
|||
public function loadImage($fileName, $type) {
|
||||
$image = false;
|
||||
switch ($type) {
|
||||
case "gif": $image = @imagecreatefromgif($fileName); break;
|
||||
case "jpg": $image = @imagecreatefromjpeg($fileName); break;
|
||||
case "png": $image = @imagecreatefrompng($fileName); break;
|
||||
case "gif": $image = @imagecreatefromgif($fileName); break;
|
||||
case "jpeg": $image = @imagecreatefromjpeg($fileName); break;
|
||||
case "png": $image = @imagecreatefrompng($fileName); break;
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ class YellowImage {
|
|||
public function saveImage($image, $fileName, $type, $quality) {
|
||||
$ok = false;
|
||||
switch ($type) {
|
||||
case "gif": $ok = @imagegif($image, $fileName); break;
|
||||
case "jpg": $ok = @imagejpeg($image, $fileName, $quality); break;
|
||||
case "png": $ok = @imagepng($image, $fileName); break;
|
||||
case "gif": $ok = @imagegif($image, $fileName); break;
|
||||
case "jpeg": $ok = @imagejpeg($image, $fileName, $quality); break;
|
||||
case "png": $ok = @imagepng($image, $fileName); break;
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ class YellowInstall {
|
|||
if (!$this->isServerBuiltin()) {
|
||||
$curlHandle = curl_init();
|
||||
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);
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowInstall/".YellowInstall::VERSION).")";
|
||||
|
|
|
@ -390,15 +390,17 @@ class YellowUpdate {
|
|||
}
|
||||
}
|
||||
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);
|
||||
if ($this->yellow->extension->isExisting($extension) && $action!="uninstall") {
|
||||
$value = $this->yellow->extension->data[$extension];
|
||||
if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
|
||||
if ($action!="uninstall") {
|
||||
$this->updateSystemSettings($extension, $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");
|
||||
if (!$this->yellow->system->save($fileName, array("updateEventPending" => "none"))) {
|
||||
$this->yellow->toolbox->log("error", "Can't write file '$fileName'!");
|
||||
|
@ -470,29 +472,31 @@ class YellowUpdate {
|
|||
$statusCode = 200;
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
|
||||
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName);
|
||||
if ($action=="install" || $action=="update") {
|
||||
$fileDataStart = $fileDataSettings = "";
|
||||
$settings = new YellowArray();
|
||||
$settings->exchangeArray($this->yellow->system->settingsDefaults->getArrayCopy());
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\#/", $line)) {
|
||||
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
|
||||
continue;
|
||||
}
|
||||
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
|
||||
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) {
|
||||
$settings[$matches[1]] = $matches[2];
|
||||
if (!is_string_empty($extension)) {
|
||||
$regex = "/^".ucfirst($extension)."[A-Z]+/";
|
||||
if ($action=="install" || $action=="update") {
|
||||
$fileDataStart = $fileDataSettings = "";
|
||||
$settings = new YellowArray();
|
||||
$settings->exchangeArray($this->yellow->system->settingsDefaults->getArrayCopy());
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\#/", $line)) {
|
||||
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
|
||||
continue;
|
||||
}
|
||||
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) {
|
||||
$fileDataSettings .= ucfirst($key).(is_string_empty($value) ? ":\n" : ": $value\n");
|
||||
}
|
||||
$fileDataNew = $fileDataStart.$fileDataSettings;
|
||||
} elseif ($action=="uninstall") {
|
||||
if (!is_string_empty($extension)) {
|
||||
foreach ($settings as $key=>$value) {
|
||||
$fileDataSettings .= ucfirst($key).(is_string_empty($value) ? ":\n" : ": $value\n");
|
||||
}
|
||||
$fileDataNew = $fileDataStart.$fileDataSettings;
|
||||
} elseif ($action=="uninstall") {
|
||||
$fileDataNew = "";
|
||||
$regex = "/^".ucfirst($extension)."[A-Z]+/";
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
|
||||
if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue;
|
||||
|
@ -513,58 +517,60 @@ class YellowUpdate {
|
|||
$statusCode = 200;
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile");
|
||||
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileName);
|
||||
if ($action=="install" || $action=="update") {
|
||||
$fileDataStart = $fileDataSettings = $language = "";
|
||||
$settings = new YellowArray();
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\#/", $line)) {
|
||||
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
|
||||
continue;
|
||||
}
|
||||
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
|
||||
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) {
|
||||
if (lcfirst($matches[1])=="language") {
|
||||
if (!is_array_empty($settings)) {
|
||||
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
|
||||
foreach ($settings as $key=>$value) {
|
||||
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
|
||||
if (!is_string_empty($extension) && ucfirst($extension)!="Language") {
|
||||
$regex = "/^".ucfirst($extension)."[A-Z]+/";
|
||||
if ($action=="install" || $action=="update") {
|
||||
$fileDataStart = $fileDataSettings = $language = "";
|
||||
$settings = new YellowArray();
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\#/", $line)) {
|
||||
if (is_string_empty($fileDataStart)) $fileDataStart = $line."\n";
|
||||
continue;
|
||||
}
|
||||
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
|
||||
if (!is_string_empty($matches[1]) && !is_string_empty($matches[2])) {
|
||||
if (lcfirst($matches[1])=="language") {
|
||||
if (!is_array_empty($settings)) {
|
||||
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
|
||||
foreach ($settings as $key=>$value) {
|
||||
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$language = $matches[2];
|
||||
$settings = new YellowArray();
|
||||
$settings["language"] = $language;
|
||||
$settings["languageLocale"] = "n/a";
|
||||
$settings["languageDescription"] = "n/a";
|
||||
$settings["languageTranslator"] = "Unknown";
|
||||
foreach ($this->yellow->language->settingsDefaults as $key=>$value) {
|
||||
$require = preg_match("/^([a-z]*)[A-Z]+/", $key, $tokens) ? $tokens[1] : "core";
|
||||
if ($require=="language") $require = "core";
|
||||
if ($this->yellow->extension->isExisting($require)) {
|
||||
if ($this->yellow->language->isText($key, $language)) {
|
||||
$settings[$key] = $this->yellow->language->getText($key, $language);
|
||||
} else {
|
||||
$settings[$key] = $this->yellow->language->getText($key, "en");
|
||||
$language = $matches[2];
|
||||
$settings = new YellowArray();
|
||||
$settings["language"] = $language;
|
||||
$settings["languageLocale"] = "n/a";
|
||||
$settings["languageDescription"] = "n/a";
|
||||
$settings["languageTranslator"] = "Unknown";
|
||||
foreach ($this->yellow->language->settingsDefaults as $key=>$value) {
|
||||
$require = preg_match("/^([a-z]*)[A-Z]+/", $key, $tokens) ? $tokens[1] : "core";
|
||||
if ($require=="language") $require = "core";
|
||||
if ($this->yellow->extension->isExisting($require)) {
|
||||
if ($this->yellow->language->isText($key, $language)) {
|
||||
$settings[$key] = $this->yellow->language->getText($key, $language);
|
||||
} else {
|
||||
$settings[$key] = $this->yellow->language->getText($key, "en");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_string_empty($language)) {
|
||||
$settings[$matches[1]] = $matches[2];
|
||||
if (!is_string_empty($language)) {
|
||||
if (!preg_match($regex, $matches[1]) || $settings->isExisting($matches[1])) {
|
||||
$settings[$matches[1]] = $matches[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_array_empty($settings)) {
|
||||
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
|
||||
foreach ($settings as $key=>$value) {
|
||||
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
|
||||
if (!is_array_empty($settings)) {
|
||||
if (!is_string_empty($fileDataSettings)) $fileDataSettings .= "\n";
|
||||
foreach ($settings as $key=>$value) {
|
||||
$fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$fileDataNew = $fileDataStart.$fileDataSettings;
|
||||
} elseif ($action=="uninstall") {
|
||||
if (!is_string_empty($extension) && ucfirst($extension)!="Language") {
|
||||
$fileDataNew = $fileDataStart.$fileDataSettings;
|
||||
} elseif ($action=="uninstall") {
|
||||
$fileDataNew = "";
|
||||
$regex = "/^".ucfirst($extension)."[A-Z]+/";
|
||||
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
|
||||
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
|
||||
if (!is_string_empty($matches[1]) && preg_match($regex, $matches[1])) continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue