Updated API, added core prefix to many settings

This commit is contained in:
markseu 2019-12-15 17:22:07 +01:00
parent b815d58f4b
commit f9f859846b
15 changed files with 334 additions and 291 deletions

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowBundle {
const VERSION = "0.8.5";
const VERSION = "0.8.6";
const TYPE = "feature";
public $yellow; //access to API
@ -37,7 +37,7 @@ class YellowBundle {
$statusCode = 0;
list($command, $path) = $args;
if ($path=="all") {
$path = $this->yellow->system->get("resourceDir");
$path = $this->yellow->system->get("coreResourceDir");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/bundle-.*/", false, false) as $entry) {
if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
}
@ -79,9 +79,9 @@ class YellowBundle {
// Process bundle, create file on demand
public function processBundle($data, $type) {
$fileNames = array();
$scheme = $this->yellow->system->get("serverScheme");
$address = $this->yellow->system->get("serverAddress");
$base = $this->yellow->system->get("serverBase");
$scheme = $this->yellow->system->get("coreServerScheme");
$address = $this->yellow->system->get("coreServerAddress");
$base = $this->yellow->system->get("coreServerBase");
foreach ($data as $key=>$value) {
if (preg_match("/^\w+:/", $key)) continue;
if (preg_match("/data-bundle=\"none\"/i", $value)) continue;
@ -96,8 +96,8 @@ class YellowBundle {
}
if (!empty($fileNames)) {
$id = substru(md5(implode($fileNames).$base), 0, 10);
$fileNameBundle = $this->yellow->system->get("resourceDir")."bundle-$id.min.$type";;
$locationBundle = $base.$this->yellow->system->get("resourceLocation")."bundle-$id.min.$type";
$fileNameBundle = $this->yellow->system->get("coreResourceDir")."bundle-$id.min.$type";;
$locationBundle = $base.$this->yellow->system->get("coreResourceLocation")."bundle-$id.min.$type";
if ($type=="css") {
$data[$locationBundle] = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".htmlspecialchars($locationBundle)."\" />\n";
} else {
@ -126,11 +126,11 @@ class YellowBundle {
// Process bundle, convert URLs
public function processBundleConvert($scheme, $address, $base, $fileData, $fileName, $type) {
if ($type=="css") {
$extensionDirLength = strlenu($this->yellow->system->get("extensionDir"));
if (substru($fileName, 0, $extensionDirLength) == $this->yellow->system->get("extensionDir")) {
$base .= $this->yellow->system->get("extensionLocation");
$extensionDirLength = strlenu($this->yellow->system->get("coreExtensionDir"));
if (substru($fileName, 0, $extensionDirLength) == $this->yellow->system->get("coreExtensionDir")) {
$base .= $this->yellow->system->get("coreExtensionLocation");
} else {
$base .= $this->yellow->system->get("resourceLocation");
$base .= $this->yellow->system->get("coreResourceLocation");
}
$thisCompatible = $this;
$callback = function ($matches) use ($thisCompatible, $scheme, $address, $base) {

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCommand {
const VERSION = "0.8.7";
const VERSION = "0.8.8";
const TYPE = "feature";
const PRIORITY = "3";
public $yellow; //access to API
@ -82,8 +82,8 @@ class YellowCommand {
$statusCode = 500;
$this->files = 0;
$this->errors = 1;
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
echo "ERROR building files: Please configure StaticUrl in file '$fileName'!\n";
$fileName = $this->yellow->system->get("coreSettingDir").$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" : "");
echo ", $this->errors error".($this->errors!=1 ? "s" : "")."\n";
@ -96,11 +96,11 @@ class YellowCommand {
// Build static files
public function buildStaticFiles($path, $locationFilter) {
$path = rtrim(empty($path) ? $this->yellow->system->get("staticDir") : $path, "/");
$path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
$this->files = $this->errors = 0;
$this->locationsArgs = $this->locationsArgsPagination = array();
$statusCode = empty($locationFilter) ? $this->cleanStaticFiles($path, $locationFilter) : 200;
$staticUrl = $this->yellow->system->get("staticUrl");
$staticUrl = $this->yellow->system->get("coreStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
$locations = $this->getContentLocations();
$filesEstimated = count($locations);
@ -150,7 +150,7 @@ class YellowCommand {
$this->yellow->page->fileName = substru($location, 1);
if (!is_readable($this->yellow->page->fileName)) {
ob_start();
$staticUrl = $this->yellow->system->get("staticUrl");
$staticUrl = $this->yellow->system->get("coreStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
$statusCode = $this->requestStaticFile($scheme, $address, $base, $location);
if ($statusCode<400 || $error) {
@ -225,7 +225,7 @@ class YellowCommand {
// Analyse locations with arguments
public function analyseLocations($scheme, $address, $base, $rawData) {
$pagination = $this->yellow->system->get("contentPagination");
$pagination = $this->yellow->system->get("coreContentPagination");
preg_match_all("/<(.*?)href=\"([^\"]+)\"(.*?)>/i", $rawData, $matches);
foreach ($matches[2] as $match) {
$location = rawurldecode($match);
@ -265,8 +265,8 @@ class YellowCommand {
$statusCode = 500;
$this->links = 0;
$this->errors = 1;
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
echo "ERROR checking files: Please configure StaticUrl in file '$fileName'!\n";
$fileName = $this->yellow->system->get("coreSettingDir").$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" : "");
echo ", $this->errors error".($this->errors!=1 ? "s" : "")."\n";
@ -279,9 +279,9 @@ class YellowCommand {
// Check static files for broken links
public function checkStaticFiles($path, $locationFilter) {
$path = rtrim(empty($path) ? $this->yellow->system->get("staticDir") : $path, "/");
$path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
$this->links = $this->errors = 0;
$regex = "/^[^.]+$|".$this->yellow->system->get("staticDefaultFile")."$/";
$regex = "/^[^.]+$|".$this->yellow->system->get("coreStaticDefaultFile")."$/";
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($path, $regex, false, false);
list($statusCodeFiles, $links) = $this->analyseLinks($path, $locationFilter, $fileNames);
list($statusCodeLinks, $broken, $redirect) = $this->analyseStatus($path, $links);
@ -297,7 +297,7 @@ class YellowCommand {
$statusCode = 200;
$links = array();
if (!empty($fileNames)) {
$staticUrl = $this->yellow->system->get("staticUrl");
$staticUrl = $this->yellow->system->get("coreStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
foreach ($fileNames as $fileName) {
if (is_readable($fileName)) {
@ -340,7 +340,7 @@ class YellowCommand {
public function analyseStatus($path, $links) {
$statusCode = 200;
$remote = $broken = $redirect = $data = array();
$staticUrl = $this->yellow->system->get("staticUrl");
$staticUrl = $this->yellow->system->get("coreStaticUrl");
$staticUrlLength = strlenu(rtrim($staticUrl, "/"));
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
$staticLocations = $this->getContentLocations(true);
@ -412,7 +412,7 @@ class YellowCommand {
// Clean static files and directories
public function cleanStaticFiles($path, $location) {
$statusCode = 200;
$path = rtrim(empty($path) ? $this->yellow->system->get("staticDir") : $path, "/");
$path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticDir") : $path, "/");
if (empty($location)) {
$statusCode = max($statusCode, $this->broadcastCommand("clean", "all"));
$statusCode = max($statusCode, $this->cleanStaticDirectory($path));
@ -482,16 +482,16 @@ class YellowCommand {
// Check static settings
public function checkStaticSettings() {
return !empty($this->yellow->system->get("staticUrl"));
return !empty($this->yellow->system->get("coreStaticUrl"));
}
// Check static directory
public function checkStaticDirectory($path) {
$ok = false;
if (!empty($path)) {
if ($path==rtrim($this->yellow->system->get("staticDir"), "/")) $ok = true;
if ($path==rtrim($this->yellow->system->get("trashDir"), "/")) $ok = true;
if (is_file("$path/".$this->yellow->system->get("staticDefaultFile"))) $ok = true;
if ($path==rtrim($this->yellow->system->get("coreStaticDir"), "/")) $ok = true;
if ($path==rtrim($this->yellow->system->get("coreTrashDir"), "/")) $ok = true;
if (is_file("$path/".$this->yellow->system->get("coreStaticDefaultFile"))) $ok = true;
if (is_file("$path/yellow.php")) $ok = false;
}
return $ok;
@ -541,9 +541,9 @@ class YellowCommand {
public function getStaticFile($path, $location, $statusCode) {
if ($statusCode<400) {
$fileName = $path.$location;
if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("staticDefaultFile");
if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("coreStaticDefaultFile");
} elseif ($statusCode==404) {
$fileName = $path."/".$this->yellow->system->get("staticErrorFile");
$fileName = $path."/".$this->yellow->system->get("coreStaticErrorFile");
}
return $fileName;
}
@ -551,8 +551,8 @@ class YellowCommand {
// Return static location
public function getStaticLocation($path, $fileName) {
$location = substru($fileName, strlenu($path));
if (basename($location)==$this->yellow->system->get("staticDefaultFile")) {
$defaultFileLength = strlenu($this->yellow->system->get("staticDefaultFile"));
if (basename($location)==$this->yellow->system->get("coreStaticDefaultFile")) {
$defaultFileLength = strlenu($this->yellow->system->get("coreStaticDefaultFile"));
$location = substru($location, 0, -$defaultFileLength);
}
return $location;
@ -570,7 +570,7 @@ class YellowCommand {
// Return content locations
public function getContentLocations($includeAll = false) {
$locations = array();
$staticUrl = $this->yellow->system->get("staticUrl");
$staticUrl = $this->yellow->system->get("coreStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
$this->yellow->page->setRequestInformation($scheme, $address, $base, "", "");
foreach ($this->yellow->content->index(true, true) as $page) {
@ -585,7 +585,7 @@ class YellowCommand {
// Return media locations
public function getMediaLocations() {
$locations = array();
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("mediaDir"), "/.*/", false, false);
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreMediaDir"), "/.*/", false, false);
foreach ($fileNames as $fileName) {
array_push($locations, "/".$fileName);
}
@ -596,15 +596,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("extensionDir"));
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("extensionDir"), $regex, false, false);
$extensionDirLength = strlenu($this->yellow->system->get("coreExtensionDir"));
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreExtensionDir"), $regex, false, false);
foreach ($fileNames as $fileName) {
array_push($locations, $this->yellow->system->get("extensionLocation").substru($fileName, $extensionDirLength));
array_push($locations, $this->yellow->system->get("coreExtensionLocation").substru($fileName, $extensionDirLength));
}
$resourceDirLength = strlenu($this->yellow->system->get("resourceDir"));
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("resourceDir"), $regex, false, false);
$resourceDirLength = strlenu($this->yellow->system->get("coreResourceDir"));
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreResourceDir"), $regex, false, false);
foreach ($fileNames as $fileName) {
array_push($locations, $this->yellow->system->get("resourceLocation").substru($fileName, $resourceDirLength));
array_push($locations, $this->yellow->system->get("coreResourceLocation").substru($fileName, $resourceDirLength));
}
return $locations;
}
@ -613,11 +613,11 @@ class YellowCommand {
public function getExtraLocations($path) {
$locations = array();
$pathIgnore = "($path/|".
$this->yellow->system->get("staticDir")."|".
$this->yellow->system->get("cacheDir")."|".
$this->yellow->system->get("contentDir")."|".
$this->yellow->system->get("mediaDir")."|".
$this->yellow->system->get("systemDir").")";
$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").")";
$fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive(".", "/.*/", false, false);
foreach ($fileNames as $fileName) {
$fileName = substru($fileName, 2);

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCore {
const VERSION = "0.8.7";
const VERSION = "0.8.8";
const TYPE = "feature";
public $page; //current page
public $content; //content files from file system
@ -27,7 +27,6 @@ class YellowCore {
$this->system->setDefault("sitename", "Yellow");
$this->system->setDefault("author", "Yellow");
$this->system->setDefault("email", "webmaster");
$this->system->setDefault("timezone", "UTC");
$this->system->setDefault("language", "en");
$this->system->setDefault("layout", "default");
$this->system->setDefault("theme", "default");
@ -37,39 +36,40 @@ class YellowCore {
$this->system->setDefault("header", "header");
$this->system->setDefault("footer", "footer");
$this->system->setDefault("sidebar", "sidebar");
$this->system->setDefault("staticUrl", "");
$this->system->setDefault("staticDefaultFile", "index.html");
$this->system->setDefault("staticErrorFile", "404.html");
$this->system->setDefault("staticDir", "public/");
$this->system->setDefault("cacheDir", "cache/");
$this->system->setDefault("mediaLocation", "/media/");
$this->system->setDefault("downloadLocation", "/media/downloads/");
$this->system->setDefault("imageLocation", "/media/images/");
$this->system->setDefault("extensionLocation", "/media/extensions/");
$this->system->setDefault("resourceLocation", "/media/resources/");
$this->system->setDefault("mediaDir", "media/");
$this->system->setDefault("downloadDir", "media/downloads/");
$this->system->setDefault("imageDir", "media/images/");
$this->system->setDefault("systemDir", "system/");
$this->system->setDefault("extensionDir", "system/extensions/");
$this->system->setDefault("layoutDir", "system/layouts/");
$this->system->setDefault("resourceDir", "system/resources/");
$this->system->setDefault("settingDir", "system/settings/");
$this->system->setDefault("trashDir", "system/trash/");
$this->system->setDefault("contentDir", "content/");
$this->system->setDefault("contentRootDir", "default/");
$this->system->setDefault("contentHomeDir", "home/");
$this->system->setDefault("contentSharedDir", "shared/");
$this->system->setDefault("contentPagination", "page");
$this->system->setDefault("contentDefaultFile", "page.md");
$this->system->setDefault("contentExtension", ".md");
$this->system->setDefault("downloadExtension", ".download");
$this->system->setDefault("systemFile", "system.ini");
$this->system->setDefault("textFile", "text.ini");
$this->system->setDefault("logFile", "yellow.log");
$this->system->setDefault("coreStaticUrl", "");
$this->system->setDefault("coreStaticDefaultFile", "index.html");
$this->system->setDefault("coreStaticErrorFile", "404.html");
$this->system->setDefault("coreStaticDir", "public/");
$this->system->setDefault("coreCacheDir", "cache/");
$this->system->setDefault("coreServerUrl", "auto");
$this->system->setDefault("coreServerTimezone", "UTC");
$this->system->setDefault("coreSafeMode", "0");
$this->system->setDefault("coreMultiLanguageMode", "0");
$this->system->setDefault("serverUrl", "");
$this->system->setDefault("coreMediaLocation", "/media/");
$this->system->setDefault("coreDownloadLocation", "/media/downloads/");
$this->system->setDefault("coreImageLocation", "/media/images/");
$this->system->setDefault("coreExtensionLocation", "/media/extensions/");
$this->system->setDefault("coreResourceLocation", "/media/resources/");
$this->system->setDefault("coreMediaDir", "media/");
$this->system->setDefault("coreDownloadDir", "media/downloads/");
$this->system->setDefault("coreImageDir", "media/images/");
$this->system->setDefault("coreSystemDir", "system/");
$this->system->setDefault("coreExtensionDir", "system/extensions/");
$this->system->setDefault("coreLayoutDir", "system/layouts/");
$this->system->setDefault("coreResourceDir", "system/resources/");
$this->system->setDefault("coreSettingDir", "system/settings/");
$this->system->setDefault("coreTrashDir", "system/trash/");
$this->system->setDefault("coreContentDir", "content/");
$this->system->setDefault("coreContentRootDir", "default/");
$this->system->setDefault("coreContentHomeDir", "home/");
$this->system->setDefault("coreContentSharedDir", "shared/");
$this->system->setDefault("coreContentPagination", "page");
$this->system->setDefault("coreContentDefaultFile", "page.md");
$this->system->setDefault("coreContentExtension", ".md");
$this->system->setDefault("coreDownloadExtension", ".download");
$this->system->setDefault("coreSystemFile", "system.ini");
$this->system->setDefault("coreTextFile", "text.ini");
$this->system->setDefault("coreLogFile", "yellow.log");
}
public function __destruct() {
@ -83,10 +83,10 @@ class YellowCore {
echo "YellowCore::load Datenstrom Yellow ".YellowCore::VERSION.", PHP ".PHP_VERSION.", $serverVersion<br/>\n";
}
$this->toolbox->timerStart($time);
$this->system->load($this->system->get("settingDir").$this->system->get("systemFile"));
$this->extensions->load($this->system->get("extensionDir"));
$this->text->load($this->system->get("extensionDir"));
$this->text->load($this->system->get("settingDir"), $this->system->get("textFile"), $this->system->get("language"));
$this->system->load($this->system->get("coreSettingDir").$this->system->get("coreSystemFile"));
$this->extensions->load($this->system->get("coreExtensionDir"));
$this->text->load($this->system->get("coreExtensionDir"));
$this->text->load($this->system->get("coreSettingDir"), $this->system->get("coreTextFile"), $this->system->get("language"));
$this->lookup->detectFileSystem();
$this->startup();
$this->toolbox->timerStop($time);
@ -311,7 +311,7 @@ class YellowCore {
}
if ($statusCode==0) {
$line = date("Y-m-d H:i:s")." ".trim($action)." ".trim($message)."\n";
$this->toolbox->appendFile($this->system->get("extensionDir").$this->system->get("logFile"), $line);
$this->toolbox->appendFile($this->system->get("coreExtensionDir").$this->system->get("coreLogFile"), $line);
}
}
@ -329,10 +329,13 @@ class YellowCore {
// Return request information
public function getRequestInformation($scheme = "", $address = "", $base = "") {
if (empty($scheme) && empty($address) && empty($base)) {
$url = $this->system->get("serverUrl");
if (empty($url) || $this->isCommandLine()) $url = $this->toolbox->getServerUrl();
$url = $this->system->get("coreServerUrl");
if ($url=="auto" || $this->isCommandLine()) $url = $this->toolbox->getServerUrl();
list($scheme, $address, $base) = $this->lookup->getUrlInformation($url);
$this->system->set("serverScheme", $scheme);
$this->system->set("coreServerScheme", $scheme);
$this->system->set("coreServerAddress", $address);
$this->system->set("coreServerBase", $base);
$this->system->set("serverScheme", $scheme); //TODO: remove later, for backwards compatibility
$this->system->set("serverAddress", $address);
$this->system->set("serverBase", $base);
if (defined("DEBUG") && DEBUG>=3) echo "YellowCore::getRequestInformation $scheme://$address$base<br/>\n";
@ -346,7 +349,7 @@ class YellowCore {
// Return request location
public function getRequestLocationArgsClean() {
return $this->toolbox->getLocationArgsClean($this->system->get("contentPagination"));
return $this->toolbox->getLocationArgsClean($this->system->get("coreContentPagination"));
}
// Return request language
@ -451,18 +454,18 @@ class YellowPage {
if ($this->get("status")=="unlisted") $this->visible = false;
if ($this->get("status")=="shared") $this->available = false;
$this->set("pageRead", $this->yellow->lookup->normaliseUrl(
$this->yellow->system->get("serverScheme"),
$this->yellow->system->get("serverAddress"),
$this->yellow->system->get("serverBase"),
$this->yellow->system->get("coreServerScheme"),
$this->yellow->system->get("coreServerAddress"),
$this->yellow->system->get("coreServerBase"),
$this->location));
$this->set("pageEdit", $this->yellow->lookup->normaliseUrl(
$this->yellow->system->get("serverScheme"),
$this->yellow->system->get("serverAddress"),
$this->yellow->system->get("serverBase"),
$this->yellow->system->get("coreServerScheme"),
$this->yellow->system->get("coreServerAddress"),
$this->yellow->system->get("coreServerBase"),
rtrim($this->yellow->system->get("editLocation"), "/").$this->location));
} else {
$this->set("type", $this->yellow->toolbox->getFileType($this->fileName));
$this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("mediaDir")));
$this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("coreMediaDir")));
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
}
if (!empty($pageError)) $this->set("pageError", $pageError);
@ -531,8 +534,8 @@ class YellowPage {
if ($name=="yellow" && $type=="inline") {
$output = "Datenstrom Yellow ".YellowCore::VERSION;
if ($text=="error") $output = $this->get("pageError");
if ($text=="logfile") {
$fileName = $this->yellow->system->get("extensionDir").$this->yellow->system->get("logFile");
if ($text=="log") {
$fileName = $this->yellow->system->get("coreExtensionDir").$this->yellow->system->get("coreLogFile");
$fileHandle = @fopen($fileName, "r");
if ($fileHandle) {
$dataBufferSize = 512;
@ -559,7 +562,7 @@ class YellowPage {
if (!$this->isHeader("Content-Type")) $this->setHeader("Content-Type", "text/html; charset=utf-8");
if (!$this->isHeader("Content-Modified")) $this->setHeader("Content-Modified", $this->getModified(true));
if (!$this->isHeader("Last-Modified")) $this->setHeader("Last-Modified", $this->getLastModified(true));
$fileNameTheme = $this->yellow->system->get("resourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$fileNameTheme = $this->yellow->system->get("coreResourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
if (!is_file($fileNameTheme)) {
$this->error(500, "Theme '".$this->get("theme")."' does not exist!");
}
@ -612,8 +615,8 @@ class YellowPage {
// Include page layout
public function includeLayout($name) {
$fileNameLayoutNormal = $this->yellow->system->get("layoutDir").$this->yellow->lookup->normaliseName($name).".html";
$fileNameLayoutTheme = $this->yellow->system->get("layoutDir").
$fileNameLayoutNormal = $this->yellow->system->get("coreLayoutDir").$this->yellow->lookup->normaliseName($name).".html";
$fileNameLayoutTheme = $this->yellow->system->get("coreLayoutDir").
$this->yellow->lookup->normaliseName($this->get("theme"))."-".$this->yellow->lookup->normaliseName($name).".html";
if (is_file($fileNameLayoutTheme)) {
if (defined("DEBUG") && DEBUG>=2) echo "YellowPage::includeLayout file:$fileNameLayoutTheme<br>\n";
@ -772,16 +775,16 @@ class YellowPage {
}
}
if ($name=="header") {
$fileNameTheme = $this->yellow->system->get("resourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$fileNameTheme = $this->yellow->system->get("coreResourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
if (is_file($fileNameTheme)) {
$locationTheme = $this->yellow->system->get("serverBase").
$this->yellow->system->get("resourceLocation").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$locationTheme = $this->yellow->system->get("coreServerBase").
$this->yellow->system->get("coreResourceLocation").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$output .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$locationTheme\" />\n";
}
$fileNameScript = $this->yellow->system->get("resourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".js";
$fileNameScript = $this->yellow->system->get("coreResourceDir").$this->yellow->lookup->normaliseName($this->get("theme")).".js";
if (is_file($fileNameScript)) {
$locationScript = $this->yellow->system->get("serverBase").
$this->yellow->system->get("resourceLocation").$this->yellow->lookup->normaliseName($this->get("theme")).".js";
$locationScript = $this->yellow->system->get("coreServerBase").
$this->yellow->system->get("coreResourceLocation").$this->yellow->lookup->normaliseName($this->get("theme")).".js";
$output .= "<script type=\"text/javascript\" src=\"$locationScript\"></script>\n";
}
}
@ -1072,7 +1075,7 @@ class YellowPageCollection extends ArrayObject {
public function pagination($limit, $reverse = true) {
$this->paginationNumber = 1;
$this->paginationCount = ceil($this->count() / $limit);
$pagination = $this->yellow->system->get("contentPagination");
$pagination = $this->yellow->system->get("coreContentPagination");
if (isset($_REQUEST[$pagination])) $this->paginationNumber = intval($_REQUEST[$pagination]);
if ($this->paginationNumber>$this->paginationCount) $this->paginationNumber = 0;
if ($this->paginationNumber>=1) {
@ -1096,7 +1099,7 @@ class YellowPageCollection extends ArrayObject {
// Return location for a page in pagination
public function getPaginationLocation($absoluteLocation = true, $pageNumber = 1) {
if ($pageNumber>=1 && $pageNumber<=$this->paginationCount) {
$pagination = $this->yellow->system->get("contentPagination");
$pagination = $this->yellow->system->get("coreContentPagination");
$location = $this->yellow->page->getLocation($absoluteLocation);
$locationArgs = $this->yellow->toolbox->getLocationArgsNew(
$pageNumber>1 ? "$pagination:$pageNumber" : "$pagination:", $pagination);
@ -1267,7 +1270,7 @@ class YellowContent {
$location = $this->yellow->lookup->getDirectoryLocation($this->yellow->page->location).$name;
$page = $this->find($location);
if ($page==null) {
$location = $this->getHomeLocation($this->yellow->page->location).$this->yellow->system->get("contentSharedDir").$name;
$location = $this->getHomeLocation($this->yellow->page->location).$this->yellow->system->get("coreContentSharedDir").$name;
$page = $this->find($location);
}
return $page;
@ -1368,9 +1371,9 @@ class YellowMedia {
$this->files[$location] = array();
$scheme = $this->yellow->page->scheme;
$address = $this->yellow->page->address;
$base = $this->yellow->system->get("serverBase");
$base = $this->yellow->system->get("coreServerBase");
if (empty($location)) {
$fileNames = array($this->yellow->system->get("mediaDir"));
$fileNames = array($this->yellow->system->get("coreMediaDir"));
} else {
$fileNames = array();
$path = substru($location, 1);
@ -1393,7 +1396,7 @@ class YellowMedia {
// Return page with media file information, null if not found
public function find($location, $absoluteLocation = false) {
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->system->get("serverBase")));
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->system->get("coreServerBase")));
foreach ($this->scanLocation($this->getParentLocation($location)) as $file) {
if ($file->location==$location) {
if ($this->yellow->lookup->isFileLocation($file->location)) {
@ -1443,12 +1446,12 @@ class YellowMedia {
// Return home location
public function getHomeLocation($location) {
return $this->yellow->system->get("mediaLocation");
return $this->yellow->system->get("coreMediaLocation");
}
// Return parent location
public function getParentLocation($location) {
$token = rtrim($this->yellow->system->get("mediaLocation"), "/");
$token = rtrim($this->yellow->system->get("coreMediaLocation"), "/");
if (preg_match("#^($token.*\/).+?$#", $location, $matches)) {
if ($matches[1]!="$token/" || $this->yellow->lookup->isFileLocation($location)) $parentLocation = $matches[1];
}
@ -1458,7 +1461,7 @@ class YellowMedia {
// Return top-level location
public function getParentTopLocation($location) {
$token = rtrim($this->yellow->system->get("mediaLocation"), "/");
$token = rtrim($this->yellow->system->get("coreMediaLocation"), "/");
if (preg_match("#^($token.+?\/)#", $location, $matches)) $parentTopLocation = $matches[1];
if (empty($parentTopLocation)) $parentTopLocation = "$token/";
return $parentTopLocation;
@ -1654,7 +1657,7 @@ class YellowText {
$dateWeekdays = preg_split("/\s*,\s*/", $this->get("dateWeekdays"));
$month = $dateMonths[date("n", $timestamp) - 1];
$weekday = $dateWeekdays[date("N", $timestamp) - 1];
$timeZone = $this->yellow->system->get("timezone");
$timeZone = $this->yellow->system->get("coreServerTimezone");
$timeZoneHelper = new DateTime(null, new DateTimeZone($timeZone));
$timeZoneOffset = $timeZoneHelper->getOffset();
$timeZoneAbbreviation = "GMT".($timeZoneOffset<0 ? "-" : "+").abs(intval($timeZoneOffset/3600));
@ -1746,16 +1749,16 @@ class YellowLookup {
// Detect file system
public function detectFileSystem() {
list($pathRoot, $pathHome) = $this->findFileSystemInformation();
$this->yellow->system->set("contentRootDir", $pathRoot);
$this->yellow->system->set("contentHomeDir", $pathHome);
date_default_timezone_set($this->yellow->system->get("timezone"));
$this->yellow->system->set("coreContentRootDir", $pathRoot);
$this->yellow->system->set("coreContentHomeDir", $pathHome);
date_default_timezone_set($this->yellow->system->get("coreServerTimezone"));
}
// Return file system information
public function findFileSystemInformation() {
$path = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathHome = $this->yellow->system->get("contentHomeDir");
$path = $this->yellow->system->get("coreContentDir");
$pathRoot = $this->yellow->system->get("coreContentRootDir");
$pathHome = $this->yellow->system->get("coreContentHomeDir");
if (!$this->yellow->system->get("coreMultiLanguageMode")) $pathRoot = "";
if (!empty($pathRoot)) {
$token = $root = rtrim($pathRoot, "/");
@ -1786,8 +1789,8 @@ class YellowLookup {
// Return root locations
public function findRootLocations($includePath = true) {
$locations = array();
$pathBase = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathBase = $this->yellow->system->get("coreContentDir");
$pathRoot = $this->yellow->system->get("coreContentRootDir");
if (!empty($pathRoot)) {
foreach ($this->yellow->toolbox->getDirectoryEntries($pathBase, "/.*/", true, true, false) as $entry) {
$token = $this->normaliseToken($entry)."/";
@ -1804,11 +1807,11 @@ class YellowLookup {
// Return location from file path
public function findLocationFromFile($fileName) {
$location = "/";
$pathBase = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathHome = $this->yellow->system->get("contentHomeDir");
$fileDefault = $this->yellow->system->get("contentDefaultFile");
$fileExtension = $this->yellow->system->get("contentExtension");
$pathBase = $this->yellow->system->get("coreContentDir");
$pathRoot = $this->yellow->system->get("coreContentRootDir");
$pathHome = $this->yellow->system->get("coreContentHomeDir");
$fileDefault = $this->yellow->system->get("coreContentDefaultFile");
$fileExtension = $this->yellow->system->get("coreContentExtension");
if (substru($fileName, 0, strlenu($pathBase))==$pathBase) {
$fileName = substru($fileName, strlenu($pathBase));
$tokens = explode("/", $fileName);
@ -1840,11 +1843,11 @@ class YellowLookup {
// Return file path from location
public function findFileFromLocation($location, $directory = false) {
$path = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathHome = $this->yellow->system->get("contentHomeDir");
$fileDefault = $this->yellow->system->get("contentDefaultFile");
$fileExtension = $this->yellow->system->get("contentExtension");
$path = $this->yellow->system->get("coreContentDir");
$pathRoot = $this->yellow->system->get("coreContentRootDir");
$pathHome = $this->yellow->system->get("coreContentHomeDir");
$fileDefault = $this->yellow->system->get("coreContentDefaultFile");
$fileExtension = $this->yellow->system->get("coreContentExtension");
$tokens = explode("/", $location);
if ($this->isRootLocation($location)) {
if (!empty($pathRoot)) {
@ -1930,8 +1933,8 @@ class YellowLookup {
// Return children from location
public function findChildrenFromLocation($location) {
$fileNames = array();
$fileDefault = $this->yellow->system->get("contentDefaultFile");
$fileExtension = $this->yellow->system->get("contentExtension");
$fileDefault = $this->yellow->system->get("coreContentDefaultFile");
$fileExtension = $this->yellow->system->get("coreContentExtension");
if (!$this->isFileLocation($location)) {
$path = $this->findFileFromLocation($location, true);
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) {
@ -1954,8 +1957,8 @@ class YellowLookup {
// Return language from file path
public function findLanguageFromFile($fileName, $languageDefault) {
$language = $languageDefault;
$pathBase = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathBase = $this->yellow->system->get("coreContentDir");
$pathRoot = $this->yellow->system->get("coreContentRootDir");
if (!empty($pathRoot)) {
$fileName = substru($fileName, strlenu($pathBase));
if (preg_match("/^(.+?)\//", $fileName, $matches)) $name = $this->normaliseToken($matches[1]);
@ -1967,9 +1970,9 @@ class YellowLookup {
// Return file path from media location
public function findFileFromMedia($location) {
if ($this->isFileLocation($location)) {
$mediaLocationLength = strlenu($this->yellow->system->get("mediaLocation"));
if (substru($location, 0, $mediaLocationLength)==$this->yellow->system->get("mediaLocation")) {
$fileName = $this->yellow->system->get("mediaDir").substru($location, 7);
$mediaLocationLength = strlenu($this->yellow->system->get("coreMediaLocation"));
if (substru($location, 0, $mediaLocationLength)==$this->yellow->system->get("coreMediaLocation")) {
$fileName = $this->yellow->system->get("coreMediaDir").substru($location, 7);
}
}
return $fileName;
@ -1978,12 +1981,12 @@ class YellowLookup {
// Return file path from system location
public function findFileFromSystem($location) {
if (preg_match("/\.(css|gif|ico|js|jpg|png|svg|txt|woff|woff2)$/", $location)) {
$extensionLocationLength = strlenu($this->yellow->system->get("extensionLocation"));
$resourceLocationLength = strlenu($this->yellow->system->get("resourceLocation"));
if (substru($location, 0, $extensionLocationLength)==$this->yellow->system->get("extensionLocation")) {
$fileName = $this->yellow->system->get("extensionDir").substru($location, $extensionLocationLength);
} elseif (substru($location, 0, $resourceLocationLength)==$this->yellow->system->get("resourceLocation")) {
$fileName = $this->yellow->system->get("resourceDir").substru($location, $resourceLocationLength);
$extensionLocationLength = strlenu($this->yellow->system->get("coreExtensionLocation"));
$resourceLocationLength = strlenu($this->yellow->system->get("coreResourceLocation"));
if (substru($location, 0, $extensionLocationLength)==$this->yellow->system->get("coreExtensionLocation")) {
$fileName = $this->yellow->system->get("coreExtensionDir").substru($location, $extensionLocationLength);
} elseif (substru($location, 0, $resourceLocationLength)==$this->yellow->system->get("coreResourceLocation")) {
$fileName = $this->yellow->system->get("coreResourceDir").substru($location, $resourceLocationLength);
}
}
return $fileName;
@ -1993,8 +1996,8 @@ class YellowLookup {
public function findFileFromCache($location, $fileName, $cacheable) {
if ($cacheable) {
$location .= $this->yellow->toolbox->getLocationArgs();
$fileNameStatic = rtrim($this->yellow->system->get("cacheDir"), "/").$location;
if (!$this->isFileLocation($location)) $fileNameStatic .= $this->yellow->system->get("staticDefaultFile");
$fileNameStatic = rtrim($this->yellow->system->get("coreCacheDir"), "/").$location;
if (!$this->isFileLocation($location)) $fileNameStatic .= $this->yellow->system->get("coreStaticDefaultFile");
if (is_readable($fileNameStatic)) $fileName = $fileNameStatic;
}
return $fileName;
@ -2043,7 +2046,7 @@ class YellowLookup {
public function normaliseLocation($location, $pageLocation, $filterStrict = true) {
if (!preg_match("/^\w+:/", trim(html_entity_decode($location, ENT_QUOTES, "UTF-8")))) {
$pageBase = $this->yellow->page->base;
$mediaBase = $this->yellow->system->get("serverBase").$this->yellow->system->get("mediaLocation");
$mediaBase = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreMediaLocation");
if (preg_match("/^\#/", $location)) {
$location = $pageBase.$pageLocation.$location;
} elseif (!preg_match("/^\//", $location)) {
@ -2119,9 +2122,9 @@ class YellowLookup {
// Check if location is available
public function isAvailableLocation($location, $fileName) {
$available = true;
$pathBase = $this->yellow->system->get("contentDir");
$pathBase = $this->yellow->system->get("coreContentDir");
if (substru($fileName, 0, strlenu($pathBase))==$pathBase) {
$sharedLocation = $this->yellow->content->getHomeLocation($location).$this->yellow->system->get("contentSharedDir");
$sharedLocation = $this->yellow->content->getHomeLocation($location).$this->yellow->system->get("coreContentSharedDir");
if (substru($location, 0, strlenu($sharedLocation))==$sharedLocation) $available = false;
}
return $available;
@ -2143,30 +2146,30 @@ class YellowLookup {
// Check if file is valid
public function isValidFile($fileName) {
$contentDirLength = strlenu($this->yellow->system->get("contentDir"));
$mediaDirLength = strlenu($this->yellow->system->get("mediaDir"));
$systemDirLength = strlenu($this->yellow->system->get("systemDir"));
return substru($fileName, 0, $contentDirLength)==$this->yellow->system->get("contentDir") ||
substru($fileName, 0, $mediaDirLength)==$this->yellow->system->get("mediaDir") ||
substru($fileName, 0, $systemDirLength)==$this->yellow->system->get("systemDir");
$contentDirLength = strlenu($this->yellow->system->get("coreContentDir"));
$mediaDirLength = strlenu($this->yellow->system->get("coreMediaDir"));
$systemDirLength = strlenu($this->yellow->system->get("coreSystemDir"));
return substru($fileName, 0, $contentDirLength)==$this->yellow->system->get("coreContentDir") ||
substru($fileName, 0, $mediaDirLength)==$this->yellow->system->get("coreMediaDir") ||
substru($fileName, 0, $systemDirLength)==$this->yellow->system->get("coreSystemDir");
}
// Check if content file
public function isContentFile($fileName) {
$contentDirLength = strlenu($this->yellow->system->get("contentDir"));
return substru($fileName, 0, $contentDirLength)==$this->yellow->system->get("contentDir");
$contentDirLength = strlenu($this->yellow->system->get("coreContentDir"));
return substru($fileName, 0, $contentDirLength)==$this->yellow->system->get("coreContentDir");
}
// Check if media file
public function isMediaFile($fileName) {
$mediaDirLength = strlenu($this->yellow->system->get("mediaDir"));
return substru($fileName, 0, $mediaDirLength)==$this->yellow->system->get("mediaDir");
$mediaDirLength = strlenu($this->yellow->system->get("coreMediaDir"));
return substru($fileName, 0, $mediaDirLength)==$this->yellow->system->get("coreMediaDir");
}
// Check if system file
public function isSystemFile($fileName) {
$systemDirLength = strlenu($this->yellow->system->get("systemDir"));
return substru($fileName, 0, $systemDirLength)==$this->yellow->system->get("systemDir");
$systemDirLength = strlenu($this->yellow->system->get("coreSystemDir"));
return substru($fileName, 0, $systemDirLength)==$this->yellow->system->get("coreSystemDir");
}
}
@ -2945,6 +2948,22 @@ class YellowExtensions {
foreach ($this->extensions as $key=>$value) {
if (method_exists($this->extensions[$key]["obj"], "onLoad")) $this->extensions[$key]["obj"]->onLoad($this->yellow);
}
$this->yellow->system->set("mediaLocation", "/media/"); //TODO: remove later, for backwards compatibility
$this->yellow->system->set("downloadLocation", "/media/downloads/");
$this->yellow->system->set("imageLocation", "/media/images/");
$this->yellow->system->set("extensionLocation", "/media/extensions/");
$this->yellow->system->set("resourceLocation", "/media/resources/");
$this->yellow->system->set("mediaDir", "media/");
$this->yellow->system->set("downloadDir", "media/downloads/");
$this->yellow->system->set("imageDir", "media/images/");
$this->yellow->system->set("systemDir", "system/");
$this->yellow->system->set("extensionDir", "system/extensions/");
$this->yellow->system->set("layoutDir", "system/layouts/");
$this->yellow->system->set("resourceDir", "system/resources/");
$this->yellow->system->set("settingDir", "system/settings/");
$this->yellow->system->set("trashDir", "system/trash/");
$this->yellow->system->set("contentDir", "content/");
$this->yellow->system->set("contentPagination", "page");
}
// Register extension

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowEdit {
const VERSION = "0.8.12";
const VERSION = "0.8.13";
const TYPE = "feature";
public $yellow; //access to API
public $response; //web response
@ -33,16 +33,16 @@ class YellowEdit {
$this->yellow->system->setDefault("editLoginSessionTimeout", "2592000");
$this->yellow->system->setDefault("editLoginRestriction", "0");
$this->yellow->system->setDefault("editBruteForceProtection", "25");
$this->users->load($this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile"));
$this->users->load($this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile"));
}
// Handle request
public function onRequest($scheme, $address, $base, $location, $fileName) {
$statusCode = 0;
if ($this->checkRequest($location)) {
$scheme = $this->yellow->system->get("serverScheme");
$address = $this->yellow->system->get("serverAddress");
$base = rtrim($this->yellow->system->get("serverBase").$this->yellow->system->get("editLocation"), "/");
$scheme = $this->yellow->system->get("coreServerScheme");
$address = $this->yellow->system->get("coreServerAddress");
$base = rtrim($this->yellow->system->get("coreServerBase").$this->yellow->system->get("editLocation"), "/");
list($scheme, $address, $base, $location, $fileName) = $this->yellow->getRequestInformation($scheme, $address, $base);
$this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName);
$statusCode = $this->processRequest($scheme, $address, $base, $location, $fileName);
@ -66,7 +66,7 @@ class YellowEdit {
$output = null;
if ($name=="header" && $this->response->isActive()) {
$this->response->processPageData($page);
$extensionLocation = $this->yellow->system->get("serverBase").$this->yellow->system->get("extensionLocation");
$extensionLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreExtensionLocation");
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" data-bundle=\"none\" href=\"{$extensionLocation}edit.css\" />\n";
$output .= "<script type=\"text/javascript\" data-bundle=\"none\" src=\"{$extensionLocation}edit.js\"></script>\n";
$output .= "<script type=\"text/javascript\">\n";
@ -98,7 +98,7 @@ class YellowEdit {
// Handle update
public function onUpdate($action) {
if ($action=="update") { //TODO: remove later, converts old format
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$fileData = $this->yellow->toolbox->readFile($fileNameUser);
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
@ -122,7 +122,7 @@ class YellowEdit {
}
}
if ($action=="update") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$fileData = $this->yellow->toolbox->readFile($fileNameUser);
$fileDataNew = "";
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
@ -179,7 +179,7 @@ class YellowEdit {
case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break;
}
if ($status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $this->yellow->system->get("language"),
@ -219,7 +219,7 @@ class YellowEdit {
case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break;
}
if ($status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$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),
@ -247,7 +247,7 @@ class YellowEdit {
case "unknown": echo "ERROR updating settings: Can't find email '$email'!\n"; break;
}
if ($status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$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, " ")."'");
@ -315,7 +315,7 @@ class YellowEdit {
// Process request for user login
public function processRequestLogin($scheme, $address, $base, $location, $fileName) {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("failed" => "0", "modified" => time());
if ($this->users->save($fileNameUser, $this->response->userEmail, $settings)) {
$home = $this->users->getUser($this->response->userEmail, "home");
@ -338,9 +338,9 @@ class YellowEdit {
$this->response->userEmail = "";
$this->response->destroyCookies($scheme, $address, $base);
$location = $this->yellow->lookup->normaliseUrl(
$this->yellow->system->get("serverScheme"),
$this->yellow->system->get("serverAddress"),
$this->yellow->system->get("serverBase"),
$this->yellow->system->get("coreServerScheme"),
$this->yellow->system->get("coreServerAddress"),
$this->yellow->system->get("coreServerBase"),
$location);
$statusCode = $this->yellow->sendStatus(302, $location);
return $statusCode;
@ -359,7 +359,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $this->yellow->lookup->findLanguageFromFile($fileName, $this->yellow->system->get("language")),
@ -394,7 +394,7 @@ class YellowEdit {
$email = $_REQUEST["email"];
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("status" => "unapproved", "failed" => "0", "modified" => 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'!");
@ -414,7 +414,7 @@ class YellowEdit {
$email = $_REQUEST["email"];
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("status" => "active", "failed" => "0", "modified" => 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'!");
@ -454,7 +454,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("hash" => $this->users->createHash($password), "failed" => "0", "modified" => 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'!");
@ -475,7 +475,7 @@ class YellowEdit {
$email = $_REQUEST["email"];
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("status" => "active", "failed" => "0", "modified" => 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'!");
@ -495,7 +495,7 @@ class YellowEdit {
if ($this->users->getUser($emailSource, "status")!="active") $this->response->status = "done";
}
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("status" => "unchanged", "failed" => "0", "modified" => 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'!");
@ -519,7 +519,7 @@ class YellowEdit {
if (!$this->users->isExisting($email) || empty($hash)) $this->response->status = "done";
}
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"status" => "active",
"pending" => "none",
@ -530,7 +530,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$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'!");
}
@ -566,7 +566,7 @@ class YellowEdit {
$email = $_REQUEST["email"];
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("status" => "removed", "failed" => "0", "modified" => 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'!");
@ -577,7 +577,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$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'!");
}
@ -603,7 +603,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@ -619,7 +619,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@ -636,7 +636,7 @@ class YellowEdit {
}
} else {
if ($this->response->status=="ok") {
$fileNameUser = $this->yellow->system->get("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array("name" => $name, "language" => $language, "failed" => "0", "modified" => 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'!");
@ -664,7 +664,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("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
$settings = array("sitename" => $sitename, "author" => $author, "email" => $email);
$this->response->status = $this->yellow->system->save($fileName, $settings) ? "done" : "error";
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileName'!");
@ -784,7 +784,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("trashDir"))) {
if ($this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
$statusCode = $this->yellow->sendStatus(303, $location);
} else {
@ -792,7 +792,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("trashDir"))) {
if ($this->yellow->toolbox->deleteDirectory(dirname($fileName), $this->yellow->system->get("coreTrashDir"))) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
$statusCode = $this->yellow->sendStatus(303, $location);
} else {
@ -905,7 +905,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$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")) {
@ -1184,9 +1184,9 @@ class YellowEditResponse {
$data["author"] = $this->yellow->system->get("author");
$data["email"] = $this->yellow->system->get("email");
}
$data["serverScheme"] = $this->yellow->system->get("serverScheme");
$data["serverAddress"] = $this->yellow->system->get("serverAddress");
$data["serverBase"] = $this->yellow->system->get("serverBase");
$data["serverScheme"] = $this->yellow->system->get("coreServerScheme");
$data["serverAddress"] = $this->yellow->system->get("coreServerAddress");
$data["serverBase"] = $this->yellow->system->get("coreServerBase");
$data["serverFileSizeMax"] = $this->yellow->toolbox->getNumberBytes(ini_get("upload_max_filesize"));
$data["serverVersion"] = "Datenstrom Yellow ".YellowCore::VERSION;
$data["serverExtensions"] = array();
@ -1302,7 +1302,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("contentSharedDir");
$location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDir");
$fileName = $this->yellow->lookup->findFileFromLocation($location, true).$this->yellow->system->get("editNewFile");
$fileName = strreplaceu("(.*)", $name, $fileName);
if (is_file($fileName)) break;
@ -1310,7 +1310,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("contentSharedDir");
$location = $this->yellow->content->getHomeLocation($page->location).$this->yellow->system->get("coreContentSharedDir");
$fileName = $this->yellow->lookup->findFileFromLocation($location, true).$this->yellow->system->get("editNewFile");
$fileName = strreplaceu("(.*)", $name, $fileName);
}
@ -1405,13 +1405,13 @@ class YellowEditResponse {
$path = $matches[1];
$text = $this->yellow->lookup->normaliseName($matches[2], true, true);
if (preg_match("/^[\d\-\_\.]*$/", $text)) $prefix = "";
$fileName = $path."/".$prefix.$text.$this->yellow->system->get("contentExtension");
$fileName = $path."/".$prefix.$text.$this->yellow->system->get("coreContentExtension");
} else {
preg_match("#^(.*)\/(.+?)$#", dirname($fileName), $matches);
$path = $matches[1];
$text = $this->yellow->lookup->normaliseName($matches[2], true, false);
if (preg_match("/^[\d\-\_\.]*$/", $text)) $prefix = "";
$fileName = $path."/".$prefix.$text."/".$this->yellow->system->get("contentDefaultFile");
$fileName = $path."/".$prefix.$text."/".$this->yellow->system->get("coreContentDefaultFile");
}
}
return $fileName;
@ -1440,16 +1440,16 @@ class YellowEditResponse {
$location = preg_replace("/@folder/i", $this->getFileNewFolder($pageLocation), $location);
$location = preg_replace("/@filename/i", strtoloweru($fileNameShort), $location);
if (!preg_match("/^\//", $location)) {
$location = $this->yellow->system->get("mediaLocation").$location;
$location = $this->yellow->system->get("coreMediaLocation").$location;
}
return $location;
}
// Return group for new file
public function getFileNewGroup($fileNameShort) {
$path = $this->yellow->system->get("mediaDir");
$path = $this->yellow->system->get("coreMediaDir");
$fileType = $this->yellow->toolbox->getFileType($fileNameShort);
$fileName = $this->yellow->system->get(preg_match("/(gif|jpg|png|svg)$/", $fileType) ? "imageDir" : "downloadDir").$fileNameShort;
$fileName = $this->yellow->system->get(preg_match("/(gif|jpg|png|svg)$/", $fileType) ? "coreImageDir" : "coreDownloadDir").$fileNameShort;
preg_match("#^$path(.+?)\/#", $fileName, $matches);
return strtoloweru($matches[1]);
}

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowImage {
const VERSION = "0.8.3";
const VERSION = "0.8.4";
const TYPE = "feature";
public $yellow; //access to API
public $graphicsLibrary; //graphics library support? (boolean)
@ -35,7 +35,7 @@ class YellowImage {
if (empty($alt)) $alt = $this->yellow->system->get("imageAlt");
if (empty($width)) $width = "100%";
if (empty($height)) $height = $width;
list($src, $width, $height) = $this->getImageInformation($this->yellow->system->get("imageDir").$name, $width, $height);
list($src, $width, $height) = $this->getImageInformation($this->yellow->system->get("coreImageDir").$name, $width, $height);
} else {
if (empty($alt)) $alt = $this->yellow->system->get("imageAlt");
$src = $this->yellow->lookup->normaliseUrl("", "", "", $name);
@ -101,12 +101,12 @@ class YellowImage {
// Return image info, create thumbnail on demand
public function getImageInformation($fileName, $widthOutput, $heightOutput) {
$fileNameShort = substru($fileName, strlenu($this->yellow->system->get("imageDir")));
$fileNameShort = substru($fileName, strlenu($this->yellow->system->get("coreImageDir")));
list($widthInput, $heightInput, $type) = $this->yellow->toolbox->detectImageInformation($fileName);
$widthOutput = $this->convertValueAndUnit($widthOutput, $widthInput);
$heightOutput = $this->convertValueAndUnit($heightOutput, $heightInput);
if (($widthInput==$widthOutput && $heightInput==$heightOutput) || $type=="svg") {
$src = $this->yellow->system->get("serverBase").$this->yellow->system->get("imageLocation").$fileNameShort;
$src = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreImageLocation").$fileNameShort;
$width = $widthOutput;
$height = $heightOutput;
} else {
@ -123,7 +123,7 @@ class YellowImage {
$this->yellow->page->error(500, "Can't write file '$fileNameOutput'!");
}
}
$src = $this->yellow->system->get("serverBase").$this->yellow->system->get("imageThumbnailLocation").$fileNameThumb;
$src = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("imageThumbnailLocation").$fileNameThumb;
list($width, $height) = $this->yellow->toolbox->detectImageInformation($fileNameOutput);
}
return array($src, $width, $height);

Binary file not shown.

Binary file not shown.

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowInstall {
const VERSION = "0.8.10";
const VERSION = "0.8.11";
const TYPE = "feature";
const PRIORITY = "1";
public $yellow; //access to API
@ -83,7 +83,7 @@ class YellowInstall {
// Update log
public function updateLog() {
$statusCode = 200;
$fileName = $this->yellow->system->get("extensionDir").$this->yellow->system->get("logFile");
$fileName = $this->yellow->system->get("coreExtensionDir").$this->yellow->system->get("coreLogFile");
if (!is_file($fileName)) {
$serverVersion = $this->yellow->toolbox->getServerVersion();
$this->yellow->log("info", "Datenstrom Yellow ".YellowCore::VERSION.", PHP ".PHP_VERSION.", $serverVersion");
@ -102,7 +102,7 @@ class YellowInstall {
// Update language
public function updateLanguage() {
$statusCode = 200;
$path = $this->yellow->system->get("extensionDir")."install-languages.zip";
$path = $this->yellow->system->get("coreExtensionDir")."install-languages.zip";
if (is_file($path) && $this->yellow->extensions->isExisting("update")) {
$zip = new ZipArchive();
if ($zip->open($path)===true) {
@ -143,7 +143,7 @@ class YellowInstall {
}
$zip->close();
if ($statusCode==200) {
$this->yellow->text->load($this->yellow->system->get("extensionDir").$this->yellow->system->get("languageFile"), "");
$this->yellow->text->load($this->yellow->system->get("coreExtensionDir").$this->yellow->system->get("coreLanguageFile"), "");
}
} else {
$statusCode = 500;
@ -156,7 +156,7 @@ class YellowInstall {
// Update extension
public function updateExtension($extension) {
$statusCode = 200;
$path = $this->yellow->system->get("extensionDir");
$path = $this->yellow->system->get("coreExtensionDir");
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)) {
@ -175,7 +175,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("settingDir").$this->yellow->system->get("editUserFile");
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
$settings = array(
"name" => $name,
"language" => $language,
@ -219,7 +219,7 @@ class YellowInstall {
// Update settings
public function updateSettings($settings) {
$statusCode = 200;
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
if (!$this->yellow->system->save($fileName, $settings)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@ -231,7 +231,7 @@ class YellowInstall {
public function removeFiles() {
$statusCode = 200;
if (function_exists("opcache_reset")) opcache_reset();
$path = $this->yellow->system->get("extensionDir");
$path = $this->yellow->system->get("coreExtensionDir");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
if (preg_match("/^install-(.*?)\./", basename($entry), $matches)) {
if (!$this->yellow->toolbox->deleteFile($entry)) {
@ -240,7 +240,7 @@ class YellowInstall {
}
}
}
$path = $this->yellow->system->get("extensionDir")."install.php";
$path = $this->yellow->system->get("coreExtensionDir")."install.php";
if ($statusCode==200 && !$this->yellow->toolbox->deleteFile($path)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$path'!");
@ -252,7 +252,7 @@ class YellowInstall {
// Check web server rewrite
public function checkServerRewrite($scheme, $address, $base, $location, $fileName) {
$curlHandle = curl_init();
$location = $this->yellow->system->get("resourceLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$location = $this->yellow->system->get("coreResourceLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::VERSION).")";
@ -266,7 +266,7 @@ class YellowInstall {
// Check web server read/write access
public function checkServerAccess() {
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
return $this->yellow->system->save($fileName, array());
}
@ -293,9 +293,9 @@ class YellowInstall {
if ($key=="password" || $key=="status") continue;
$data[$key] = trim($value);
}
$data["timezone"] = $this->yellow->toolbox->getTimezone();
$data["staticUrl"] = $this->yellow->toolbox->getServerUrl();
if ($this->yellow->isCommandLine()) $data["staticUrl"] = getenv("URL");
$data["coreStaticUrl"] = $this->yellow->toolbox->getServerUrl();
$data["coreServerTimezone"] = $this->yellow->toolbox->getTimezone();
if ($this->yellow->isCommandLine()) $data["coreStaticUrl"] = getenv("URL");
return $data;
}
@ -333,7 +333,7 @@ class YellowInstall {
// Return extensions for install page
public function getExtensionsInstall() {
$extensions = array("website");
$path = $this->yellow->system->get("extensionDir");
$path = $this->yellow->system->get("coreExtensionDir");
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]);
}

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowMarkdown {
const VERSION = "0.8.9";
const VERSION = "0.8.10";
const TYPE = "feature";
public $yellow; //access to API
@ -3962,7 +3962,7 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser {
public function _doImages_inline_callback($matches) {
$src = $matches[3]=="" ? $matches[4] : $matches[3];
if (!preg_match("/^\w+:/", $src)) {
$src = $this->yellow->system->get("serverBase").$this->yellow->system->get("imageLocation").$src;
$src = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreImageLocation").$src;
}
$alt = $matches[2];
$title = $matches[7]=="" ? $matches[2] : $matches[7];

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowMeta {
const VERSION = "0.8.8";
const VERSION = "0.8.9";
const TYPE = "feature";
public $yellow; //access to API
@ -17,7 +17,7 @@ class YellowMeta {
// Handle update
public function onUpdate($action) {
if ($action=="update") { //TODO: remove later, converts old settings
$path = $this->yellow->system->get("contentDir");
$path = $this->yellow->system->get("coreContentDir");
foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.md$/", true, false) as $entry) {
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
$fileDataNew = preg_replace("/SocialtagsImage:/i", "Image:", $fileDataNew);
@ -74,12 +74,12 @@ class YellowMeta {
$alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title");
}
if (!preg_match("/^\w+:/", $name)) {
$location = $name!="icon" ? $this->yellow->system->get("imageLocation").$name :
$this->yellow->system->get("resourceLocation").$page->get("theme")."-icon.png";
$location = $name!="icon" ? $this->yellow->system->get("coreImageLocation").$name :
$this->yellow->system->get("coreResourceLocation").$page->get("theme")."-icon.png";
$url = $this->yellow->lookup->normaliseUrl(
$this->yellow->system->get("serverScheme"),
$this->yellow->system->get("serverAddress"),
$this->yellow->system->get("serverBase"), $location);
$this->yellow->system->get("coreServerScheme"),
$this->yellow->system->get("coreServerAddress"),
$this->yellow->system->get("coreServerBase"), $location);
} else {
$url = $this->yellow->lookup->normaliseUrl("", "", "", $name);
}

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowStockholm {
const VERSION = "0.8.5";
const VERSION = "0.8.6";
const TYPE = "theme";
public $yellow; //access to API
@ -15,7 +15,7 @@ class YellowStockholm {
// Handle update
public function onUpdate($action) {
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
if ($action=="install") {
$this->yellow->system->save($fileName, array("theme" => "stockholm"));
} elseif ($action=="uninstall" && $this->yellow->system->get("theme")=="stockholm") {

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowUpdate {
const VERSION = "0.8.10";
const VERSION = "0.8.11";
const TYPE = "feature";
const PRIORITY = "2";
public $yellow; //access to API
@ -56,13 +56,36 @@ class YellowUpdate {
// Handle update
public function onUpdate($action) {
if ($action=="update") { //TODO: remove later, converts old core settings
if ($action=="update") { //TODO: remove later, converts old server settings and layout files
if ($this->yellow->system->isExisting("staticUrl")) {
$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");
$this->yellow->system->save($fileName, array("coreStaticUrl" => $coreStaticUrl, "coreServerUrl" => $coreServerUrl,
"coreServerTimezone" => $coreServerTimezone));
$path = $this->yellow->system->get("coreLayoutDir");
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);
$fileDataNew = str_replace("system->get(\"serverAddress\")", "system->get(\"coreServerAddress\")", $fileDataNew);
$fileDataNew = str_replace("system->get(\"serverBase\")", "system->get(\"coreServerBase\")", $fileDataNew);
$fileDataNew = str_replace("system->get(\"imageLocation\")", "system->get(\"coreImageLocation\")", $fileDataNew);
$fileDataNew = str_replace("system->get(\"extensionLocation\")", "system->get(\"coreExtensionLocation\")", $fileDataNew);
$fileDataNew = str_replace("system->get(\"resourceLocation\")", "system->get(\"coreResourceLocation\")", $fileDataNew);
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
$this->yellow->log("error", "Can't write file '$entry'!");
}
}
}
}
if ($action=="update") { //TODO: remove later, converts old core and status settings
if ($this->yellow->system->isExisting("safeMode")) {
$safeMode = $this->yellow->system->get("safeMode");
$multiLanguageMode = $this->yellow->system->get("multiLanguageMode");
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$this->yellow->system->save($fileName, array("coreSafeMode" => $safeMode, "coreMultiLanguageMode" => $multiLanguageMode));
$path = $this->yellow->system->get("contentDir");
$coreSafeMode = $this->yellow->system->get("safeMode");
$coreMultiLanguageMode = $this->yellow->system->get("multiLanguageMode");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
$this->yellow->system->save($fileName, array("coreSafeMode" => $coreSafeMode, "coreMultiLanguageMode" => $coreMultiLanguageMode));
$path = $this->yellow->system->get("coreContentDir");
foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.md$/", true, false) as $entry) {
$fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
$fileStatusUnlisted = false;
@ -97,7 +120,7 @@ class YellowUpdate {
if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($action);
}
}
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
$this->yellow->system->save($fileName, array("updateNotification" => "none"));
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileDataHeader = $fileDataSettings = $fileDataFooter = "";
@ -115,10 +138,10 @@ class YellowUpdate {
$fileDataFooter .= $line;
}
}
unset($settings["systemFile"]);
unset($settings["coreSystemFile"]);
foreach ($settings as $key=>$value) {
if ($key=="coreStaticUrl") $fileDataSettings .= "\n";
$fileDataSettings .= ucfirst($key).(strempty($value) ? ":\n" : ": $value\n");
if ($key=="updateNotification") $fileDataSettings .= "\n";
}
if (!empty($fileDataHeader)) $fileDataHeader .= "\n";
if (!empty($fileDataFooter)) $fileDataSettings .= "\n";
@ -135,8 +158,8 @@ class YellowUpdate {
$statusCode = 0;
list($command, $path) = $args;
if ($path=="all") {
$path = $this->yellow->system->get("extensionDir");
$regex = "/^.*\\".$this->yellow->system->get("downloadExtension")."$/";
$path = $this->yellow->system->get("coreExtensionDir");
$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;
}
@ -224,7 +247,7 @@ class YellowUpdate {
if ($updateNotification=="none") $updateNotification = "";
if (!empty($updateNotification)) $updateNotification .= ",";
$updateNotification .= "$extension/$action";
$fileName = $this->yellow->system->get("settingDir").$this->yellow->system->get("systemFile");
$fileName = $this->yellow->system->get("coreSettingDir").$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'!");
@ -354,8 +377,8 @@ class YellowUpdate {
// Download extensions
public function downloadExtensions($data) {
$statusCode = 200;
$path = $this->yellow->system->get("extensionDir");
$fileExtension = $this->yellow->system->get("downloadExtension");
$path = $this->yellow->system->get("coreExtensionDir");
$fileExtension = $this->yellow->system->get("coreDownloadExtension");
foreach ($data as $key=>$value) {
$fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
list($version, $url) = explode(",", $value);
@ -382,7 +405,7 @@ class YellowUpdate {
public function updateExtensions($action, $force = false) {
$statusCode = 200;
if (function_exists("opcache_reset")) opcache_reset();
$path = $this->yellow->system->get("extensionDir");
$path = $this->yellow->system->get("coreExtensionDir");
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)) {
@ -456,7 +479,7 @@ class YellowUpdate {
}
}
if ($update) {
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("trashDir")) ||
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir")) ||
!$this->yellow->toolbox->createFile($fileName, $fileData) ||
!$this->yellow->toolbox->modifyFile($fileName, $modified)) {
$statusCode = 500;
@ -464,7 +487,7 @@ class YellowUpdate {
}
}
if ($delete) {
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("trashDir"))) {
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
}
@ -483,8 +506,8 @@ class YellowUpdate {
$statusCode = 200;
if ($this->yellow->system->get("coreMultiLanguageMode") && !$this->yellow->extensions->isExisting($extension)) {
$pathsSource = $pathsTarget = array();
$pathBase = $this->yellow->system->get("contentDir");
$fileExtension = $this->yellow->system->get("contentExtension");
$pathBase = $this->yellow->system->get("coreContentDir");
$fileExtension = $this->yellow->system->get("coreContentExtension");
$fileRegex = "/^.*\\".$fileExtension."$/";
foreach ($this->yellow->toolbox->getDirectoryEntries($pathBase, "/.*/", true, true) as $entry) {
if (count($this->yellow->toolbox->getDirectoryEntries($entry, $fileRegex, false, false))) {
@ -541,7 +564,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("trashDir"))) {
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDir"))) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
}
@ -653,7 +676,7 @@ class YellowUpdate {
// Check if extension pending
public function isExtensionPending() {
$path = $this->yellow->system->get("extensionDir");
$path = $this->yellow->system->get("coreExtensionDir");
return count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", false, false))>0;
}
}

2
system/layouts/header.html Normal file → Executable file
View file

@ -7,7 +7,7 @@
<meta name="author" content="<?php echo $this->yellow->page->getHtml("author") ?>" />
<meta name="generator" content="Datenstrom Yellow" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php $resourceLocation = $this->yellow->system->get("serverBase").$this->yellow->system->get("resourceLocation") ?>
<?php $resourceLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreResourceLocation") ?>
<link rel="icon" type="image/png" href="<?php echo $resourceLocation.$this->yellow->page->getHtml("theme")."-icon.png" ?>" />
<?php echo $this->yellow->page->getExtra("header") ?>
</head>

View file

@ -3,7 +3,6 @@
Sitename: Datenstrom Yellow
Author: Datenstrom
Email: webmaster
Timezone: UTC
Language: en
Layout: default
Theme: stockholm
@ -13,38 +12,40 @@ Navigation: navigation
Header: header
Footer: footer
Sidebar: sidebar
StaticUrl:
StaticDefaultFile: index.html
StaticErrorFile: 404.html
StaticDir: public/
CacheDir: cache/
MediaLocation: /media/
DownloadLocation: /media/downloads/
ImageLocation: /media/images/
ExtensionLocation: /media/extensions/
ResourceLocation: /media/resources/
MediaDir: media/
DownloadDir: media/downloads/
ImageDir: media/images/
SystemDir: system/
ExtensionDir: system/extensions/
LayoutDir: system/layouts/
ResourceDir: system/resources/
SettingDir: system/settings/
TrashDir: system/trash/
ContentDir: content/
ContentRootDir: default/
ContentHomeDir: home/
ContentSharedDir: shared/
ContentPagination: page
ContentDefaultFile: page.md
ContentExtension: .md
DownloadExtension: .download
TextFile: text.ini
LogFile: yellow.log
CoreStaticUrl:
CoreStaticDefaultFile: index.html
CoreStaticErrorFile: 404.html
CoreStaticDir: public/
CoreCacheDir: cache/
CoreServerUrl: auto
CoreServerTimezone: UTC
CoreSafeMode: 0
CoreMultiLanguageMode: 0
ServerUrl:
CoreMediaLocation: /media/
CoreDownloadLocation: /media/downloads/
CoreImageLocation: /media/images/
CoreExtensionLocation: /media/extensions/
CoreResourceLocation: /media/resources/
CoreMediaDir: media/
CoreDownloadDir: media/downloads/
CoreImageDir: media/images/
CoreSystemDir: system/
CoreExtensionDir: system/extensions/
CoreLayoutDir: system/layouts/
CoreResourceDir: system/resources/
CoreSettingDir: system/settings/
CoreTrashDir: system/trash/
CoreContentDir: content/
CoreContentRootDir: default/
CoreContentHomeDir: home/
CoreContentSharedDir: shared/
CoreContentPagination: page
CoreContentDefaultFile: page.md
CoreContentExtension: .md
CoreDownloadExtension: .download
CoreTextFile: text.ini
CoreLogFile: yellow.log
UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions
UpdateExtensionFile: extension.ini
UpdateVersionFile: version.ini