mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit f64ca3f8fe10da467d88bb31b1f4791d7391a0bb
parent 1c1a2a44dd16f5a03807e6683904682103422a52
Author: markseu <mark2011@mayberg.se>
Date:   Wed, 24 May 2023 13:35:41 +0200

Updated API, spring remix

Diffstat:
Msystem/extensions/core.php | 63++++++++++++++++++++++++++++-----------------------------------
Msystem/extensions/update-current.ini | 4++--
2 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/annaesvensson/yellow-core class YellowCore { - const VERSION = "0.8.114"; + const VERSION = "0.8.115"; const RELEASE = "0.8.22"; public $content; // content files public $media; // media files @@ -10,8 +10,8 @@ class YellowCore { public $language; // language settings public $user; // user settings public $extension; // extensions - public $lookup; // lookup and normalisation - public $toolbox; // toolbox with helper functions + public $lookup; // lookup and normalisation methods + public $toolbox; // toolbox with helper methods public $page; // current page public function __construct() { @@ -168,7 +168,7 @@ class YellowCore { $this->toolbox->log("error", "Can't parse file '$fileName'!"); $this->toolbox->sendHttpHeader($this->toolbox->getHttpStatusFormatted(500)); $troubleshooting = PHP_SAPI!="cli" ? - "<a href=\"".$this->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->getTroubleshootingUrl(); + "<a href=\"".$this->toolbox->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->toolbox->getTroubleshootingUrl(); echo "<br/>\nDatenstrom Yellow stopped with fatal error. Activate the debug mode for more information. $troubleshooting\n"; } } @@ -177,7 +177,7 @@ class YellowCore { public function exitFatalError($errorMessage = "") { $this->toolbox->sendHttpHeader($this->toolbox->getHttpStatusFormatted(500)); $troubleshooting = PHP_SAPI!="cli" ? - "<a href=\"".$this->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->getTroubleshootingUrl(); + "<a href=\"".$this->toolbox->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->toolbox->getTroubleshootingUrl(); echo "$errorMessage $troubleshooting\n"; exit(1); } @@ -262,11 +262,16 @@ class YellowCore { } } if ($statusCode==0 && is_string_empty($command)) { - $lineCounter = 0; - 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"; + $lines = array(); + foreach ($this->extension->data as $key=>$value) { + if (method_exists($value["object"], "onCommandHelp")) { + $this->lookup->commandHandler = $key; + $output = $value["object"]->onCommandHelp(); + $lines = array_merge($lines, is_array($output) ? $output : array($output)); + } } + usort($lines, "strnatcasecmp"); + $this->showCommandHelp($lines); $statusCode = 200; } if ($statusCode==0) { @@ -281,6 +286,15 @@ class YellowCore { return $statusCode<400 ? 0 : 1; } + // Show command help + public function showCommandHelp($lines) { + echo "Datenstrom Yellow is for people who make small websites. https://datenstrom.se/yellow/\n"; + $lineCounter = 0; + foreach ($lines as $line) { + echo(++$lineCounter>1 ? " " : "Syntax: ")."php yellow.php $line\n"; + } + } + // Handle startup public function startup() { if (isset($this->extension->data)) { @@ -309,32 +323,6 @@ class YellowCore { public function getLayoutArguments($sizeMin = 9) { return array_pad($this->lookup->layoutArguments, $sizeMin, null); } - - // Return command help - public function getCommandHelp() { - $data = array(); - foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["object"], "onCommandHelp")) { - $output = $value["object"]->onCommandHelp(); - $lines = is_array($output) ? $output : array($output); - foreach ($lines as $line) { - list($command, $dummy) = $this->toolbox->getTextList($line, " ", 2); - if (!is_string_empty($command) && !isset($data[$command])) $data[$command] = $line; - } - } - } - uksort($data, "strnatcasecmp"); - return $data; - } - - // Return troubleshooting URL - public function getTroubleshootingUrl() { - return "https://datenstrom.se/yellow/help/troubleshooting"; - } - - // TODO: remove later, for backwards compatibility - public function log($action, $message) { $this->toolbox->log($action, $message); } - public function isCommandLine() { return $this->lookup->isCommandLine(); } } class YellowContent { @@ -2597,6 +2585,11 @@ class YellowToolbox { } return $rawDataNew; } + + // Return troubleshooting URL + public function getTroubleshootingUrl() { + return "https://datenstrom.se/yellow/help/troubleshooting"; + } // Detect server URL public function detectServerUrl() { diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -1,11 +1,11 @@ # Datenstrom Yellow update settings Extension: Core -Version: 0.8.114 +Version: 0.8.115 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: 2023-05-19 13:37:00 +Published: 2023-05-24 13:27:21 Developer: Mark Seuffert, David Fehrmann Tag: feature system/extensions/core.php: core.php, create, update