commit 6b5623c17c7ce50f234e49442376ddc60f50cd1b
parent 27b00056b4573b35e8855f612dbe711aeeb89ac6
Author: markseu <mark2011@mayberg.se>
Date: Thu, 25 Jun 2020 16:46:44 +0200
Updated API, changed command interface
Diffstat:
8 files changed, 188 insertions(+), 185 deletions(-)
diff --git a/system/extensions/command.php b/system/extensions/command.php
@@ -4,15 +4,15 @@
// This file may be used and distributed under the terms of the public license.
class YellowCommand {
- const VERSION = "0.8.14";
+ const VERSION = "0.8.15";
const TYPE = "feature";
const PRIORITY = "3";
- public $yellow; //access to API
- public $files; //number of files
- public $links; //number of links
- public $errors; //number of errors
- public $locationsArgs; //locations with location arguments detected
- public $locationsArgsPagination; //locations with pagination arguments detected
+ public $yellow; //access to API
+ public $files; //number of files
+ public $links; //number of links
+ public $errors; //number of errors
+ public $locationsArguments; //locations with location arguments detected
+ public $locationsArgumentsPagination; //locations with pagination arguments detected
// Handle initialisation
public function onLoad($yellow) {
@@ -20,15 +20,14 @@ class YellowCommand {
}
// Handle command
- public function onCommand($args) {
- list($command) = $args;
+ public function onCommand($command, $text) {
switch ($command) {
case "": $statusCode = $this->processCommandHelp(); break;
- case "about": $statusCode = $this->processCommandAbout($args); break;
- case "build": $statusCode = $this->processCommandBuild($args); break;
- case "check": $statusCode = $this->processCommandCheck($args); break;
- case "clean": $statusCode = $this->processCommandClean($args); break;
- case "serve": $statusCode = $this->processCommandServe($args); break;
+ 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;
+ case "serve": $statusCode = $this->processCommandServe($command, $text); break;
default: $statusCode = 0;
}
return $statusCode;
@@ -55,7 +54,7 @@ class YellowCommand {
}
// Process command to show website version and updates
- public function processCommandAbout($args) {
+ public function processCommandAbout($command, $text) {
echo "Datenstrom Yellow ".YellowCore::VERSION."\n";
list($statusCode, $dataCurrent) = $this->getExtensionsVersion();
list($statusCode, $dataLatest) = $this->getExtensionsVersion(true);
@@ -71,17 +70,17 @@ class YellowCommand {
}
// Process command to build static website
- public function processCommandBuild($args) {
+ public function processCommandBuild($command, $text) {
$statusCode = 0;
- list($command, $path, $location) = $args;
- if (empty($location) || $location[0]=="/") {
+ list($path, $location) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location) || substru($location, 0, 1)=="/") {
if ($this->checkStaticSettings()) {
$statusCode = $this->buildStaticFiles($path, $location);
} else {
$statusCode = 500;
$this->files = 0;
$this->errors = 1;
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
echo "ERROR building files: Please configure CoreStaticUrl in file '$fileName'!\n";
}
echo "Yellow $command: $this->files file".($this->files!=1 ? "s" : "");
@@ -95,9 +94,9 @@ class YellowCommand {
// Build static files
public function buildStaticFiles($path, $locationFilter) {
- $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
+ $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDirectory") : $path, "/");
$this->files = $this->errors = 0;
- $this->locationsArgs = $this->locationsArgsPagination = array();
+ $this->locationsArguments = $this->locationsArgumentsPagination = array();
$statusCode = empty($locationFilter) ? $this->cleanStaticFiles($path, $locationFilter) : 200;
$staticUrl = $this->yellow->system->get("coreStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
@@ -108,16 +107,16 @@ class YellowCommand {
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
$statusCode = max($statusCode, $this->buildStaticFile($path, $location, true));
}
- foreach ($this->locationsArgs as $location) {
+ foreach ($this->locationsArguments as $location) {
echo "\rBuilding static website ".$this->getProgressPercent($this->files, $filesEstimated, 5, 60)."%... ";
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
$statusCode = max($statusCode, $this->buildStaticFile($path, $location, true));
}
- $filesEstimated = $this->files + count($this->locationsArgs) + count($this->locationsArgsPagination);
- foreach ($this->locationsArgsPagination as $location) {
+ $filesEstimated = $this->files + count($this->locationsArguments) + count($this->locationsArgumentsPagination);
+ foreach ($this->locationsArgumentsPagination as $location) {
echo "\rBuilding static website ".$this->getProgressPercent($this->files, $filesEstimated, 5, 95)."%... ";
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
- if (substru($location, -1)!=$this->yellow->toolbox->getLocationArgsSeparator()) {
+ if (substru($location, -1)!=$this->yellow->toolbox->getLocationArgumentsSeparator()) {
$statusCode = max($statusCode, $this->buildStaticFile($path, $location, false, true));
}
for ($pageNumber=2; $pageNumber<=999; ++$pageNumber) {
@@ -237,17 +236,17 @@ class YellowCommand {
}
if (substru($location, 0, strlenu($base))!=$base) continue;
$location = substru($location, strlenu($base));
- if (!$this->yellow->toolbox->isLocationArgs($location)) continue;
- if (!$this->yellow->toolbox->isLocationArgsPagination($location)) {
+ if (!$this->yellow->toolbox->isLocationArguments($location)) continue;
+ if (!$this->yellow->toolbox->isLocationArgumentsPagination($location)) {
$location = rtrim($location, "/")."/";
- if (!isset($this->locationsArgs[$location])) {
- $this->locationsArgs[$location] = $location;
+ if (!isset($this->locationsArguments[$location])) {
+ $this->locationsArguments[$location] = $location;
if (defined("DEBUG") && DEBUG>=2) echo "YellowCommand::analyseLocations detected location:$location<br/>\n";
}
} else {
$location = rtrim($location, "0..9");
- if (!isset($this->locationsArgsPagination[$location])) {
- $this->locationsArgsPagination[$location] = $location;
+ if (!isset($this->locationsArgumentsPagination[$location])) {
+ $this->locationsArgumentsPagination[$location] = $location;
if (defined("DEBUG") && DEBUG>=2) echo "YellowCommand::analyseLocations detected location:$location<br/>\n";
}
}
@@ -255,17 +254,17 @@ class YellowCommand {
}
// Process command to check static files for broken links
- public function processCommandCheck($args) {
+ public function processCommandCheck($command, $text) {
$statusCode = 0;
- list($command, $path, $location) = $args;
- if (empty($location) || $location[0]=="/") {
+ list($path, $location) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location) || substru($location, 0, 1)=="/") {
if ($this->checkStaticSettings()) {
$statusCode = $this->checkStaticFiles($path, $location);
} else {
$statusCode = 500;
$this->links = 0;
$this->errors = 1;
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
echo "ERROR checking files: Please configure CoreStaticUrl in file '$fileName'!\n";
}
echo "Yellow $command: $this->links link".($this->links!=1 ? "s" : "");
@@ -279,7 +278,7 @@ class YellowCommand {
// Check static files for broken links
public function checkStaticFiles($path, $locationFilter) {
- $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
+ $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDirectory") : $path, "/");
$this->links = $this->errors = 0;
$regex = "/^[^.]+$|".$this->yellow->system->get("coreStaticDefaultFile")."$/";
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($path, $regex, false, false);
@@ -402,10 +401,10 @@ class YellowCommand {
}
// Process command to clean static files
- public function processCommandClean($args) {
+ public function processCommandClean($command, $text) {
$statusCode = 0;
- list($command, $path, $location) = $args;
- if (empty($location) || $location[0]=="/") {
+ list($path, $location) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location) || substru($location, 0, 1)=="/") {
$statusCode = $this->cleanStaticFiles($path, $location);
echo "Yellow $command: Static file".(empty($location) ? "s" : "")." ".($statusCode!=200 ? "not " : "")."cleaned\n";
} else {
@@ -418,7 +417,7 @@ class YellowCommand {
// Clean static files and directories
public function cleanStaticFiles($path, $location) {
$statusCode = 200;
- $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
+ $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDirectory") : $path, "/");
if (empty($location)) {
$statusCode = max($statusCode, $this->broadcastCommand("clean", "all"));
$statusCode = max($statusCode, $this->cleanStaticDirectory($path));
@@ -458,20 +457,20 @@ class YellowCommand {
}
// Broadcast command to other extensions
- public function broadcastCommand($args) {
+ public function broadcastCommand($command, $text) {
$statusCode = 0;
foreach ($this->yellow->extensions->extensions as $key=>$value) {
if (method_exists($value["obj"], "onCommand") && $key!="command") {
- $statusCode = max($statusCode, $value["obj"]->onCommand(func_get_args()));
+ $statusCode = max($statusCode, $value["obj"]->onCommand($command, $text));
}
}
return $statusCode;
}
// Process command to start built-in web server
- public function processCommandServe($args) {
- list($command, $path, $url) = $args;
- if (empty($path) && is_dir($this->yellow->system->get("coreStaticDir"))) $path = $this->yellow->system->get("coreStaticDir");
+ public function processCommandServe($command, $text) {
+ list($path, $url) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($path) && is_dir($this->yellow->system->get("coreStaticDirectory"))) $path = $this->yellow->system->get("coreStaticDirectory");
if (empty($url)) $url = "http://localhost:8000";
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($url);
if ($scheme=="http" && !empty($address)) {
@@ -501,8 +500,8 @@ class YellowCommand {
public function checkStaticDirectory($path) {
$ok = false;
if (!empty($path)) {
- if ($path==rtrim($this->yellow->system->get("coreStaticDir"), "/")) $ok = true;
- if ($path==rtrim($this->yellow->system->get("coreTrashDir"), "/")) $ok = true;
+ if ($path==rtrim($this->yellow->system->get("coreStaticDirectory"), "/")) $ok = true;
+ if ($path==rtrim($this->yellow->system->get("coreTrashDirectory"), "/")) $ok = true;
if (is_file("$path/".$this->yellow->system->get("coreStaticDefaultFile"))) $ok = true;
if (is_file("$path/yellow.php")) $ok = false;
}
@@ -597,7 +596,7 @@ class YellowCommand {
// Return media locations
public function getMediaLocations() {
$locations = array();
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreMediaDir"), "/.*/", false, false);
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreMediaDirectory"), "/.*/", false, false);
foreach ($fileNames as $fileName) {
array_push($locations, "/".$fileName);
}
@@ -608,15 +607,15 @@ class YellowCommand {
public function getSystemLocations() {
$locations = array();
$regex = "/\.(css|gif|ico|js|jpg|png|svg|txt|woff|woff2)$/";
- $extensionDirLength = strlenu($this->yellow->system->get("coreExtensionDir"));
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreExtensionDir"), $regex, false, false);
+ $extensionDirectoryLength = strlenu($this->yellow->system->get("coreExtensionDirectory"));
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreExtensionDirectory"), $regex, false, false);
foreach ($fileNames as $fileName) {
- array_push($locations, $this->yellow->system->get("coreExtensionLocation").substru($fileName, $extensionDirLength));
+ array_push($locations, $this->yellow->system->get("coreExtensionLocation").substru($fileName, $extensionDirectoryLength));
}
- $resourceDirLength = strlenu($this->yellow->system->get("coreResourceDir"));
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreResourceDir"), $regex, false, false);
+ $resourceDirectoryLength = strlenu($this->yellow->system->get("coreResourceDirectory"));
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreResourceDirectory"), $regex, false, false);
foreach ($fileNames as $fileName) {
- array_push($locations, $this->yellow->system->get("coreResourceLocation").substru($fileName, $resourceDirLength));
+ array_push($locations, $this->yellow->system->get("coreResourceLocation").substru($fileName, $resourceDirectoryLength));
}
return $locations;
}
@@ -625,11 +624,11 @@ class YellowCommand {
public function getExtraLocations($path) {
$locations = array();
$pathIgnore = "($path/|".
- $this->yellow->system->get("coreStaticDir")."|".
- $this->yellow->system->get("coreCacheDir")."|".
- $this->yellow->system->get("coreContentDir")."|".
- $this->yellow->system->get("coreMediaDir")."|".
- $this->yellow->system->get("coreSystemDir").")";
+ $this->yellow->system->get("coreStaticDirectory")."|".
+ $this->yellow->system->get("coreCacheDirectory")."|".
+ $this->yellow->system->get("coreContentDirectory")."|".
+ $this->yellow->system->get("coreMediaDirectory")."|".
+ $this->yellow->system->get("coreSystemDirectory").")";
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive(".", "/.*/", false, false);
foreach ($fileNames as $fileName) {
$fileName = substru($fileName, 2);
diff --git a/system/extensions/core.php b/system/extensions/core.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCore {
- const VERSION = "0.8.12";
+ const VERSION = "0.8.13";
const TYPE = "feature";
public $page; //current page
public $content; //content files from file system
@@ -263,20 +263,20 @@ class YellowCore {
}
// Handle command
- public function command($args = null) {
+ public function command($line = "") {
$statusCode = 0;
$this->toolbox->timerStart($time);
+ list($command, $text) = $this->getCommandInformation($line);
foreach ($this->extensions->extensions as $key=>$value) {
if (method_exists($value["obj"], "onCommand")) {
$this->lookup->commandHandler = $key;
- $statusCode = $value["obj"]->onCommand(func_get_args());
+ $statusCode = $value["obj"]->onCommand($command, $text);
if ($statusCode!=0) break;
}
}
if ($statusCode==0) {
$this->lookup->commandHandler = "core";
$statusCode = 400;
- list($command) = func_get_args();
echo "Yellow $command: Command not found\n";
}
$this->toolbox->timerStop($time);
@@ -357,6 +357,15 @@ class YellowCore {
if (empty($fileName)) $fileName = $this->lookup->findFileFromLocation($location);
return array($scheme, $address, $base, $location, $fileName);
}
+
+ // Return command information
+ public function getCommandInformation($line = "") {
+ if (empty($line)) {
+ $line = $this->toolbox->getTextString(array_slice($this->toolbox->getServer("argv"), 1));
+ if (defined("DEBUG") && DEBUG>=3) echo "YellowCore::getCommandInformation $line<br/>\n";
+ }
+ return $this->toolbox->getTextList($line, " ", 2);
+ }
// Return request handler
public function getRequestHandler() {
diff --git a/system/extensions/edit.js b/system/extensions/edit.js
@@ -12,7 +12,7 @@ var yellow = {
onPageShow: function(e) { yellow.edit.pageShow(e); },
onUpdatePane: function() { yellow.edit.updatePane(yellow.edit.paneId, yellow.edit.paneAction, yellow.edit.paneStatus); },
onResizePane: function() { yellow.edit.resizePane(yellow.edit.paneId, yellow.edit.paneAction, yellow.edit.paneStatus); },
- action: function(action, status, args) { yellow.edit.processAction(action, status, args); }
+ action: function(action, status, arguments) { yellow.edit.processAction(action, status, arguments); }
};
yellow.edit = {
@@ -71,7 +71,7 @@ yellow.edit = {
for (; element; element=element.parentNode) {
if (element.tagName=="A") break;
}
- this.processAction(element.getAttribute("data-action"), element.getAttribute("data-status"), element.getAttribute("data-args"));
+ this.processAction(element.getAttribute("data-action"), element.getAttribute("data-status"), element.getAttribute("data-arguments"));
},
// Handle page cache
@@ -333,7 +333,7 @@ yellow.edit = {
"<li><span>"+yellow.toolbox.encodeHtml(yellow.system.userEmail)+"</span></li>"+
"<li><a href=\"#\" data-action=\"settings\">"+this.getText("MenuSettings")+"</a></li>" +
"<li><a href=\"#\" data-action=\"help\">"+this.getText("MenuHelp")+"</a></li>" +
- "<li><a href=\"#\" data-action=\"submit\" data-args=\"action:logout\">"+this.getText("MenuLogout")+"</a></li>"+
+ "<li><a href=\"#\" data-action=\"submit\" data-arguments=\"action:logout\">"+this.getText("MenuLogout")+"</a></li>"+
"</ul>";
break;
case "yellow-pane-information":
@@ -397,7 +397,7 @@ yellow.edit = {
setTimeout("yellow.action('submit', '', 'action:update/option:check/');", 500);
}
if (paneStatus=="updates") {
- document.getElementById("yellow-pane-update-status").innerHTML = "<a href=\"#\" data-action=\"submit\" data-args=\"action:update\">"+this.getText("UpdateStatusUpdates")+"</a>";
+ document.getElementById("yellow-pane-update-status").innerHTML = "<a href=\"#\" data-action=\"submit\" data-arguments=\"action:update\">"+this.getText("UpdateStatusUpdates")+"</a>";
}
break;
case "yellow-pane-create":
@@ -427,7 +427,7 @@ yellow.edit = {
if (document.getElementById(paneId+"-submit").className != className) {
document.getElementById(paneId+"-submit").className = className;
document.getElementById(paneId+"-submit").innerHTML = this.getText(paneAction+"Button");
- document.getElementById(paneId+"-submit").setAttribute("data-args", "action:"+paneAction);
+ document.getElementById(paneId+"-submit").setAttribute("data-arguments", "action:"+paneAction);
this.resizePane(paneId, paneAction, paneStatus);
}
}
@@ -543,10 +543,10 @@ yellow.edit = {
},
// Process action
- processAction: function(action, status, args) {
+ processAction: function(action, status, arguments) {
action = action ? action : "none";
status = status ? status : "none";
- args = args ? args : "none";
+ arguments = arguments ? arguments : "none";
if (action!="none") {
if (yellow.system.debug) console.log("yellow.edit.processAction action:"+action+" status:"+status);
var paneId = (status!="next" && status!="done") ? "yellow-pane-"+action : "yellow-pane-information";
@@ -570,16 +570,16 @@ yellow.edit = {
case "delete": this.showPane(paneId, action, status, true); break;
case "menu": this.showPane(paneId, action, status); break;
case "close": this.hidePane(this.paneId); break;
- case "toolbar": this.processToolbar(status, args); break;
- case "settings": this.processSettings(args); break;
- case "submit": this.processSubmit(args); break;
+ case "toolbar": this.processToolbar(status, arguments); break;
+ case "settings": this.processSettings(arguments); break;
+ case "submit": this.processSubmit(arguments); break;
case "help": this.processHelp(); break;
}
}
},
// Process toolbar
- processToolbar: function(status, args) {
+ processToolbar: function(status, arguments) {
if (yellow.system.debug) console.log("yellow.edit.processToolbar status:"+status);
var elementText = document.getElementById(this.paneId+"-text");
var elementPreview = document.getElementById(this.paneId+"-preview");
@@ -601,7 +601,7 @@ yellow.edit = {
case "ol": yellow.editor.setMarkdown(elementText, "1. ", "insert-multiline-block", true); break;
case "tl": yellow.editor.setMarkdown(elementText, "- [ ] ", "insert-multiline-block", true); break;
case "link": yellow.editor.setMarkdown(elementText, "[link](url)", "insert", false, yellow.editor.getMarkdownLink); break;
- case "text": yellow.editor.setMarkdown(elementText, args, "insert"); break;
+ case "text": yellow.editor.setMarkdown(elementText, arguments, "insert"); break;
case "status": yellow.editor.setMetaData(elementText, "status", true); break;
case "file": this.showFileDialog(); break;
case "undo": yellow.editor.undo(); break;
@@ -653,15 +653,15 @@ yellow.edit = {
},
// Process settings
- processSettings: function(args) {
- var action = args!="none" ? args : "account";
+ processSettings: function(arguments) {
+ var action = arguments!="none" ? arguments : "account";
if (action!=this.paneAction && action!="settings") this.processAction(action);
},
// Process submit
- processSubmit: function(args) {
+ processSubmit: function(arguments) {
var settings = { "action":"none", "csrftoken":this.getCookie("csrftoken") };
- var tokens = args.split("/");
+ var tokens = arguments.split("/");
for (var i=0; i<tokens.length; i++) {
var pair = tokens[i].split(/[:=]/);
if (!pair[0] || !pair[1]) continue;
@@ -726,7 +726,7 @@ yellow.edit = {
for (var i=0; i<tokens.length; i++) {
var token = tokens[i].replace(/[\:]/g,"");
var className = token.replace("+1", "plus1").replace("-1", "minus1").replace(/_/g, "-");
- rawDataEmojis += "<li><a href=\"#\" id=\"yellow-popup-list-"+yellow.toolbox.encodeHtml(token)+"\" data-action=\"toolbar\" data-status=\"text\" data-args=\":"+yellow.toolbox.encodeHtml(token)+":\"><i class=\"ea ea-"+yellow.toolbox.encodeHtml(className)+"\"></i></a></li>";
+ rawDataEmojis += "<li><a href=\"#\" id=\"yellow-popup-list-"+yellow.toolbox.encodeHtml(token)+"\" data-action=\"toolbar\" data-status=\"text\" data-arguments=\":"+yellow.toolbox.encodeHtml(token)+":\"><i class=\"ea ea-"+yellow.toolbox.encodeHtml(className)+"\"></i></a></li>";
}
}
elementDiv.innerHTML = "<ul class=\"yellow-dropdown yellow-dropdown-menu\">"+rawDataEmojis+"</ul>";
@@ -737,7 +737,7 @@ yellow.edit = {
var tokens = yellow.system.fontawesomeToolbarButtons.split(" ");
for (var i=0; i<tokens.length; i++) {
var token = tokens[i].replace(/[\:]/g,"");
- rawDataIcons += "<li><a href=\"#\" id=\"yellow-popup-list-"+yellow.toolbox.encodeHtml(token)+"\" data-action=\"toolbar\" data-status=\"text\" data-args=\":"+yellow.toolbox.encodeHtml(token)+":\"><i class=\"fa "+yellow.toolbox.encodeHtml(token)+"\"></i></a></li>";
+ rawDataIcons += "<li><a href=\"#\" id=\"yellow-popup-list-"+yellow.toolbox.encodeHtml(token)+"\" data-action=\"toolbar\" data-status=\"text\" data-arguments=\":"+yellow.toolbox.encodeHtml(token)+":\"><i class=\"fa "+yellow.toolbox.encodeHtml(token)+"\"></i></a></li>";
}
}
elementDiv.innerHTML = "<ul class=\"yellow-dropdown yellow-dropdown-menu\">"+rawDataIcons+"</ul>";
@@ -916,7 +916,7 @@ yellow.edit = {
var tokens = yellow.system.editSettingsActions.split(/\s*,\s*/);
for (var i=0; i<tokens.length; i++) {
var token = tokens[i];
- rawDataActions += "<a href=\"#\""+(token==paneAction ? "class=\"active\"": "")+" data-action=\"settings\" data-args=\""+yellow.toolbox.encodeHtml(token)+"\">"+this.getText(token+"Title")+"</a><br />";
+ rawDataActions += "<a href=\"#\""+(token==paneAction ? "class=\"active\"": "")+" data-action=\"settings\" data-arguments=\""+yellow.toolbox.encodeHtml(token)+"\">"+this.getText(token+"Title")+"</a><br />";
}
}
return rawDataActions;
@@ -1480,15 +1480,15 @@ yellow.toolbox = {
},
// Submit form with post method
- submitForm: function(args) {
+ submitForm: function(arguments) {
var elementForm = document.createElement("form");
elementForm.setAttribute("method", "post");
- for (var key in args) {
- if (!args.hasOwnProperty(key)) continue;
+ for (var key in arguments) {
+ if (!arguments.hasOwnProperty(key)) continue;
var elementInput = document.createElement("input");
elementInput.setAttribute("type", "hidden");
elementInput.setAttribute("name", key);
- elementInput.setAttribute("value", args[key]);
+ elementInput.setAttribute("value", arguments[key]);
elementForm.appendChild(elementInput);
}
document.body.appendChild(elementForm);
diff --git a/system/extensions/edit.php b/system/extensions/edit.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowEdit {
- const VERSION = "0.8.25";
+ const VERSION = "0.8.26";
const TYPE = "feature";
public $yellow; //access to API
public $response; //web response
@@ -33,7 +33,7 @@ class YellowEdit {
$this->yellow->system->setDefault("editLoginRestriction", "0");
$this->yellow->system->setDefault("editLoginSessionTimeout", "2592000");
$this->yellow->system->setDefault("editBruteForceProtection", "25");
- $this->users->load($this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile"));
+ $this->users->load($this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile"));
}
// Handle request
@@ -87,10 +87,9 @@ class YellowEdit {
}
// Handle command
- public function onCommand($args) {
- list($command) = $args;
+ public function onCommand($command, $text) {
switch ($command) {
- case "user": $statusCode = $this->processCommandUser($args); break;
+ case "user": $statusCode = $this->processCommandUser($command, $text); break;
default: $statusCode = 0;
}
return $statusCode;
@@ -105,7 +104,7 @@ class YellowEdit {
public function onUpdate($action) {
if ($action=="update") {
$cleanup = false;
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$fileData = $this->yellow->toolbox->readFile($fileNameUser);
$fileDataNew = "";
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
@@ -125,21 +124,20 @@ class YellowEdit {
}
// Process command to update user account
- public function processCommandUser($args) {
- list($command, $option) = $args;
+ public function processCommandUser($command, $text) {
+ list($option) = $this->yellow->toolbox->getTextArguments($text);
switch ($option) {
- case "": $statusCode = $this->userShow($args); break;
- case "add": $statusCode = $this->userAdd($args); break;
- case "change": $statusCode = $this->userChange($args); break;
- case "remove": $statusCode = $this->userRemove($args); break;
+ case "": $statusCode = $this->userShow($command, $text); break;
+ case "add": $statusCode = $this->userAdd($command, $text); break;
+ case "change": $statusCode = $this->userChange($command, $text); break;
+ case "remove": $statusCode = $this->userRemove($command, $text); break;
default: $statusCode = 400; echo "Yellow $command: Invalid arguments\n";
}
return $statusCode;
}
// Show user accounts
- public function userShow($args) {
- list($command) = $args;
+ public function userShow($command, $text) {
foreach ($this->users->getData() as $line) {
echo "$line\n";
}
@@ -148,9 +146,9 @@ class YellowEdit {
}
// Add user account
- public function userAdd($args) {
+ public function userAdd($command, $text) {
$status = "ok";
- list($command, $option, $email, $password, $name) = $args;
+ list($option, $email, $password, $name) = $this->yellow->toolbox->getTextArguments($text);
if (empty($email) || empty($password)) $status = $this->response->status = "incomplete";
if (empty($name)) $name = $this->yellow->system->get("sitename");
if ($status=="ok") $status = $this->getUserAccount($email, $password, "add");
@@ -163,7 +161,7 @@ class YellowEdit {
case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break;
}
if ($status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $this->yellow->system->get("language"),
@@ -190,9 +188,9 @@ class YellowEdit {
}
// Change user account
- public function userChange($args) {
+ public function userChange($command, $text) {
$status = "ok";
- list($command, $option, $email, $password, $name) = $args;
+ list($option, $email, $password, $name) = $this->yellow->toolbox->getTextArguments($text);
if (empty($email)) $status = $this->response->status = "invalid";
if ($status=="ok") $status = $this->getUserAccount($email, $password, "change");
if ($status=="ok" && !$this->users->isExisting($email)) $status = "unknown";
@@ -203,7 +201,7 @@ class YellowEdit {
case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break;
}
if ($status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => empty($name) ? $this->users->getUser($email, "name") : $name,
"hash" => empty($password) ? $this->users->getUser($email, "hash") : $this->users->createHash($password),
@@ -218,9 +216,9 @@ class YellowEdit {
}
// Remove user account
- public function userRemove($args) {
+ public function userRemove($command, $text) {
$status = "ok";
- list($command, $option, $email) = $args;
+ list($option, $email) = $this->yellow->toolbox->getTextArguments($text);
$name = $this->users->getUser($email, "name");
if (empty($email)) $status = $this->response->status = "invalid";
if (empty($name)) $name = $this->yellow->system->get("sitename");
@@ -231,7 +229,7 @@ class YellowEdit {
case "unknown": echo "ERROR updating settings: Can't find email '$email'!\n"; break;
}
if ($status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$status = $this->users->remove($fileNameUser, $email) ? "ok" : "error";
if ($status=="error") echo "ERROR updating settings: Can't write file '$fileNameUser'!\n";
$this->yellow->log($status=="ok" ? "info" : "error", "Remove user '".strtok($name, " ")."'");
@@ -299,7 +297,7 @@ class YellowEdit {
// Process request for user login
public function processRequestLogin($scheme, $address, $base, $location, $fileName) {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
if ($this->users->save($fileNameUser, $this->response->userEmail, $settings)) {
$home = $this->users->getUser($this->response->userEmail, "home");
@@ -343,7 +341,7 @@ class YellowEdit {
if ($this->response->status=="ok" && $this->response->isLoginRestriction()) $this->response->status = "next";
if ($this->response->status=="ok" && $this->users->isTaken($email)) $this->response->status = "next";
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $this->yellow->lookup->findLanguageFromFile($fileName, $this->yellow->system->get("language")),
@@ -378,7 +376,7 @@ class YellowEdit {
$email = $this->yellow->page->getRequest("email");
$this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action"));
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unapproved");
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -398,7 +396,7 @@ class YellowEdit {
$email = $this->yellow->page->getRequest("email");
$this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action"));
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active");
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -438,7 +436,7 @@ class YellowEdit {
if (empty($password)) $this->response->status = "password";
if ($this->response->status=="ok") $this->response->status = $this->getUserAccount($email, $password, $this->response->action);
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("hash" => $this->users->createHash($password), "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -459,7 +457,7 @@ class YellowEdit {
$email = $this->yellow->page->getRequest("email");
$this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action"));
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active");
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "done" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -479,7 +477,7 @@ class YellowEdit {
if ($this->users->getUser($emailSource, "status")!="active") $this->response->status = "done";
}
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unchanged");
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -503,7 +501,7 @@ class YellowEdit {
if (!$this->users->isExisting($email) || empty($hash)) $this->response->status = "done";
}
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"hash" => $hash,
"pending" => "none",
@@ -514,7 +512,7 @@ class YellowEdit {
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
if ($this->response->status=="ok" && $email!=$emailSource) {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$this->response->status = $this->users->remove($fileNameUser, $emailSource) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
@@ -550,7 +548,7 @@ class YellowEdit {
$email = $this->yellow->page->getRequest("email");
$this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action"));
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "removed");
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -561,7 +559,7 @@ class YellowEdit {
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't send email on this server!");
}
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$this->response->status = $this->users->remove($fileNameUser, $email) ? "ok" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
@@ -587,7 +585,7 @@ class YellowEdit {
if ($this->response->status=="ok") $this->response->status = $this->getUserAccount($email, $password, $this->response->action);
if ($this->response->status=="ok" && $email!=$emailSource && $this->users->isTaken($email)) $this->response->status = "taken";
if ($this->response->status=="ok" && $email!=$emailSource) {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@@ -603,7 +601,7 @@ class YellowEdit {
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@@ -620,7 +618,7 @@ class YellowEdit {
}
} else {
if ($this->response->status=="ok") {
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array("name" => $name, "language" => $language, "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "done" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
@@ -648,7 +646,7 @@ class YellowEdit {
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) $this->response->status = "invalid";
}
if ($this->response->status=="ok") {
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
$settings = array("sitename" => $sitename, "author" => $author, "email" => $email);
$file = $this->response->getFileSystem($scheme, $address, $base, $location, $fileName, $settings);
$this->response->status = (!$file->isError() && $this->yellow->system->save($fileName, $settings)) ? "done" : "error";
@@ -681,7 +679,7 @@ class YellowEdit {
$this->response->rawDataOutput = "";
}
} else {
- $this->response->status = $this->yellow->command("update", $extension, $option)==0 ? "done" : "error";
+ $this->response->status = $this->yellow->command("update $extension $option")==0 ? "done" : "error";
}
if ($this->response->status=="done") {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
@@ -769,7 +767,7 @@ class YellowEdit {
$rawDataFile, $this->response->rawDataEndOfLine);
if (!$page->isError()) {
if ($this->yellow->lookup->isFileLocation($location)) {
- if ($this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
+ if ($this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"))) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
$statusCode = $this->yellow->sendStatus(303, $location);
} else {
@@ -777,7 +775,7 @@ class YellowEdit {
$statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false);
}
} else {
- if ($this->yellow->toolbox->deleteDirectory(dirname($fileName), $this->yellow->system->get("coreTrashDir"))) {
+ if ($this->yellow->toolbox->deleteDirectory(dirname($fileName), $this->yellow->system->get("coreTrashDirectory"))) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
$statusCode = $this->yellow->sendStatus(303, $location);
} else {
@@ -899,7 +897,7 @@ class YellowEdit {
if ($this->response->userFailedExpire>time() && $this->users->isExisting($this->response->userFailedEmail)) {
$email = $this->response->userFailedEmail;
$failed = $this->users->getUser($email, "failed")+1;
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$status = $this->users->save($fileNameUser, $email, array("failed" => $failed)) ? "ok" : "error";
if ($status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
if ($failed==$this->yellow->system->get("editBruteForceProtection")) {
@@ -1008,7 +1006,7 @@ class YellowEditResponse {
if (empty($this->rawDataSource)) $this->rawDataSource = $page->rawData;
if (empty($this->rawDataEdit)) $this->rawDataEdit = $page->rawData;
if (empty($this->rawDataEndOfLine)) $this->rawDataEndOfLine = $this->getEndOfLine($page->rawData);
- if ($page->statusCode==404 || $this->yellow->toolbox->isLocationArgs()) {
+ if ($page->statusCode==404 || $this->yellow->toolbox->isLocationArguments()) {
$this->rawDataEdit = $this->getRawDataGenerated($page);
$this->rawDataReadonly = true;
}
@@ -1289,7 +1287,7 @@ class YellowEditResponse {
if ($updates==0) {
foreach ($dataCurrent as $key=>$value) {
if (isset($dataModified[$key]) && isset($dataLatest[$key])) {
- $output = $this->yellow->text->getTextHtml("editUpdateModified", $this->language)." - <a href=\"#\" data-action=\"submit\" data-args=\"".$this->yellow->toolbox->normaliseArgs("action:update/extension:$key/option:force")."\">".$this->yellow->text->getTextHtml("editUpdateForce", $this->language)."</a><br />\n";
+ $output = $this->yellow->text->getTextHtml("editUpdateModified", $this->language)." - <a href=\"#\" data-action=\"submit\" data-arguments=\"".$this->yellow->toolbox->normaliseArguments("action:update/extension:$key/option:force")."\">".$this->yellow->text->getTextHtml("editUpdateForce", $this->language)."</a><br />\n";
$rawData .= preg_replace("/@extension/i", htmlspecialchars(ucfirst($key)." $dataLatest[$key]"), $output);
}
}
@@ -1311,7 +1309,7 @@ class YellowEditResponse {
foreach ($this->yellow->content->path($page->location)->reverse() as $ancestor) {
if ($ancestor->isExisting("layoutNew")) {
$name = $this->yellow->lookup->normaliseName($ancestor->get("layoutNew"));
- $location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDir");
+ $location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDirectory");
$fileName = $this->yellow->lookup->findFileFromLocation($location, true).$this->yellow->system->get("editNewFile");
$fileName = strreplaceu("(.*)", $name, $fileName);
if (is_file($fileName)) break;
@@ -1319,7 +1317,7 @@ class YellowEditResponse {
}
if (!is_file($fileName)) {
$name = $this->yellow->lookup->normaliseName($this->yellow->system->get("layout"));
- $location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDir");
+ $location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDirectory");
$fileName = $this->yellow->lookup->findFileFromLocation($location, true).$this->yellow->system->get("editNewFile");
$fileName = strreplaceu("(.*)", $name, $fileName);
}
@@ -1457,9 +1455,9 @@ class YellowEditResponse {
// Return group for new file
public function getFileNewGroup($fileNameShort) {
$group = "none";
- $path = $this->yellow->system->get("coreMediaDir");
+ $path = $this->yellow->system->get("coreMediaDirectory");
$fileType = $this->yellow->toolbox->getFileType($fileNameShort);
- $fileName = $this->yellow->system->get(preg_match("/(gif|jpg|png|svg)$/", $fileType) ? "coreImageDir" : "coreDownloadDir").$fileNameShort;
+ $fileName = $this->yellow->system->get(preg_match("/(gif|jpg|png|svg)$/", $fileType) ? "coreImageDirectory" : "coreDownloadDirectory").$fileNameShort;
if (preg_match("#^$path(.+?)\/#", $fileName, $matches)) $group = strtoloweru($matches[1]);
return $group;
}
diff --git a/system/extensions/install.php b/system/extensions/install.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowInstall {
- const VERSION = "0.8.24";
+ const VERSION = "0.8.25";
const TYPE = "feature";
const PRIORITY = "1";
public $yellow; //access to API
@@ -24,7 +24,7 @@ class YellowInstall {
}
// Handle command
- public function onCommand($args) {
+ public function onCommand($command, $text) {
return $this->processCommandInstall();
}
@@ -82,7 +82,7 @@ class YellowInstall {
// Update log
public function updateLog() {
$statusCode = 200;
- $fileName = $this->yellow->system->get("coreExtensionDir").$this->yellow->system->get("coreLogFile");
+ $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLogFile");
if (!is_file($fileName)) {
list($name, $version) = $this->yellow->toolbox->detectServerInformation();
$this->yellow->log("info", "Datenstrom Yellow ".YellowCore::VERSION.", PHP ".PHP_VERSION.", $name $version, ".PHP_OS);
@@ -97,7 +97,7 @@ class YellowInstall {
// Update language
public function updateLanguage() {
$statusCode = 200;
- $path = $this->yellow->system->get("coreExtensionDir")."install-languages.zip";
+ $path = $this->yellow->system->get("coreExtensionDirectory")."install-languages.zip";
if (is_file($path) && $this->yellow->extensions->isExisting("update")) {
$zip = new ZipArchive();
if ($zip->open($path)===true) {
@@ -141,7 +141,7 @@ class YellowInstall {
}
$zip->close();
if ($statusCode==200) {
- $this->yellow->text->load($this->yellow->system->get("coreExtensionDir").$this->yellow->system->get("coreLanguageFile"), "");
+ $this->yellow->text->load($this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile"), "");
}
} else {
$statusCode = 500;
@@ -154,7 +154,7 @@ class YellowInstall {
// Update extension
public function updateExtension($extension) {
$statusCode = 200;
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
if (!empty($extension) && $this->yellow->extensions->isExisting("update")) {
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
if (preg_match("/^install-(.*?)\./", basename($entry), $matches)) {
@@ -173,7 +173,7 @@ class YellowInstall {
$statusCode = 200;
if (!empty($email) && !empty($password) && $this->yellow->extensions->isExisting("edit")) {
if (empty($name)) $name = $this->yellow->system->get("sitename");
- $fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
+ $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@@ -217,7 +217,7 @@ class YellowInstall {
// Update text settings
public function updateText($language) {
$statusCode = 200;
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreTextFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreTextFile");
$fileData = $this->yellow->toolbox->readFile($fileName);
if (count($this->yellow->toolbox->getTextLines($fileData))<4) {
$fileData .= "Language: $language\n";
@@ -234,7 +234,7 @@ class YellowInstall {
// Update system settings
public function updateSystem($settings) {
$statusCode = 200;
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
if (!$this->yellow->system->save($fileName, $settings)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@@ -246,7 +246,7 @@ class YellowInstall {
public function removeInstall() {
$statusCode = 200;
if (function_exists("opcache_reset")) opcache_reset();
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
if (preg_match("/^install-(.*?)\./", basename($entry), $matches)) {
if (!$this->yellow->toolbox->deleteFile($entry)) {
@@ -255,7 +255,7 @@ class YellowInstall {
}
}
}
- $path = $this->yellow->system->get("coreExtensionDir")."install.php";
+ $path = $this->yellow->system->get("coreExtensionDirectory")."install.php";
if ($statusCode==200 && !$this->yellow->toolbox->deleteFile($path)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$path'!");
@@ -298,7 +298,7 @@ class YellowInstall {
// Check web server write access
public function checkServerWrite() {
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
return $this->yellow->system->save($fileName, array());
}
@@ -363,7 +363,7 @@ class YellowInstall {
// Return extensions for install page
public function getExtensionsInstall() {
$extensions = array("website");
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false, false) as $entry) {
if (preg_match("/^install-(.*?)\./", $entry, $matches) && $matches[1]!="languages") array_push($extensions, $matches[1]);
}
diff --git a/system/extensions/update.php b/system/extensions/update.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowUpdate {
- const VERSION = "0.8.19";
+ const VERSION = "0.8.20";
const TYPE = "feature";
const PRIORITY = "2";
public $yellow; //access to API
@@ -14,7 +14,7 @@ class YellowUpdate {
public function onLoad($yellow) {
$this->yellow = $yellow;
$this->yellow->system->setDefault("updateExtensionUrl", "https://github.com/datenstrom/yellow-extensions");
- $this->yellow->system->setDefault("updateExtensionDir", "/Users/yourname/Documents/GitHub/");
+ $this->yellow->system->setDefault("updateExtensionDirectory", "/Users/yourname/Documents/GitHub/");
$this->yellow->system->setDefault("updateExtensionFile", "extension.ini");
$this->yellow->system->setDefault("updateVersionFile", "version.ini");
$this->yellow->system->setDefault("updateWaffleFile", "waffle.ini");
@@ -31,16 +31,15 @@ class YellowUpdate {
}
// Handle command
- public function onCommand($args) {
+ public function onCommand($command, $text) {
$statusCode = 0;
if ($this->isExtensionPending()) $statusCode = $this->processCommandPending();
if ($statusCode==0) {
- list($command) = $args;
switch ($command) {
- case "clean": $statusCode = $this->processCommandClean($args); break;
- case "install": $statusCode = $this->processCommandInstall($args); break;
- case "uninstall": $statusCode = $this->processCommandUninstall($args); break;
- case "update": $statusCode = $this->processCommandUpdate($args); break;
+ case "clean": $statusCode = $this->processCommandClean($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;
default: $statusCode = 0; break;
}
}
@@ -62,7 +61,7 @@ class YellowUpdate {
$coreStaticUrl = $this->yellow->system->get("staticUrl");
$coreServerUrl = empty($this->yellow->system->get("serverUrl")) ? "auto" : $this->yellow->system->get("serverUrl");
$coreServerTimezone = $this->yellow->system->get("timezone");
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
$this->yellow->system->save($fileName, array("coreStaticUrl" => $coreStaticUrl, "coreServerUrl" => $coreServerUrl,
"coreServerTimezone" => $coreServerTimezone));
}
@@ -70,9 +69,9 @@ class YellowUpdate {
if ($action=="update") { //TODO: remove later, converts old content settings
if ($this->yellow->system->isExisting("multiLanguageMode")) {
$coreMultiLanguageMode = $this->yellow->system->get("multiLanguageMode");
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
$this->yellow->system->save($fileName, array("coreMultiLanguageMode" => $coreMultiLanguageMode));
- $path = $this->yellow->system->get("coreContentDir");
+ $path = $this->yellow->system->get("coreContentDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.md$/", true, false) as $entry) {
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
$fileStatusUnlisted = false;
@@ -102,7 +101,7 @@ class YellowUpdate {
if ($action=="update") { //TODO: remove later, converts old layout files
if ($this->yellow->system->isExisting("navigation")) {
$navigation = $this->yellow->system->get("navigation");
- $path = $this->yellow->system->get("coreLayoutDir");
+ $path = $this->yellow->system->get("coreLayoutDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) {
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
$fileDataNew = str_replace("system->get(\"serverScheme\")", "system->get(\"coreServerScheme\")", $fileDataNew);
@@ -132,7 +131,7 @@ class YellowUpdate {
if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($action);
}
}
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
$this->yellow->system->save($fileName, array("updateNotification" => "none"));
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileDataHeader = $fileDataSettings = $fileDataFooter = "";
@@ -166,11 +165,10 @@ class YellowUpdate {
}
// Process command to clean downloads
- public function processCommandClean($args) {
+ public function processCommandClean($command, $text) {
$statusCode = 0;
- list($command, $path) = $args;
- if ($path=="all") {
- $path = $this->yellow->system->get("coreExtensionDir");
+ if ($command=="clean" && $text=="all") {
+ $path = $this->yellow->system->get("coreExtensionDirectory");
$regex = "/^.*\\".$this->yellow->system->get("coreDownloadExtension")."$/";
foreach ($this->yellow->toolbox->getDirectoryEntries($path, $regex, false, false) as $entry) {
if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
@@ -181,8 +179,8 @@ class YellowUpdate {
}
// Process command to install extensions
- public function processCommandInstall($args) {
- list($command, $extensions) = $this->getExtensionInformation($args);
+ public function processCommandInstall($command, $text) {
+ list($extensions) = $this->getExtensionInformation($text);
if (!empty($extensions)) {
$this->updates = 0;
list($statusCode, $data) = $this->getInstallInformation($extensions);
@@ -198,8 +196,8 @@ class YellowUpdate {
}
// Process command to uninstall extensions
- public function processCommandUninstall($args) {
- list($command, $extensions) = $this->getExtensionInformation($args);
+ public function processCommandUninstall($command, $text) {
+ list($extensions) = $this->getExtensionInformation($text);
if (!empty($extensions)) {
$this->updates = 0;
list($statusCode, $data) = $this->getUninstallInformation($extensions, "core, command, update");
@@ -214,8 +212,8 @@ class YellowUpdate {
}
// Process command to update website
- public function processCommandUpdate($args) {
- list($command, $extensions, $force) = $this->getExtensionInformation($args);
+ public function processCommandUpdate($command, $text) {
+ list($extensions, $force) = $this->getExtensionInformation($text);
list($statusCode, $data) = $this->getUpdateInformation($extensions, $force);
if ($statusCode!=200 || !empty($data)) {
$this->updates = 0;
@@ -259,7 +257,7 @@ class YellowUpdate {
if ($updateNotification=="none") $updateNotification = "";
if (!empty($updateNotification)) $updateNotification .= ",";
$updateNotification .= "$extension/$action";
- $fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
if (!$this->yellow->system->save($fileName, array("updateNotification" => $updateNotification))) {
$statusCode = 500;
$this->yellow->page->error(500, "Can't write file '$fileName'!");
@@ -268,9 +266,8 @@ class YellowUpdate {
}
// Return extension information
- public function getExtensionInformation($args) {
- $command = array_shift($args);
- $extensions = array_unique(array_filter($args, "strlen"));
+ public function getExtensionInformation($text) {
+ $extensions = array_unique(array_filter($this->yellow->toolbox->getTextArguments($text), "strlen"));
$force = false;
foreach ($extensions as $key=>$value) {
if ($value=="force") {
@@ -278,7 +275,7 @@ class YellowUpdate {
unset($extensions[$key]);
}
}
- return array($command, $extensions, $force);
+ return array($extensions, $force);
}
// Return install information
@@ -394,7 +391,7 @@ class YellowUpdate {
// Download extensions
public function downloadExtensions($data) {
$statusCode = 200;
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
$fileExtension = $this->yellow->system->get("coreDownloadExtension");
foreach ($data as $key=>$value) {
$fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
@@ -422,7 +419,7 @@ class YellowUpdate {
public function updateExtensions($action, $force = false) {
$statusCode = 200;
if (function_exists("opcache_reset")) opcache_reset();
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
$statusCode = max($statusCode, $this->updateExtensionArchive($entry, $action, $force));
if (!$this->yellow->toolbox->deleteFile($entry)) {
@@ -507,7 +504,7 @@ class YellowUpdate {
}
}
if ($update) {
- if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir")) ||
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory")) ||
!$this->yellow->toolbox->createFile($fileName, $fileData) ||
!$this->yellow->toolbox->modifyFile($fileName, $modified)) {
$statusCode = 500;
@@ -515,7 +512,7 @@ class YellowUpdate {
}
}
if ($delete) {
- if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"))) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
}
@@ -546,8 +543,8 @@ class YellowUpdate {
$fileNameSource = $pathBase.basename($entry);
}
if ($this->yellow->system->get("coreMultiLanguageMode") && $this->yellow->lookup->isContentFile($fileName)) {
- $contentDirLength = strlenu($this->yellow->system->get("coreContentDir"));
- $fileNameDestination = $page->fileName.substru($fileName, $contentDirLength);
+ $contentDirectoryLength = strlenu($this->yellow->system->get("coreContentDirectory"));
+ $fileNameDestination = $page->fileName.substru($fileName, $contentDirectoryLength);
} else {
$fileNameDestination = $fileName;
}
@@ -575,7 +572,7 @@ class YellowUpdate {
$statusCode = 200;
$fileName = $this->yellow->toolbox->normaliseTokens($fileName);
if ($this->yellow->lookup->isValidFile($fileName) && !empty($extension)) {
- if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"))) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
}
@@ -693,7 +690,7 @@ class YellowUpdate {
// Check if extension pending
public function isExtensionPending() {
- $path = $this->yellow->system->get("coreExtensionDir");
+ $path = $this->yellow->system->get("coreExtensionDirectory");
return count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", false, false))>0;
}
}
diff --git a/system/settings/system.ini b/system/settings/system.ini
@@ -42,7 +42,7 @@ CoreDownloadExtension: .download
CoreTextFile: text.ini
CoreLogFile: yellow.log
UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions
-UpdateExtensionDir: /Users/yourname/Documents/GitHub/
+UpdateExtensionDirectory: /Users/yourname/Documents/GitHub/
UpdateExtensionFile: extension.ini
UpdateVersionFile: version.ini
UpdateWaffleFile: waffle.ini
diff --git a/yellow.php b/yellow.php
@@ -12,5 +12,5 @@ if (PHP_SAPI!="cli") {
} else {
$yellow = new YellowCore();
$yellow->load();
- exit($yellow->command($argv[1], $argv[2], $argv[3], $argv[4], $argv[5], $argv[6], $argv[7]));
+ exit($yellow->command());
}