Refactored code, updated languages

This commit is contained in:
markseu 2022-10-30 19:59:40 +01:00
parent bcff9677a7
commit cbbfde1308
4 changed files with 31 additions and 13 deletions

View file

@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore {
const VERSION = "0.8.97";
const VERSION = "0.8.98";
const RELEASE = "0.8.21";
public $page; // current page
public $content; // content files
@ -893,9 +893,9 @@ class YellowPage {
$languageError = $this->yellow->lookup->findContentLanguage($this->fileName, $this->yellow->system->get("language"));
if (is_file($fileNameError)) {
$rawData = $this->yellow->toolbox->readFile($fileNameError);
} elseif ($this->yellow->language->isText("coreError${statusCode}Title", $languageError)) {
$rawData = "---\nTitle: ".$this->yellow->language->getText("coreError${statusCode}Title", $languageError)."\n";
$rawData .= "Layout: error\n---\n".$this->yellow->language->getText("coreError${statusCode}Text", $languageError);
} elseif ($this->yellow->language->isText("coreError{$statusCode}Title", $languageError)) {
$rawData = "---\nTitle: ".$this->yellow->language->getText("coreError{$statusCode}Title", $languageError)."\n";
$rawData .= "Layout: error\n---\n".$this->yellow->language->getText("coreError{$statusCode}Text", $languageError);
} else {
$rawData = "---\nTitle:".$this->yellow->toolbox->getHttpStatusFormatted($statusCode, true)."\n";
$rawData .= "Layout:error\n---\n".$this->errorMessage;
@ -1579,6 +1579,18 @@ class YellowSystem {
public function setDefault($key, $value) {
$this->settingsDefaults[$key] = $value;
}
// Set default system settings
public function setDefaults($lines) {
foreach ($lines as $line) {
if (preg_match("/^\#/", $line)) continue;
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {
if (!empty($matches[1]) && !strempty($matches[2])) {
$this->settingsDefaults[$matches[1]] = $matches[2];
}
}
}
}
// Set system setting
public function set($key, $value) {
@ -1700,10 +1712,16 @@ class YellowLanguage {
$this->language = $language;
}
// Set default language setting
public function setDefault($key, $value, $language) {
if (!isset($this->settings[$language])) $this->settings[$language] = new YellowArray();
$this->settings[$language][$key] = $value;
$this->settingsDefaults[$key] = $value;
}
// Set default language settings
public function setDefault($text) {
public function setDefaults($lines) {
$language = "";
$lines = is_array($text) ? $text : array($text);
foreach ($lines as $line) {
if (preg_match("/^\#/", $line)) continue;
if (preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches)) {

View file

@ -2,7 +2,7 @@
// Install extension, https://github.com/annaesvensson/yellow-install
class YellowInstall {
const VERSION = "0.8.82";
const VERSION = "0.8.83";
const PRIORITY = "1";
public $yellow; // access to API
@ -414,13 +414,13 @@ class YellowInstall {
$rawData .= "<p>".$this->yellow->language->getText("installLanguage")."</p>\n<p>";
foreach ($languages as $language) {
$checked = $language==$this->yellow->language->language ? " checked=\"checked\"" : "";
$rawData .= "<label for=\"${language}-language\"><input type=\"radio\" name=\"language\" id=\"${language}-language\" value=\"$language\"$checked> ".$this->yellow->language->getTextHtml("languageDescription", $language)."</label><br />";
$rawData .= "<label for=\"{$language}-language\"><input type=\"radio\" name=\"language\" id=\"{$language}-language\" value=\"$language\"$checked> ".$this->yellow->language->getTextHtml("languageDescription", $language)."</label><br />";
}
$rawData .= "</p>\n";
$rawData .= "<p>".$this->yellow->language->getText("installExtension")."</p>\n<p>";
foreach (array("website", "wiki", "blog") as $extension) {
$checked = $extension=="website" ? " checked=\"checked\"" : "";
$rawData .= "<label for=\"${extension}-extension\"><input type=\"radio\" name=\"extension\" id=\"${extension}-extension\" value=\"$extension\"$checked> ".$this->yellow->language->getTextHtml("installExtension".ucfirst($extension))."</label><br />";
$rawData .= "<label for=\"{$extension}-extension\"><input type=\"radio\" name=\"extension\" id=\"{$extension}-extension\" value=\"$extension\"$checked> ".$this->yellow->language->getTextHtml("installExtension".ucfirst($extension))."</label><br />";
}
$rawData .= "</p>\n";
$rawData .= "<input class=\"btn\" type=\"submit\" value=\"".$this->yellow->language->getText("installButton")."\" />\n";

View file

@ -11,11 +11,11 @@ Tag: feature
system/extensions/command.php: command.php, create, update
Extension: Core
Version: 0.8.97
Version: 0.8.98
Description: Core functionality of the website.
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/core.zip
Published: 2022-10-30 00:27:11
Published: 2022-10-30 19:38:43
Developer: Mark Seuffert, David Fehrmann
Tag: feature
system/extensions/core.php: core.php, create, update
@ -54,11 +54,11 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install
Version: 0.8.82
Version: 0.8.83
Description: Install a brand new, shiny website.
DocumentationUrl: https://github.com/annaesvensson/yellow-install
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/install.zip
Published: 2022-10-28 13:07:09
Published: 2022-10-30 19:38:16
Developer: Anna Svensson
Status: unlisted
system/extensions/install.php: install.php, create