Updated layout files, switched to self contained themes
This commit is contained in:
parent
b8f2ea60c5
commit
42b00f555e
15 changed files with 126 additions and 140 deletions
5
content/shared/page-error-404.md
Normal file
5
content/shared/page-error-404.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
Title: File not found
|
||||
Layout: error
|
||||
---
|
||||
The requested file was not found. Oh no...
|
|
@ -4,7 +4,7 @@
|
|||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
class YellowCore {
|
||||
const VERSION = "0.8.9";
|
||||
const VERSION = "0.8.10";
|
||||
const TYPE = "feature";
|
||||
public $page; //current page
|
||||
public $content; //content files from file system
|
||||
|
@ -32,10 +32,6 @@ class YellowCore {
|
|||
$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");
|
||||
$this->system->setDefault("sidebar", "sidebar");
|
||||
$this->system->setDefault("coreStaticUrl", "");
|
||||
$this->system->setDefault("coreStaticDefaultFile", "index.html");
|
||||
$this->system->setDefault("coreStaticErrorFile", "404.html");
|
||||
|
@ -64,6 +60,7 @@ class YellowCore {
|
|||
$this->system->setDefault("coreContentHomeDir", "home/");
|
||||
$this->system->setDefault("coreContentSharedDir", "shared/");
|
||||
$this->system->setDefault("coreContentDefaultFile", "page.md");
|
||||
$this->system->setDefault("coreContentErrorFile", "page-error-(.*).md");
|
||||
$this->system->setDefault("coreContentExtension", ".md");
|
||||
$this->system->setDefault("coreDownloadExtension", ".download");
|
||||
$this->system->setDefault("coreSystemFile", "system.ini");
|
||||
|
@ -169,13 +166,15 @@ class YellowCore {
|
|||
// Read page
|
||||
public function readPage($scheme, $address, $base, $location, $fileName, $cacheable, $statusCode, $pageError) {
|
||||
if ($statusCode>=400) {
|
||||
$language = $this->lookup->findLanguageFromFile($fileName, $this->system->get("language"));
|
||||
if ($this->text->isExisting("error${statusCode}Title", $language)) {
|
||||
$rawData = "---\nTitle:".$this->text->getText("error${statusCode}Title", $language)."\n";
|
||||
$rawData .= "Layout:error\nSidebar:none\nLanguage:$language\n---\n".$this->text->getText("error${statusCode}Text", $language);
|
||||
$locationError = $this->content->getHomeLocation($page->location).$this->system->get("coreContentSharedDir");
|
||||
$fileNameError = $this->lookup->findFileFromLocation($locationError, true).$this->system->get("coreContentErrorFile");
|
||||
$fileNameError = strreplaceu("(.*)", $statusCode, $fileNameError);
|
||||
if (is_file($fileNameError)) {
|
||||
$rawData = $this->toolbox->readFile($fileNameError);
|
||||
} else {
|
||||
$rawData = "---\nTitle:".$this->toolbox->getHttpStatusFormatted($statusCode, true)."\n";
|
||||
$rawData .= "Layout:error\nSidebar:none\nLanguage:en\n---\n[yellow error]";
|
||||
$language = $this->lookup->findLanguageFromFile($fileName, $this->system->get("language"));
|
||||
$rawData = "---\nTitle:".$this->text->getText("coreError${statusCode}Title", $language)."\n";
|
||||
$rawData .= "Layout:error\n---\n".$this->text->getText("coreError${statusCode}Text", $language);
|
||||
}
|
||||
$cacheable = false;
|
||||
} else {
|
||||
|
@ -444,7 +443,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", "status", "navigation", "header", "footer", "sidebar"));
|
||||
$this->parseMetaRaw(array("sitename", "author", "layout", "theme", "parser", "status"));
|
||||
$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"));
|
||||
|
@ -479,6 +478,10 @@ class YellowPage {
|
|||
$value = $this->yellow->system->get($key);
|
||||
if (!empty($key) && !strempty($value)) $this->set($key, $value);
|
||||
}
|
||||
$this->set("navigation", "navigation"); //TODO: remove later, for backwards compatibility
|
||||
$this->set("header", "header");
|
||||
$this->set("sidebar", "sidebar");
|
||||
$this->set("footer", "footer");
|
||||
if (preg_match("/^(\xEF\xBB\xBF)?\-\-\-[\r\n]+(.+?)\-\-\-[\r\n]+/s", $this->rawData, $parts)) {
|
||||
$this->metaDataOffsetBytes = strlenb($parts[0]);
|
||||
foreach (preg_split("/[\r\n]+/", $parts[2]) as $line) {
|
||||
|
@ -514,7 +517,8 @@ class YellowPage {
|
|||
$this->parserData = preg_replace("/\[yellow error\]/i", $this->get("pageError"), $this->parserData);
|
||||
}
|
||||
if (!$this->isExisting("description")) {
|
||||
$this->set("description", $this->yellow->toolbox->createTextDescription($this->parserData, 150));
|
||||
$description = $this->yellow->toolbox->createTextDescription($this->parserData, 150);
|
||||
$this->set("description", !empty($description) ? $description : $this->get("title"));
|
||||
}
|
||||
if (defined("DEBUG") && DEBUG>=3) echo "YellowPage::parseContent location:".$this->location."<br/>\n";
|
||||
}
|
||||
|
@ -651,7 +655,7 @@ class YellowPage {
|
|||
if (!empty($format)) {
|
||||
$format = $this->yellow->text->get($format);
|
||||
} else {
|
||||
$format = $this->yellow->text->get("dateFormatMedium");
|
||||
$format = $this->yellow->text->get("coreDateFormatMedium");
|
||||
}
|
||||
return $this->yellow->text->getDateFormatted(strtotime($this->get($key)), $format);
|
||||
}
|
||||
|
@ -666,7 +670,7 @@ class YellowPage {
|
|||
if (!empty($format)) {
|
||||
$format = $this->yellow->text->get($format);
|
||||
} else {
|
||||
$format = $this->yellow->text->get("dateFormatMedium");
|
||||
$format = $this->yellow->text->get("coreDateFormatMedium");
|
||||
}
|
||||
return $this->yellow->text->getDateRelative(strtotime($this->get($key)), $format, $daysLimit);
|
||||
}
|
||||
|
@ -1269,6 +1273,7 @@ class YellowContent {
|
|||
$location = $this->getHomeLocation($this->yellow->page->location).$this->yellow->system->get("coreContentSharedDir").$name;
|
||||
$page = $this->find($location);
|
||||
}
|
||||
if ($page) $page->setPage("main", $this->yellow->page);
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
@ -1649,8 +1654,8 @@ class YellowText {
|
|||
|
||||
// Return human readable date, custom date format
|
||||
public function getDateFormatted($timestamp, $format) {
|
||||
$dateMonths = preg_split("/\s*,\s*/", $this->get("dateMonths"));
|
||||
$dateWeekdays = preg_split("/\s*,\s*/", $this->get("dateWeekdays"));
|
||||
$dateMonths = preg_split("/\s*,\s*/", $this->get("coreDateMonths"));
|
||||
$dateWeekdays = preg_split("/\s*,\s*/", $this->get("coreDateWeekdays"));
|
||||
$month = $dateMonths[date("n", $timestamp) - 1];
|
||||
$weekday = $dateWeekdays[date("N", $timestamp) - 1];
|
||||
$timeZone = $this->yellow->system->get("coreServerTimezone");
|
||||
|
@ -1669,7 +1674,7 @@ class YellowText {
|
|||
public function getDateRelative($timestamp, $format, $daysLimit) {
|
||||
$timeDifference = time() - $timestamp;
|
||||
$days = abs(intval($timeDifference / 86400));
|
||||
$tokens = preg_split("/\s*,\s*/", $this->get($timeDifference>=0 ? "datePast" : "dateFuture"));
|
||||
$tokens = preg_split("/\s*,\s*/", $this->get($timeDifference>=0 ? "coreDatePast" : "coreDateFuture"));
|
||||
if ($days<=$daysLimit || $daysLimit==0) {
|
||||
if ($days==0) {
|
||||
$output = $tokens[0];
|
||||
|
@ -1709,11 +1714,11 @@ class YellowText {
|
|||
// Normalise date into known format
|
||||
public function normaliseDate($text) {
|
||||
if (preg_match("/^\d+\-\d+$/", $text)) {
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("dateFormatShort"));
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("coreDateFormatShort"));
|
||||
} elseif (preg_match("/^\d+\-\d+\-\d+$/", $text)) {
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("dateFormatMedium"));
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("coreDateFormatMedium"));
|
||||
} elseif (preg_match("/^\d+\-\d+\-\d+ \d+\:\d+$/", $text)) {
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("dateFormatLong"));
|
||||
$output = $this->getDateFormatted(strtotime($text), $this->get("coreDateFormatLong"));
|
||||
} else {
|
||||
$output = $text;
|
||||
}
|
||||
|
|
|
@ -595,8 +595,7 @@ yellow.edit = {
|
|||
}
|
||||
if (status=="preview" && !elementText.readOnly) this.showPreview(elementText, elementPreview);
|
||||
if (status=="save" && !elementText.readOnly && this.paneAction!="delete") this.processSubmit("action:"+this.paneAction);
|
||||
if (status=="help") window.open(this.getText("HelpUrl", "yellow"), "_blank");
|
||||
if (status=="markdown") window.open(this.getText("MarkdownUrl", "yellow"), "_blank");
|
||||
if (status=="help") window.open(this.getText("YellowHelpUrl"), "_blank");
|
||||
if (this.isExpandable(status)) {
|
||||
this.showPopup("yellow-popup-"+status, status);
|
||||
} else {
|
||||
|
@ -664,7 +663,7 @@ yellow.edit = {
|
|||
// Process help
|
||||
processHelp: function() {
|
||||
this.hidePane(this.paneId);
|
||||
window.open(this.getText("HelpUrl", "yellow"), "_self");
|
||||
window.open(this.getText("YellowHelpUrl"), "_self");
|
||||
},
|
||||
|
||||
// Create popup
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
class YellowEdit {
|
||||
const VERSION = "0.8.17";
|
||||
const VERSION = "0.8.18";
|
||||
const TYPE = "feature";
|
||||
public $yellow; //access to API
|
||||
public $response; //web response
|
||||
|
@ -108,7 +108,7 @@ class YellowEdit {
|
|||
list($hash, $name, $language, $status, $pending, $stamp, $timestamp, $failed, $group, $home) = explode(",", $matches[2]);
|
||||
$access = "create, edit, delete, upload".($group=="administrator" ? ", system, update" : "");
|
||||
$modified = date("Y-m-d H:i:s", $timestamp);
|
||||
$fileDataNew .= "Email: $matches[1]\nName: $name\nLanguage: $language\nHome: $home\nAccess: $access\nStatus: $status\nPending: $pending\nHash: $hash\nStamp: $stamp\nFailed: $failed\nModified: $modified\n\n";
|
||||
$fileDataNew .= "Email: $matches[1]\nName: $name\nLanguage: $language\nHome: $home\nAccess: $access\nHash: $hash\nStamp: $stamp\nPending: $pending\nFailed: $failed\nModified: $modified\nStatus: $status\n\n";
|
||||
} else {
|
||||
$fileDataNew .= $line;
|
||||
}
|
||||
|
@ -182,12 +182,12 @@ class YellowEdit {
|
|||
"language" => $this->yellow->system->get("language"),
|
||||
"home" => $this->yellow->system->get("editUserHome"),
|
||||
"access" => $this->yellow->system->get("editUserAccess"),
|
||||
"status" => "active",
|
||||
"pending" => "none",
|
||||
"hash" => $this->users->createHash($password),
|
||||
"stamp" => $this->users->createStamp(),
|
||||
"pending" => "none",
|
||||
"failed" => "0",
|
||||
"modified" => date("Y-m-d H:i:s", time()));
|
||||
"modified" => date("Y-m-d H:i:s", time()),
|
||||
"status" => "active");
|
||||
$status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($status=="error") echo "ERROR updating settings: Can't write file '$fileNameUser'!\n";
|
||||
$this->yellow->log($status=="ok" ? "info" : "error", "Add user '".strtok($name, " ")."'");
|
||||
|
@ -362,12 +362,12 @@ class YellowEdit {
|
|||
"language" => $this->yellow->lookup->findLanguageFromFile($fileName, $this->yellow->system->get("language")),
|
||||
"home" => $this->yellow->system->get("editUserHome"),
|
||||
"access" => $this->yellow->system->get("editUserAccess"),
|
||||
"status" => "unconfirmed",
|
||||
"pending" => "none",
|
||||
"hash" => $this->users->createHash($password),
|
||||
"stamp" => $this->users->createStamp(),
|
||||
"pending" => "none",
|
||||
"failed" => "0",
|
||||
"modified" => date("Y-m-d H:i:s", time()));
|
||||
"modified" => date("Y-m-d H:i:s", time()),
|
||||
"status" => "unconfirmed");
|
||||
$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'!");
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ class YellowEdit {
|
|||
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
|
||||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array("status" => "unapproved", "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
|
||||
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unapproved");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ class YellowEdit {
|
|||
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
|
||||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array("status" => "active", "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
|
||||
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
$this->yellow->log($this->response->status=="ok" ? "info" : "error", "Add user '".strtok($this->users->getUser($email, "name"), " ")."'");
|
||||
|
@ -473,7 +473,7 @@ class YellowEdit {
|
|||
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
|
||||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array("status" => "active", "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
|
||||
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "done" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ class YellowEdit {
|
|||
}
|
||||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array("status" => "unchanged", "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
|
||||
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unchanged");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
}
|
||||
|
@ -518,11 +518,11 @@ class YellowEdit {
|
|||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array(
|
||||
"status" => "active",
|
||||
"pending" => "none",
|
||||
"hash" => $hash,
|
||||
"pending" => "none",
|
||||
"failed" => "0",
|
||||
"modified" => date("Y-m-d H:i:s", time()));
|
||||
"modified" => date("Y-m-d H:i:s", time()),
|
||||
"status" => "active");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ class YellowEdit {
|
|||
$this->response->status = $this->getUserStatus($email, $_REQUEST["action"]);
|
||||
if ($this->response->status=="ok") {
|
||||
$fileNameUser = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("editUserFile");
|
||||
$settings = array("status" => "removed", "failed" => "0", "modified" => date("Y-m-d H:i:s", time()));
|
||||
$settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "removed");
|
||||
$this->response->status = $this->users->save($fileNameUser, $email, $settings) ? "ok" : "error";
|
||||
if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
$this->yellow->log($this->response->status=="ok" ? "info" : "error", "Remove user '".strtok($this->users->getUser($email, "name"), " ")."'");
|
||||
|
@ -606,12 +606,12 @@ class YellowEdit {
|
|||
"language" => $language,
|
||||
"home" => $this->users->getUser($emailSource, "home"),
|
||||
"access" => $this->users->getUser($emailSource, "access"),
|
||||
"status" => "unverified",
|
||||
"pending" => $emailSource,
|
||||
"hash" => $this->users->createHash("none"),
|
||||
"stamp" => $this->users->createStamp(),
|
||||
"pending" => $emailSource,
|
||||
"failed" => "0",
|
||||
"modified" => date("Y-m-d H:i:s", time()));
|
||||
"modified" => date("Y-m-d H:i:s", time()),
|
||||
"status" => "unverified");
|
||||
$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'!");
|
||||
}
|
||||
|
@ -1214,8 +1214,7 @@ class YellowEditResponse {
|
|||
public function getTextData() {
|
||||
$textLanguage = $this->yellow->text->getData("language", $this->language);
|
||||
$textEdit = $this->yellow->text->getData("edit", $this->language);
|
||||
$textYellow = $this->yellow->text->getData("yellow", $this->language);
|
||||
return array_merge($textLanguage, $textEdit, $textYellow);
|
||||
return array_merge($textLanguage, $textEdit);
|
||||
}
|
||||
|
||||
// Return settings actions
|
||||
|
@ -1236,7 +1235,7 @@ class YellowEditResponse {
|
|||
if ($this->yellow->extensions->isExisting("emojiawesome")) $toolbarButtons .= ", emojiawesome";
|
||||
if ($this->yellow->extensions->isExisting("fontawesome")) $toolbarButtons .= ", fontawesome";
|
||||
if ($this->yellow->extensions->isExisting("draft")) $toolbarButtons .= ", draft";
|
||||
if ($this->yellow->extensions->isExisting("markdown")) $toolbarButtons .= ", preview, markdown";
|
||||
$toolbarButtons .= ", preview";
|
||||
}
|
||||
} else {
|
||||
$toolbarButtons = $this->yellow->system->get("{$name}ToolbarButtons");
|
||||
|
|
Binary file not shown.
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
// Install extension, https://github.com/datenstrom/yellow
|
||||
// Copyright (c) 2013-2019 Datenstrom, https://datenstrom.se
|
||||
// Copyright (c) 2013-2020 Datenstrom, https://datenstrom.se
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
class YellowInstall {
|
||||
const VERSION = "0.8.13";
|
||||
const VERSION = "0.8.14";
|
||||
const TYPE = "feature";
|
||||
const PRIORITY = "1";
|
||||
public $yellow; //access to API
|
||||
|
@ -35,7 +35,8 @@ class YellowInstall {
|
|||
public function processCommandInstall() {
|
||||
$statusCode = $this->updateLog();
|
||||
if ($statusCode==200) $statusCode = $this->updateLanguage();
|
||||
if ($statusCode==200) $statusCode = $this->updateSettings($this->getSystemData());
|
||||
if ($statusCode==200) $statusCode = $this->updateText("en");
|
||||
if ($statusCode==200) $statusCode = $this->updateSystem($this->getSystemData());
|
||||
if ($statusCode==200) $statusCode = $this->removeFiles();
|
||||
if ($statusCode==200) {
|
||||
$statusCode = 0;
|
||||
|
@ -63,11 +64,13 @@ class YellowInstall {
|
|||
$this->yellow->page->safeMode = false;
|
||||
if ($status=="install") $status = $this->updateExtension($extension)==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateUser($email, $password, $author, $language)==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "Home", "/")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "Default", "/shared/page-new-default")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "Blog", "/shared/page-new-blog")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "Wiki", "/shared/page-new-wiki")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateSettings($this->getSystemData())==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "installHome", "/")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "installDefault", "/shared/page-new-default")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "installBlog", "/shared/page-new-blog")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "installWiki", "/shared/page-new-wiki")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateContent($language, "coreError404", "/shared/page-error-404")==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateText($language)==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->updateSystem($this->getSystemData())==200 ? "ok" : "error";
|
||||
if ($status=="ok") $status = $this->removeFiles()==200 ? "done" : "error";
|
||||
if ($status=="done") {
|
||||
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
|
||||
|
@ -179,12 +182,12 @@ class YellowInstall {
|
|||
"language" => $language,
|
||||
"home" => "/",
|
||||
"access" => "create, edit, delete, upload, system, update",
|
||||
"status" => "active",
|
||||
"pending" => "none",
|
||||
"hash" => $this->yellow->extensions->get("edit")->users->createHash($password),
|
||||
"stamp" => $this->yellow->extensions->get("edit")->users->createStamp(),
|
||||
"pending" => "none",
|
||||
"failed" => "0",
|
||||
"modified" => time());
|
||||
"modified" => time(),
|
||||
"status" => "active");
|
||||
if (!$this->yellow->extensions->get("edit")->users->save($fileNameUser, $email, $settings)) {
|
||||
$statusCode = 500;
|
||||
$this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
|
||||
|
@ -200,11 +203,11 @@ class YellowInstall {
|
|||
$fileName = $this->yellow->lookup->findFileFromLocation($location);
|
||||
$fileData = strreplaceu("\r\n", "\n", $this->yellow->toolbox->readFile($fileName));
|
||||
if (!empty($fileData) && $language!="en") {
|
||||
$titleOld = "Title: ".$this->yellow->text->getText("install{$name}Title", "en");
|
||||
$titleNew = "Title: ".$this->yellow->text->getText("install{$name}Title", $language);
|
||||
$textOld = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", "en"));
|
||||
$textNew = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", $language));
|
||||
if ($name!="Footer") $fileData = strreplaceu($titleOld, $titleNew, $fileData);
|
||||
$titleOld = "Title: ".$this->yellow->text->getText("{$name}Title", "en");
|
||||
$titleNew = "Title: ".$this->yellow->text->getText("{$name}Title", $language);
|
||||
$textOld = strreplaceu("\\n", "\n", $this->yellow->text->getText("{$name}Text", "en"));
|
||||
$textNew = strreplaceu("\\n", "\n", $this->yellow->text->getText("{$name}Text", $language));
|
||||
$fileData = strreplaceu($titleOld, $titleNew, $fileData);
|
||||
$fileData = strreplaceu($textOld, $textNew, $fileData);
|
||||
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
|
||||
$statusCode = 500;
|
||||
|
@ -214,8 +217,26 @@ class YellowInstall {
|
|||
return $statusCode;
|
||||
}
|
||||
|
||||
// Update settings
|
||||
public function updateSettings($settings) {
|
||||
// Update text settings
|
||||
public function updateText($language) {
|
||||
$statusCode = 200;
|
||||
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreTextFile");
|
||||
$fileData = $this->yellow->toolbox->readFile($fileName);
|
||||
if (count($this->yellow->toolbox->getTextLines($fileData))<4) {
|
||||
$fileData .= "Language: $language\n";
|
||||
$fileData .= "CoreDateFormatMedium: ".$this->yellow->text->getText("coreDateFormatMedium", $language)."\n";
|
||||
$fileData .= "EditLoginTitle: ".$this->yellow->text->getText("editLoginTitle", $language)."\n";
|
||||
$fileData .= "picture.jpg: ".$this->yellow->text->getText("installExampleImage", $language)."\n";
|
||||
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
|
||||
$statusCode = 500;
|
||||
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
|
||||
}
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
||||
// Update system settings
|
||||
public function updateSystem($settings) {
|
||||
$statusCode = 200;
|
||||
$fileName = $this->yellow->system->get("coreSettingDir").$this->yellow->system->get("coreSystemFile");
|
||||
if (!$this->yellow->system->save($fileName, $settings)) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
class YellowUpdate {
|
||||
const VERSION = "0.8.14";
|
||||
const VERSION = "0.8.15";
|
||||
const TYPE = "feature";
|
||||
const PRIORITY = "2";
|
||||
public $yellow; //access to API
|
||||
|
@ -57,7 +57,7 @@ class YellowUpdate {
|
|||
|
||||
// Handle update
|
||||
public function onUpdate($action) {
|
||||
if ($action=="update") { //TODO: remove later, converts old server settings and layout files
|
||||
if ($action=="update") { //TODO: remove later, converts old server settings
|
||||
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");
|
||||
|
@ -65,22 +65,9 @@ class YellowUpdate {
|
|||
$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 ($action=="update") { //TODO: remove later, converts old content settings
|
||||
if ($this->yellow->system->isExisting("safeMode")) {
|
||||
$coreSafeMode = $this->yellow->system->get("safeMode");
|
||||
$coreMultiLanguageMode = $this->yellow->system->get("multiLanguageMode");
|
||||
|
@ -112,6 +99,29 @@ class YellowUpdate {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($action=="update") { //TODO: remove later, converts old layout files
|
||||
if ($this->yellow->system->isExisting("navigation")) {
|
||||
$navigation = $this->yellow->system->get("navigation");
|
||||
$path = $this->yellow->system->get("coreLayoutDir");
|
||||
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);
|
||||
$fileDataNew = str_replace("text->getHtml(\"paginationNext\")", "text->getHtml(\"corePaginationNext\")", $fileDataNew);
|
||||
$fileDataNew = str_replace("\$this->yellow->page->get(\"header\")", "\"header\"", $fileDataNew);
|
||||
$fileDataNew = str_replace("\$this->yellow->page->get(\"sidebar\")", "\"sidebar\"", $fileDataNew);
|
||||
$fileDataNew = str_replace("\$this->yellow->page->get(\"footer\")", "\"footer\"", $fileDataNew);
|
||||
$fileDataNew = str_replace("\$this->yellow->page->get(\"navigation\")", "\"$navigation\"", $fileDataNew);
|
||||
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
|
||||
$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) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php $this->yellow->layout("header") ?>
|
||||
<div class="content">
|
||||
<?php $this->yellow->layout("sidebar") ?>
|
||||
<div class="main" role="main">
|
||||
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
|
||||
<?php echo $this->yellow->page->getContent() ?>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<div class="footer" role="contentinfo">
|
||||
<div class="siteinfo">
|
||||
<?php if ($page = $this->yellow->content->shared("footer")) $this->yellow->page->setPage("footer", $page) ?>
|
||||
<?php if ($this->yellow->page->isPage("footer")) echo $this->yellow->page->getPage("footer")->getContent() ?>
|
||||
<div class="siteinfo-banner"></div>
|
||||
</div>
|
||||
|
|
|
@ -12,17 +12,13 @@
|
|||
<?php echo $this->yellow->page->getExtra("header") ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php if ($page = $this->yellow->content->shared($this->yellow->page->get("header"))) $this->yellow->page->setPage("header", $page) ?>
|
||||
<?php if ($page = $this->yellow->content->shared($this->yellow->page->get("footer"))) $this->yellow->page->setPage("footer", $page) ?>
|
||||
<?php if ($page = $this->yellow->content->shared($this->yellow->page->get("sidebar"))) $this->yellow->page->setPage("sidebar", $page) ?>
|
||||
<?php if ($this->yellow->page->get("navigation")=="navigation-sidebar") $this->yellow->page->setPage("navigation-sidebar", $this->yellow->page) ?>
|
||||
<?php $class = "page layout-".$this->yellow->page->get("layout").($this->yellow->page->isPage("sidebar") || $this->yellow->page->isPage("navigation-sidebar") ? " with-sidebar" : "") ?>
|
||||
<div class="<?php echo htmlspecialchars($class) ?>">
|
||||
<div class="<?php echo "page layout-".$this->yellow->page->getHtml("layout") ?>">
|
||||
<div class="header" role="banner">
|
||||
<div class="sitename">
|
||||
<h1><a href="<?php echo $this->yellow->page->getBase(true)."/" ?>"><i class="sitename-logo"></i><?php echo $this->yellow->page->getHtml("sitename") ?></a></h1>
|
||||
<?php if ($page = $this->yellow->content->shared("header")) $this->yellow->page->setPage("header", $page) ?>
|
||||
<?php if ($this->yellow->page->isPage("header")) echo $this->yellow->page->getPage("header")->getContent() ?>
|
||||
</div>
|
||||
<div class="sitename-banner"></div>
|
||||
<?php $this->yellow->layout($this->yellow->page->get("navigation")) ?>
|
||||
<?php $this->yellow->layout("navigation") ?>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?php $pages = $this->yellow->content->top() ?>
|
||||
<?php $this->yellow->page->setLastModified($pages->getModified()) ?>
|
||||
<div class="navigation" role="navigation">
|
||||
<ul>
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<li><a<?php echo $page->isActive() ? " class=\"active\" aria-current=\"page\"" : "" ?> href="<?php echo $page->getLocation(true) ?>"><?php echo $page->getHtml("titleNavigation") ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navigation-banner"></div>
|
|
@ -1,16 +0,0 @@
|
|||
<?php list($name, $pages, $level) = $this->yellow->getLayoutArgs() ?>
|
||||
<?php if (!$pages) $pages = $this->yellow->content->top() ?>
|
||||
<?php $this->yellow->page->setLastModified($pages->getModified()) ?>
|
||||
<?php if (!$level): ?>
|
||||
<div class="navigation-tree" role="navigation">
|
||||
<?php endif ?>
|
||||
<ul>
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<?php $children = $page->getChildren() ?>
|
||||
<li><a<?php echo $page->isActive() ? " class=\"active\" aria-current=\"page\"" : "" ?> href="<?php echo $page->getLocation(true) ?>"><?php echo $page->getHtml("titleNavigation") ?></a><?php if ($children->count()) { echo "\n"; $this->yellow->layout($name, $children, $level+1); } ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php if (!$level): ?>
|
||||
</div>
|
||||
<div class="navigation-banner"></div>
|
||||
<?php endif ?>
|
|
@ -2,10 +2,10 @@
|
|||
<?php if ($pages->isPagination()): ?>
|
||||
<div class="pagination" role="navigation">
|
||||
<?php if ($pages->getPaginationPrevious()): ?>
|
||||
<a class="previous" href="<?php echo $pages->getPaginationPrevious() ?>"><?php echo $this->yellow->text->getHtml("paginationPrevious") ?></a>
|
||||
<a class="previous" href="<?php echo $pages->getPaginationPrevious() ?>"><?php echo $this->yellow->text->getHtml("corePaginationPrevious") ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($pages->getPaginationNext()): ?>
|
||||
<a class="next" href="<?php echo $pages->getPaginationNext() ?>"><?php echo $this->yellow->text->getHtml("paginationNext") ?></a>
|
||||
<a class="next" href="<?php echo $pages->getPaginationNext() ?>"><?php echo $this->yellow->text->getHtml("corePaginationNext") ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php if ($this->yellow->page->isPage("sidebar")): ?>
|
||||
<div class="sidebar" role="complementary">
|
||||
<?php $page = $this->yellow->page->getPage("sidebar") ?>
|
||||
<?php $page->setPage("main", $this->yellow->page) ?>
|
||||
<?php echo $page->getContent() ?>
|
||||
</div>
|
||||
<?php elseif ($this->yellow->page->isPage("navigation-sidebar")): ?>
|
||||
<div class="sidebar" role="complementary">
|
||||
<div class="navigation-sidebar">
|
||||
<?php $pages = $this->yellow->page->getParentTop(true)->getChildren() ?>
|
||||
<?php $this->yellow->page->setLastModified($pages->getModified()) ?>
|
||||
<p><?php echo $this->yellow->page->getHtml("titleNavigation") ?></p>
|
||||
<ul>
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<li><a<?php echo $page->isActive() ? " class=\"active\"" : "" ?> href="<?php echo $page->getLocation(true) ?>"><?php echo $page->getHtml("titleNavigation") ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
|
@ -8,10 +8,6 @@ Layout: default
|
|||
Theme: stockholm
|
||||
Parser: markdown
|
||||
Status: public
|
||||
Navigation: navigation
|
||||
Header: header
|
||||
Footer: footer
|
||||
Sidebar: sidebar
|
||||
|
||||
CoreStaticUrl:
|
||||
CoreStaticDefaultFile: index.html
|
||||
|
@ -41,6 +37,7 @@ CoreContentRootDir: default/
|
|||
CoreContentHomeDir: home/
|
||||
CoreContentSharedDir: shared/
|
||||
CoreContentDefaultFile: page.md
|
||||
CoreContentErrorFile: page-error-(.*).md
|
||||
CoreContentExtension: .md
|
||||
CoreDownloadExtension: .download
|
||||
CoreTextFile: text.ini
|
||||
|
|
Loading…
Add table
Reference in a new issue