Refactored extensions

This commit is contained in:
markseu 2021-06-17 14:26:39 +02:00
parent eddfcca3b1
commit f4e8b4c3a4
4 changed files with 29 additions and 28 deletions

View file

@ -2,7 +2,7 @@
// Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core
class YellowCore {
const VERSION = "0.8.45";
const VERSION = "0.8.46";
const RELEASE = "0.8.17";
public $page; // current page
public $content; // content files
@ -28,9 +28,9 @@ class YellowCore {
$this->system->setDefault("sitename", "Yellow");
$this->system->setDefault("author", "Yellow");
$this->system->setDefault("email", "webmaster");
$this->system->setDefault("theme", "default");
$this->system->setDefault("language", "en");
$this->system->setDefault("layout", "default");
$this->system->setDefault("theme", "default");
$this->system->setDefault("parser", "markdown");
$this->system->setDefault("status", "public");
$this->system->setDefault("coreStaticUrl", "");
@ -76,7 +76,7 @@ class YellowCore {
// Check requirements
public function checkRequirements() {
$troubleshooting = PHP_SAPI!="cli" ? "<a href=\"".$this->getTroubleshootingUrl()."\">See troubleshooting</a>." : "";
version_compare(PHP_VERSION, "5.6", ">=") || die("Datenstrom Yellow requires PHP 5.6 or higher! $troubleshooting\n");
version_compare(PHP_VERSION, "5.5", ">=") || die("Datenstrom Yellow requires PHP 5.6 or higher! $troubleshooting\n");
extension_loaded("curl") || die("Datenstrom Yellow requires PHP curl extension! $troubleshooting\n");
extension_loaded("gd") || die("Datenstrom Yellow requires PHP gd extension! $troubleshooting\n");
extension_loaded("mbstring") || die("Datenstrom Yellow requires PHP mbstring extension! $troubleshooting\n");
@ -228,11 +228,11 @@ class YellowCore {
foreach ($this->page->headerData as $key=>$value) {
echo "YellowCore::sendPage $key: $value<br/>\n";
}
$theme = $this->page->get("theme");
$language = $this->page->get("language");
$layout = $this->page->get("layout");
$theme = $this->page->get("theme");
$parser = $this->page->get("parser");
echo "YellowCore::sendPage language:$language layout:$layout theme:$theme parser:$parser<br/>\n";
echo "YellowCore::sendPage theme:$theme language:$language layout:$layout parser:$parser<br/>\n";
}
return $statusCode;
}
@ -292,7 +292,7 @@ class YellowCore {
}
if ($statusCode==0 && empty($command)) {
$lineCounter = 0;
echo "Datenstrom Yellow is for people who make small websites.\n";
echo "Datenstrom Yellow is for people who make small websites. https://datenstrom.se/yellow/\n";
foreach ($this->getCommandHelp() as $line) {
echo(++$lineCounter>1 ? " " : "Syntax: ")."php yellow.php $line\n";
}
@ -493,7 +493,7 @@ class YellowPage {
$this->set("title", $this->yellow->toolbox->createTextTitle($this->location));
$this->set("language", $this->yellow->lookup->findLanguageFromFile($this->fileName, $this->yellow->system->get("language")));
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
$this->parseMetaRaw(array("sitename", "author", "layout", "theme", "parser", "status"));
$this->parseMetaRaw(array("sitename", "author", "theme", "layout", "parser", "status"));
$titleHeader = ($this->location==$this->yellow->content->getHomeLocation($this->location)) ?
$this->get("sitename") : $this->get("title")." - ".$this->get("sitename");
if (!$this->isExisting("titleContent")) $this->set("titleContent", $this->get("title"));
@ -623,12 +623,12 @@ class YellowPage {
if (!is_file($fileNameTheme)) {
$this->error(500, "Theme '".$this->get("theme")."' does not exist!");
}
if (!is_object($this->parser)) {
$this->error(500, "Parser '".$this->get("parser")."' does not exist!");
}
if (!$this->yellow->language->isExisting($this->get("language"))) {
$this->error(500, "Language '".$this->get("language")."' does not exist!");
}
if (!is_object($this->parser)) {
$this->error(500, "Parser '".$this->get("parser")."' does not exist!");
}
if ($this->yellow->lookup->isNestedLocation($this->location, $this->fileName, true)) {
$this->error(500, "Folder '".dirname($this->fileName)."' may not contain subfolders!");
}
@ -1629,6 +1629,11 @@ class YellowSystem {
foreach ($this->yellow->user->settings as $userKey=>$userValue) {
array_push($values, $userKey);
}
} elseif ($key=="theme") {
$path = $this->yellow->system->get("coreThemeDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.css$/", true, false, false) as $entry) {
array_push($values, lcfirst(substru($entry, 0, -4)));
}
} elseif ($key=="language") {
foreach ($this->yellow->language->settings as $languageKey=>$languageValue) {
array_push($values, $languageKey);
@ -1638,11 +1643,6 @@ class YellowSystem {
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.html$/", true, false, false) as $entry) {
array_push($values, lcfirst(substru($entry, 0, -5)));
}
} elseif ($key=="theme") {
$path = $this->yellow->system->get("coreThemeDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.css$/", true, false, false) as $entry) {
array_push($values, lcfirst(substru($entry, 0, -4)));
}
}
return $values;
}

View file

@ -21,11 +21,11 @@ Tag: feature
system/extensions/command.php: command.php, create, update
Extension: Core
Version: 0.8.45
Version: 0.8.46
Description: Core functionality of the website.
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip
Published: 2021-06-10 21:53:13
Published: 2021-06-17 09:22:19
Developer: Datenstrom
Tag: feature
system/extensions/core.php: core.php, create, update
@ -112,11 +112,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea
system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful
Extension: Update
Version: 0.8.52
Version: 0.8.53
Description: Keep your website up to date.
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
Published: 2021-05-26 10:21:13
Published: 2021-06-16 17:20:19
Developer: Datenstrom
Tag: feature
system/extensions/update.php: update.php, create, update

View file

@ -2,7 +2,7 @@
// Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update
class YellowUpdate {
const VERSION = "0.8.52";
const VERSION = "0.8.53";
const PRIORITY = "2";
public $yellow; // access to API
public $updates; // number of updates
@ -120,8 +120,9 @@ class YellowUpdate {
// Process command to show website version and updates
public function processCommandAbout($command, $text) {
echo "Datenstrom Yellow ".YellowCore::RELEASE."\n";
list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
list($statusCode, $settingsLatest) = $this->getExtensionSettings(true);
list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
$statusCode = max($statusCodeCurrent, $statusCodeLatest);
foreach ($settingsCurrent as $key=>$value) {
$versionCurrent = $versionLatest = $settingsCurrent[$key]->get("version");
if ($settingsLatest->isExisting($key)) $versionLatest = $settingsLatest[$key]->get("version");
@ -217,11 +218,11 @@ class YellowUpdate {
public function showExtensions() {
list($statusCode, $settingsLatest) = $this->getExtensionSettings(true);
foreach ($settingsLatest as $key=>$value) {
$text = $description = $value->get("description");
if ($value->isExisting("developer")) $text = "$description Developed by ".$value["developer"].".";
if ($value->isExisting("translator")) $text = "$description Translated by ".$value["translator"].".";
if ($value->isExisting("designer")) $text = "$description Designed by ".$value["designer"].".";
echo ucfirst($key).": $text\n";
$description = $text = $value->get("description");
if ($value->isExisting("developer")) $description = "$text Developed by ".$value["developer"].".";
if ($value->isExisting("designer")) $description = "$text Designed by ".$value["designer"].".";
if ($value->isExisting("translator")) $description = "$text Translated by ".$value["translator"].".";
echo ucfirst($key).": $description\n";
}
if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->get("pageError")."\n";
return $statusCode;

View file

@ -3,9 +3,9 @@
Sitename: Datenstrom Yellow
Author: Datenstrom
Email: webmaster
Theme: stockholm
Language: en
Layout: default
Theme: stockholm
Parser: markdown
Status: public
CoreStaticUrl: