commit 7566f0ae305d02df2278eea28cb2bdf607d1281a
parent f9f60b8a949ad0820e032f84fde3faf873e0b2c6
Author: markseu <mark2011@mayberg.se>
Date: Mon, 26 Sep 2022 20:03:07 +0200
Updated command line, detailed information
Diffstat:
3 files changed, 78 insertions(+), 69 deletions(-)
diff --git a/system/extensions/command.php b/system/extensions/command.php
@@ -2,7 +2,7 @@
// Command extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/command
class YellowCommand {
- const VERSION = "0.8.41";
+ const VERSION = "0.8.42";
public $yellow; // access to API
public $files; // number of files
public $links; // number of links
@@ -26,7 +26,6 @@ class YellowCommand {
// Handle command
public function onCommand($command, $text) {
switch ($command) {
- case "about": $statusCode = $this->processCommandAbout($command, $text); break;
case "build": $statusCode = $this->processCommandBuild($command, $text); break;
case "check": $statusCode = $this->processCommandCheck($command, $text); break;
case "clean": $statusCode = $this->processCommandClean($command, $text); break;
@@ -37,31 +36,11 @@ class YellowCommand {
// Handle command help
public function onCommandHelp() {
- $help = "about\n";
- $help .= "build [directory location]\n";
+ $help = "build [directory location]\n";
$help .= "check [directory location]\n";
$help .= "clean [directory location]\n";
return $help;
}
-
- // Process command to show current version and extensions
- public function processCommandAbout($command, $text) {
- echo "Datenstrom Yellow ".YellowCore::RELEASE." - https://datenstrom.se/yellow/\n";
- if ($this->yellow->extension->isExisting("update")) {
- list($dummy, $settingsCurrent) = $this->yellow->extension->get("update")->getExtensionSettings(false);
- foreach ($settingsCurrent as $key=>$value) {
- $documentation = $value->isExisting("documentationUrl") ? $value->get("documentationUrl") : "No documentation available";
- echo ucfirst($key)." ".$value->get("version")." - $documentation\n";
- }
- } else {
- $dataCurrent = $this->yellow->extension->data;
- uksort($dataCurrent, "strnatcasecmp");
- foreach ($dataCurrent as $key=>$value) {
- echo ucfirst($key)." ".$value["version"]."\n";
- }
- }
- return 200;
- }
// Process command to build static website
public function processCommandBuild($command, $text) {
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -11,11 +11,11 @@ Tag: feature
system/extensions/bundle.php: bundle.php, create, update
Extension: Command
-Version: 0.8.41
+Version: 0.8.42
Description: Command line of the website.
DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/command
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/command.zip
-Published: 2022-06-11 12:13:10
+Published: 2022-09-22 10:13:59
Developer: Datenstrom
Tag: feature
system/extensions/command.php: command.php, create, update
@@ -131,11 +131,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.80
+Version: 0.8.81
Description: Keep your website up to date.
DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
-Published: 2022-05-16 17:28:11
+Published: 2022-09-26 19:42:02
Developer: Datenstrom
Tag: feature
system/extensions/update.php: update.php, create, update
diff --git a/system/extensions/update.php b/system/extensions/update.php
@@ -2,7 +2,7 @@
// Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update
class YellowUpdate {
- const VERSION = "0.8.80";
+ const VERSION = "0.8.81";
const PRIORITY = "2";
public $yellow; // access to API
public $extensions; // number of extensions
@@ -53,6 +53,7 @@ class YellowUpdate {
$statusCode = $this->processCommandPending();
if ($statusCode==0) {
switch ($command) {
+ case "about": $statusCode = $this->processCommandAbout($command, $text); break;
case "install": $statusCode = $this->processCommandInstall($command, $text); break;
case "uninstall": $statusCode = $this->processCommandUninstall($command, $text); break;
case "update": $statusCode = $this->processCommandUpdate($command, $text); break;
@@ -64,7 +65,8 @@ class YellowUpdate {
// Handle command help
public function onCommandHelp() {
- $help = "install [extension]\n";
+ $help = "about [extension]\n";
+ $help .= "install [extension]\n";
$help .= "uninstall [extension]\n";
$help .= "update [extension]\n";
return $help;
@@ -74,16 +76,14 @@ class YellowUpdate {
public function onParseContentShortcut($page, $name, $text, $type) {
$output = null;
if ($name=="yellow" && $type=="inline") {
- if ($text=="release") $output = "Datenstrom Yellow ".YellowCore::RELEASE;
if ($text=="about") {
- $url = $this->yellow->language->getText("editYellowUrl", $page->get("language"));
- $output = "Datenstrom Yellow ".YellowCore::RELEASE." - <a href=\"".htmlspecialchars($url)."\">".htmlspecialchars($url)."</a><br />\n";
list($dummy, $settingsCurrent) = $this->getExtensionSettings(false);
+ $output = "Datenstrom Yellow ".YellowCore::RELEASE."<br />\n";
foreach ($settingsCurrent as $key=>$value) {
- $documentation = $value->isExisting("documentationUrl") ? "<a href=\"".htmlspecialchars($value->get("documentationUrl"))."\">".htmlspecialchars($value->get("documentationUrl"))."</a>" : "No documentation available";
- $output .= ucfirst($key)." ".$value->get("version")." - $documentation<br />\n";
+ $output .= ucfirst($key)." ".$value->get("version")."<br />\n";
}
}
+ if ($text=="release") $output = "Datenstrom Yellow ".YellowCore::RELEASE;
if ($text=="log") {
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreWebsiteFile");
$fileHandle = @fopen($fileName, "r");
@@ -102,6 +102,29 @@ class YellowUpdate {
return $output;
}
+ // Process command to show current version
+ public function processCommandAbout($command, $text) {
+ $statusCode = 200;
+ $extensions = $this->getExtensionsFromText($text);
+ if (!empty($extensions)) {
+ list($statusCode, $settings) = $this->getExtensionAboutInformation($extensions);
+ if ($statusCode==200) {
+ foreach ($settings as $key=>$value) {
+ echo ucfirst($key)." ".$value->get("version")." - ".$this->getExtensionDescription($key, $value)."\n";
+ echo $this->getExtensionDocumentation($key, $value)."\n";
+ }
+ }
+ if ($statusCode>=400) echo "ERROR checking extensions: ".$this->yellow->page->errorMessage."\n";
+ } else {
+ echo "Datenstrom Yellow ".YellowCore::RELEASE."\n";
+ list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
+ foreach ($settingsCurrent as $key=>$value) {
+ echo ucfirst($key)." ".$value->get("version")."\n";
+ }
+ }
+ return $statusCode;
+ }
+
// Process command to install extensions
public function processCommandInstall($command, $text) {
$extensions = $this->getExtensionsFromText($text);
@@ -114,7 +137,11 @@ class YellowUpdate {
echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." installed\n";
} else {
- $statusCode = $this->showExtensions(true);
+ list($statusCode, $settingsLatest) = $this->getExtensionSettings(true);
+ foreach ($settingsLatest as $key=>$value) {
+ echo ucfirst($key)." - ".$this->getExtensionDescription($key, $value)."\n";
+ }
+ if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->errorMessage."\n";
}
return $statusCode;
}
@@ -124,13 +151,17 @@ class YellowUpdate {
$extensions = $this->getExtensionsFromText($text);
if (!empty($extensions)) {
$this->extensions = 0;
- list($statusCode, $settings) = $this->getExtensionUninstallInformation($extensions, "core, update");
+ list($statusCode, $settings) = $this->getExtensionAboutInformation($extensions, "core, update");
if ($statusCode==200) $statusCode = $this->removeExtensions($settings);
if ($statusCode>=400) echo "ERROR uninstalling files: ".$this->yellow->page->errorMessage."\n";
echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." uninstalled\n";
} else {
- $statusCode = $this->showExtensions(false);
+ list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
+ foreach ($settingsCurrent as $key=>$value) {
+ echo ucfirst($key)." - ".$this->getExtensionDescription($key, $value)."\n";
+ }
+ if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->errorMessage."\n";
}
return $statusCode;
}
@@ -195,21 +226,6 @@ class YellowUpdate {
return $statusCode;
}
- // Show extensions
- public function showExtensions($latest) {
- list($statusCode, $settings) = $this->getExtensionSettings($latest);
- foreach ($settings as $key=>$value) {
- $text = $value->isExisting("description") ? $value->get("description") : "No description available.";
- $description = $text;
- 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->errorMessage."\n";
- return $statusCode;
- }
-
// Download extensions
public function downloadExtensions($settings) {
$statusCode = 200;
@@ -597,18 +613,16 @@ class YellowUpdate {
public function getExtensionsFromText($text) {
return array_unique(array_filter($this->yellow->toolbox->getTextArguments($text), "strlen"));
}
-
- // Return extension install information
- public function getExtensionInstallInformation($extensions) {
+
+ // Return extension about information
+ public function getExtensionAboutInformation($extensions, $extensionsProtected = "") {
$settings = array();
- list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
- list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
- $statusCode = max($statusCodeCurrent, $statusCodeLatest);
+ list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
foreach ($extensions as $extension) {
$found = false;
- foreach ($settingsLatest as $key=>$value) {
+ foreach ($settingsCurrent as $key=>$value) {
if (strtoloweru($key)==strtoloweru($extension)) {
- if (!$settingsCurrent->isExisting($key)) $settings[$key] = $settingsLatest[$key];
+ $settings[$key] = $settingsCurrent[$key];
$found = true;
break;
}
@@ -618,18 +632,24 @@ class YellowUpdate {
$this->yellow->page->error($statusCode, "Can't find extension '$extension'!");
}
}
+ $protected = preg_split("/\s*,\s*/", $extensionsProtected);
+ foreach ($settings as $key=>$value) {
+ if (in_array($key, $protected)) unset($settings[$key]);
+ }
return array($statusCode, $settings);
}
- // Return extension uninstall information
- public function getExtensionUninstallInformation($extensions, $extensionsProtected) {
+ // Return extension install information
+ public function getExtensionInstallInformation($extensions) {
$settings = array();
- list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
+ list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
+ list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
+ $statusCode = max($statusCodeCurrent, $statusCodeLatest);
foreach ($extensions as $extension) {
$found = false;
- foreach ($settingsCurrent as $key=>$value) {
+ foreach ($settingsLatest as $key=>$value) {
if (strtoloweru($key)==strtoloweru($extension)) {
- $settings[$key] = $settingsCurrent[$key];
+ if (!$settingsCurrent->isExisting($key)) $settings[$key] = $settingsLatest[$key];
$found = true;
break;
}
@@ -639,10 +659,6 @@ class YellowUpdate {
$this->yellow->page->error($statusCode, "Can't find extension '$extension'!");
}
}
- $protected = preg_split("/\s*,\s*/", $extensionsProtected);
- foreach ($settings as $key=>$value) {
- if (in_array($key, $protected)) unset($settings[$key]);
- }
return array($statusCode, $settings);
}
@@ -794,6 +810,20 @@ class YellowUpdate {
}
return array($fileNameSource, $fileNameDestination);
}
+
+ // Return extension description including developer/designer/translator
+ public function getExtensionDescription($key, $value) {
+ $description = $text = $value->isExisting("description") ? $value->get("description") : "No description available.";
+ 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"].".";
+ return $description;
+ }
+
+ // Return extension documentation
+ public function getExtensionDocumentation($key, $value) {
+ return $value->isExisting("documentationUrl") ? "Read more at ".$value->get("documentationUrl") : "No documentation available";
+ }
// Return extension file
public function getExtensionFile($url) {