commit b27d37793524c028c1efe7f426293d3665dbc23f
parent 9b719d5c0127004247ebf1474a68c5272de9fe60
Author: markseu <mark2011@mayberg.se>
Date: Thu, 12 Dec 2019 14:51:53 +0100
Updated core, better page visibility
Diffstat:
6 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/system/extensions/command.php b/system/extensions/command.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCommand {
- const VERSION = "0.8.6";
+ const VERSION = "0.8.7";
const TYPE = "feature";
const PRIORITY = "3";
public $yellow; //access to API
@@ -578,7 +578,7 @@ class YellowCommand {
array_push($locations, $page->location);
}
}
- if (!$this->yellow->content->find("/") && $this->yellow->system->get("multiLanguageMode")) array_unshift($locations, "/");
+ if (!$this->yellow->content->find("/") && $this->yellow->system->get("coreMultiLanguageMode")) array_unshift($locations, "/");
return $locations;
}
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.6";
+ const VERSION = "0.8.7";
const TYPE = "feature";
public $page; //current page
public $content; //content files from file system
@@ -32,6 +32,7 @@ class YellowCore {
$this->system->setDefault("layout", "default");
$this->system->setDefault("theme", "default");
$this->system->setDefault("parser", "markdown");
+ $this->system->setDefault("status", "public");
$this->system->setDefault("navigation", "navigation");
$this->system->setDefault("header", "header");
$this->system->setDefault("footer", "footer");
@@ -66,8 +67,8 @@ class YellowCore {
$this->system->setDefault("systemFile", "system.ini");
$this->system->setDefault("textFile", "text.ini");
$this->system->setDefault("logFile", "yellow.log");
- $this->system->setDefault("safeMode", "0");
- $this->system->setDefault("multiLanguageMode", "0");
+ $this->system->setDefault("coreSafeMode", "0");
+ $this->system->setDefault("coreMultiLanguageMode", "0");
$this->system->setDefault("serverUrl", "");
}
@@ -415,9 +416,9 @@ class YellowPage {
$this->rawData = $rawData;
$this->parser = null;
$this->parserData = "";
- $this->safeMode = intval($this->yellow->system->get("safeMode"));
+ $this->safeMode = intval($this->yellow->system->get("coreSafeMode"));
$this->available = $this->yellow->lookup->isAvailableLocation($this->location, $this->fileName);
- $this->visible = $this->yellow->lookup->isVisibleLocation($this->location, $this->fileName);
+ $this->visible = true;
$this->active = $this->yellow->lookup->isActiveLocation($this->location, $this->yellow->page->location);
$this->cacheable = $cacheable;
$this->lastModified = 0;
@@ -441,7 +442,7 @@ class YellowPage {
$this->set("title", $this->yellow->toolbox->createTextTitle($this->location));
$this->set("language", $this->yellow->lookup->findLanguageFromFile($this->fileName, $this->yellow->system->get("language")));
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
- $this->parseMetaRaw(array("sitename", "author", "layout", "theme", "parser", "navigation", "header", "footer", "sidebar"));
+ $this->parseMetaRaw(array("sitename", "author", "layout", "theme", "parser", "status", "navigation", "header", "footer", "sidebar"));
$titleHeader = ($this->location==$this->yellow->content->getHomeLocation($this->location)) ?
$this->get("sitename") : $this->get("title")." - ".$this->get("sitename");
if (!$this->isExisting("titleContent")) $this->set("titleContent", $this->get("title"));
@@ -449,7 +450,6 @@ class YellowPage {
if (!$this->isExisting("titleHeader")) $this->set("titleHeader", $titleHeader);
if ($this->get("status")=="unlisted") $this->visible = false;
if ($this->get("status")=="shared") $this->available = false;
- if ($this->get("status")=="hidden") $this->available = false; //TODO: remove later, for backwards compatibility
$this->set("pageRead", $this->yellow->lookup->normaliseUrl(
$this->yellow->system->get("serverScheme"),
$this->yellow->system->get("serverAddress"),
@@ -1311,7 +1311,7 @@ class YellowContent {
// Return root location
public function getRootLocation($location) {
$rootLocation = "root/";
- if ($this->yellow->system->get("multiLanguageMode")) {
+ if ($this->yellow->system->get("coreMultiLanguageMode")) {
foreach ($this->scanLocation("") as $page) {
$token = substru($page->location, 4);
if ($token!="/" && substru($location, 0, strlenu($token))==$token) {
@@ -1751,7 +1751,7 @@ class YellowLookup {
$path = $this->yellow->system->get("contentDir");
$pathRoot = $this->yellow->system->get("contentRootDir");
$pathHome = $this->yellow->system->get("contentHomeDir");
- if (!$this->yellow->system->get("multiLanguageMode")) $pathRoot = "";
+ if (!$this->yellow->system->get("coreMultiLanguageMode")) $pathRoot = "";
if (!empty($pathRoot)) {
$token = $root = rtrim($pathRoot, "/");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) {
@@ -2096,7 +2096,7 @@ class YellowLookup {
if ($this->isFileLocation($location)) {
$redirect = is_dir($this->findFileFromLocation("$location/", true));
} elseif ($location=="/") {
- $redirect = $this->yellow->system->get("multiLanguageMode");
+ $redirect = $this->yellow->system->get("coreMultiLanguageMode");
}
return $redirect;
}
@@ -2122,25 +2122,6 @@ class YellowLookup {
return $available;
}
- // Check if location is visible
- public function isVisibleLocation($location, $fileName) {
- $visible = true;
- $pathBase = $this->yellow->system->get("contentDir");
- if (substru($fileName, 0, strlenu($pathBase))==$pathBase) {
- $fileName = substru($fileName, strlenu($pathBase));
- $tokens = explode("/", $fileName);
- for ($i=0; $i<count($tokens)-1; ++$i) {
- if (!preg_match("/^[\d\-\_\.]+(.*)$/", $tokens[$i])) {
- $visible = false;
- break;
- }
- }
- } else {
- $visible = false;
- }
- return $visible;
- }
-
// Check if location is within current HTTP request
public function isActiveLocation($location, $currentLocation) {
if ($this->isFileLocation($location)) {
diff --git a/system/extensions/image.php b/system/extensions/image.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowImage {
- const VERSION = "0.8.2";
+ const VERSION = "0.8.3";
const TYPE = "feature";
public $yellow; //access to API
public $graphicsLibrary; //graphics library support? (boolean)
@@ -66,7 +66,7 @@ class YellowImage {
$file->error(500, "Can't write file '$fileName'!");
}
}
- if ($this->yellow->system->get("safeMode") && $fileType=="svg") {
+ if ($this->yellow->system->get("coreSafeMode") && $fileType=="svg") {
$output = $this->sanitiseXmlData($this->yellow->toolbox->readFile($fileName));
if (empty($output) || !$this->yellow->toolbox->createFile($fileName, $output)) {
$file->error(500, "Can't write file '$fileName'!");
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.9";
+ const VERSION = "0.8.10";
const TYPE = "feature";
const PRIORITY = "1";
public $yellow; //access to API
@@ -290,6 +290,7 @@ class YellowInstall {
$data = array();
foreach ($_REQUEST as $key=>$value) {
if (!$this->yellow->system->isExisting($key)) continue;
+ if ($key=="password" || $key=="status") continue;
$data[$key] = trim($value);
}
$data["timezone"] = $this->yellow->toolbox->getTimezone();
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.9";
+ const VERSION = "0.8.10";
const TYPE = "feature";
const PRIORITY = "2";
public $yellow; //access to API
@@ -56,6 +56,38 @@ class YellowUpdate {
// Handle update
public function onUpdate($action) {
+ if ($action=="update") { //TODO: remove later, converts old core 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");
+ foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.md$/", true, false) as $entry) {
+ $fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
+ $fileStatusUnlisted = false;
+ $tokens = explode("/", substru($entry, strlenu($path)));
+ for ($i=0; $i<count($tokens)-1; ++$i) {
+ if (!preg_match("/^[\d\-\_\.]+(.*)$/", $tokens[$i]) && $tokens[$i]!="shared") {
+ $fileStatusUnlisted = true;
+ break;
+ }
+ }
+ if ($fileStatusUnlisted && empty($this->yellow->toolbox->getMetaData($fileDataNew, "status"))) {
+ $fileDataNew = $this->yellow->toolbox->setMetaData($fileDataNew, "status", "unlisted");
+ }
+ $fileDataNew = preg_replace("/Status: hidden/i", "Status: shared", $fileDataNew);
+ if ($fileData!=$fileDataNew) {
+ $modified = $this->yellow->toolbox->getFileModified($entry);
+ if (!$this->yellow->toolbox->deleteFile($entry) ||
+ !$this->yellow->toolbox->createFile($entry, $fileDataNew) ||
+ !$this->yellow->toolbox->modifyFile($entry, $modified)) {
+ $this->yellow->log("error", "Can't write file '$entry'!");
+ }
+ }
+ }
+ }
+ }
if ($action=="startup") {
if ($this->yellow->system->get("updateNotification")!="none") {
foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) {
@@ -449,7 +481,7 @@ class YellowUpdate {
// Update content for multi language mode
public function updateContentMultiLanguage($extension) {
$statusCode = 200;
- if ($this->yellow->system->get("multiLanguageMode") && !$this->yellow->extensions->isExisting($extension)) {
+ 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");
diff --git a/system/settings/system.ini b/system/settings/system.ini
@@ -8,6 +8,7 @@ Language: en
Layout: default
Theme: stockholm
Parser: markdown
+Status: public
Navigation: navigation
Header: header
Footer: footer
@@ -41,8 +42,8 @@ ContentExtension: .md
DownloadExtension: .download
TextFile: text.ini
LogFile: yellow.log
-SafeMode: 0
-MultiLanguageMode: 0
+CoreSafeMode: 0
+CoreMultiLanguageMode: 0
ServerUrl:
UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions
UpdateExtensionFile: extension.ini