mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 8d32c64680eebedf4b44c0d9dc3a2e4b4c28a6b7
parent 01074c4f434d5cefb122b2985b22a15534c64b12
Author: markseu <mark2011@mayberg.se>
Date:   Wed,  4 May 2022 10:37:09 +0200

Refactored core

Diffstat:
Msystem/extensions/command.php | 8++++----
Msystem/extensions/core.php | 201+++++++++++++++++++++++++++++++++++++------------------------------------------
Msystem/extensions/edit.php | 60++++++++++++++++++++++++++++++++++--------------------------
Msystem/extensions/install.php | 15+++++++++------
Msystem/extensions/update-current.ini | 20++++++++++----------
Msystem/extensions/update.php | 14+++++++-------
6 files changed, 158 insertions(+), 160 deletions(-)

diff --git a/system/extensions/command.php b/system/extensions/command.php @@ -2,7 +2,7 @@ // Command extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/command class YellowCommand { - const VERSION = "0.8.39"; + const VERSION = "0.8.40"; public $yellow; // access to API public $files; // number of files public $links; // number of links @@ -194,7 +194,7 @@ class YellowCommand { !$this->yellow->toolbox->modifyFile($fileName, $modified)) { $statusCode = 500; $this->yellow->page->statusCode = $statusCode; - $this->yellow->page->set("pageError", "Can't write file '$fileName'!"); + $this->yellow->page->errorMessage = "Can't write file '$fileName'!"; } return $statusCode; } @@ -209,7 +209,7 @@ class YellowCommand { !$this->yellow->toolbox->modifyFile($fileName, $modified)) { $statusCode = 500; $this->yellow->page->statusCode = $statusCode; - $this->yellow->page->set("pageError", "Can't write file '$fileName'!"); + $this->yellow->page->errorMessage = "Can't write file '$fileName'!"; } return $statusCode; } @@ -541,7 +541,7 @@ class YellowCommand { $locations = array(); $staticUrl = $this->yellow->system->get("coreStaticUrl"); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); - $this->yellow->page->setRequestInformation($scheme, $address, $base, "", ""); + $this->yellow->page->setRequestInformation($scheme, $address, $base, "", "", false); foreach ($this->yellow->content->index(true, true) as $page) { if (preg_match("/exclude/i", $page->get("build")) && !$includeAll) continue; if ($page->get("status")=="private" || $page->get("status")=="draft") continue; diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core class YellowCore { - const VERSION = "0.8.75"; + const VERSION = "0.8.76"; const RELEASE = "0.8.19"; public $page; // current page public $content; // content files @@ -106,7 +106,7 @@ class YellowCore { $this->toolbox->timerStart($time); ob_start(); list($scheme, $address, $base, $location, $fileName) = $this->getRequestInformation(); - $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName); + $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName, true); foreach ($this->extension->data as $key=>$value) { if (method_exists($value["object"], "onRequest")) { $this->lookup->requestHandler = $key; @@ -118,7 +118,7 @@ class YellowCore { $this->lookup->requestHandler = "core"; $statusCode = $this->processRequest($scheme, $address, $base, $location, $fileName, true); } - if ($this->page->isExisting("pageError")) $statusCode = $this->processRequestError(); + if ($this->page->isError()) $statusCode = $this->processRequestError(); ob_end_flush(); $this->toolbox->timerStop($time); if ($this->system->get("coreDebugMode")>=1 && $this->lookup->isContentFile($fileName)) { @@ -144,13 +144,12 @@ class YellowCore { } } if ($statusCode==0) { - if ($this->lookup->isContentFile($fileName) || !is_readable($fileName)) { - $fileName = $this->readPage($scheme, $address, $base, $location, $fileName, $cacheable, - max(is_readable($fileName) ? 200 : 404, $this->page->statusCode), $this->page->get("pageError")); - $statusCode = $this->sendPage(); + if ($this->lookup->isContentFile($fileName)) { + $statusCode = $this->sendPage($scheme, $address, $base, $location, $fileName, $cacheable, true); } else { - $statusCode = $this->sendFile(200, $fileName, true); + $statusCode = $this->sendFile(200, $fileName, $cacheable); } + if (!is_readable($fileName)) $this->page->error(404); } if ($this->system->get("coreDebugMode")>=1 && $this->lookup->isContentFile($fileName)) { echo "YellowCore::processRequest file:$fileName<br/>\n"; @@ -161,11 +160,9 @@ class YellowCore { // Process request with error public function processRequestError() { ob_clean(); - $fileName = $this->readPage($this->page->scheme, $this->page->address, $this->page->base, - $this->page->location, $this->page->fileName, $this->page->cacheable, $this->page->statusCode, - $this->page->get("pageError")); - $statusCode = $this->sendPage(); - if ($this->system->get("coreDebugMode")>=1) echo "YellowCore::processRequestError file:$fileName<br/>\n"; + $statusCode = $this->sendPage($this->page->scheme, $this->page->address, $this->page->base, + $this->page->location, $this->page->fileName, false, false); + if ($this->system->get("coreDebugMode")>=1) echo "YellowCore::processRequestError file:".$this->page->fileName."<br/>\n"; return $statusCode; } @@ -183,49 +180,18 @@ class YellowCore { } } - // Read page - public function readPage($scheme, $address, $base, $location, $fileName, $cacheable, $statusCode, $pageError) { - if ($statusCode>=400) { - $locationError = $this->content->getHomeLocation($this->page->location)."shared/"; - $fileNameError = $this->lookup->findFileFromContentLocation($locationError, true).$this->system->get("coreContentErrorFile"); - $fileNameError = str_replace("(.*)", $statusCode, $fileNameError); - $languageError = $this->lookup->findContentLanguage($fileName, $this->system->get("language")); - if (is_file($fileNameError)) { - $rawData = $this->toolbox->readFile($fileNameError); - } elseif ($this->language->isText("coreError${statusCode}Title", $languageError)) { - $rawData = "---\nTitle: ".$this->language->getText("coreError${statusCode}Title", $languageError)."\n"; - $rawData .= "Layout: error\n---\n".$this->language->getText("coreError${statusCode}Text", $languageError); - } else { - $rawData = "---\nTitle:".$this->toolbox->getHttpStatusFormatted($statusCode, true)."\n"; - $rawData .= "Layout:error\n---\n$pageError"; - } - $cacheable = false; - } else { - $rawData = $this->toolbox->readFile($fileName); - } + // Send page response + public function sendPage($scheme, $address, $base, $location, $fileName, $cacheable, $showSource) { + $rawData = $showSource ? $this->toolbox->readFile($fileName) : $this->page->getRawDataError(); + $statusCode = max($this->page->statusCode, 200); + $errorMessage = $this->page->errorMessage; $this->page = new YellowPage($this); - $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $this->page->parseData($rawData, $cacheable, $statusCode, $pageError); + $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName, $cacheable); + $this->page->parseMeta($rawData, $statusCode, $errorMessage); $this->language->set($this->page->get("language")); - return $fileName; - } - - // Send page response - public function sendPage() { $this->page->parseContent(); $this->page->parsePage(); - $statusCode = $this->page->statusCode; - $lastModifiedFormatted = $this->page->getHeader("Last-Modified"); - if ($statusCode==200 && $this->page->isCacheable() && $this->toolbox->isNotModified($lastModifiedFormatted)) { - $statusCode = 304; - @header($this->toolbox->getHttpStatusFormatted($statusCode)); - } else { - @header($this->toolbox->getHttpStatusFormatted($statusCode)); - foreach ($this->page->headerData as $key=>$value) { - @header("$key: $value"); - } - if (!is_null($this->page->outputData)) echo $this->page->outputData; - } + $statusCode = $this->sendData($this->page->statusCode, $this->page->headerData, $this->page->outputData); if ($this->system->get("coreDebugMode")>=1) { foreach ($this->page->headerData as $key=>$value) { echo "YellowCore::sendPage $key: $value<br/>\n"; @@ -239,6 +205,22 @@ class YellowCore { return $statusCode; } + // Send data response + public function sendData($statusCode, $headerData, $outputData) { + $lastModifiedFormatted = isset($headerData["Last-Modified"]) ? $headerData["Last-Modified"] : ""; + if ($statusCode==200 && !isset($headerData["Cache-Control"]) && $this->toolbox->isNotModified($lastModifiedFormatted)) { + $statusCode = 304; + @header($this->toolbox->getHttpStatusFormatted($statusCode)); + } else { + @header($this->toolbox->getHttpStatusFormatted($statusCode)); + foreach ($headerData as $key=>$value) { + @header("$key: $value"); + } + if (!is_null($outputData)) echo $outputData; + } + return $statusCode; + } + // Send file response public function sendFile($statusCode, $fileName, $cacheable) { $lastModifiedFormatted = $this->toolbox->getHttpDateFormatted($this->toolbox->getFileModified($fileName)); @@ -255,16 +237,6 @@ class YellowCore { return $statusCode; } - // Send data response - public function sendData($statusCode, $rawData, $fileName, $cacheable) { - @header($this->toolbox->getHttpStatusFormatted($statusCode)); - if (!$cacheable) @header("Cache-Control: no-cache, no-store"); - @header("Content-Type: ".$this->toolbox->getMimeContentType($fileName)); - @header("Last-Modified: ".$this->toolbox->getHttpDateFormatted(time())); - echo $rawData; - return $statusCode; - } - // Send status response public function sendStatus($statusCode, $location = "") { if (!empty($location)) $this->page->clean($statusCode, $location); @@ -272,11 +244,6 @@ class YellowCore { foreach ($this->page->headerData as $key=>$value) { @header("$key: $value"); } - if ($this->system->get("coreDebugMode")>=1) { - foreach ($this->page->headerData as $key=>$value) { - echo "YellowCore::sendStatus $key: $value<br/>\n"; - } - } return $statusCode; } @@ -444,12 +411,13 @@ class YellowPage { public $outputData; // response output public $parser; // content parser public $parserData; // content data of page + public $statusCode; // status code + public $errorMessage; // error message + public $lastModified; // last modification date public $available; // page is available? (boolean) public $visible; // page is visible location? (boolean) public $active; // page is active location? (boolean) public $cacheable; // page is cacheable? (boolean) - public $lastModified; // last modification date - public $statusCode; // status code public function __construct($yellow) { $this->yellow = $yellow; @@ -460,45 +428,46 @@ class YellowPage { } // Set request information - public function setRequestInformation($scheme, $address, $base, $location, $fileName) { + public function setRequestInformation($scheme, $address, $base, $location, $fileName, $cacheable) { $this->scheme = $scheme; $this->address = $address; $this->base = $base; $this->location = $location; $this->fileName = $fileName; + $this->cacheable = $cacheable; } - // Parse page data - public function parseData($rawData, $cacheable, $statusCode, $pageError = "") { + // Parse page meta + public function parseMeta($rawData, $statusCode = 0, $errorMessage = "") { $this->rawData = $rawData; $this->parser = null; $this->parserData = ""; + $this->statusCode = $statusCode; + $this->errorMessage = $errorMessage; + $this->lastModified = 0; $this->available = $this->yellow->lookup->isAvailableLocation($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; - $this->statusCode = $statusCode; - $this->parseMeta($pageError); + $this->parseMetaData(); } - // Parse page data update - public function parseDataUpdate() { + // Parse page meta update + public function parseMetaUpdate() { if ($this->statusCode==0) { $this->rawData = $this->yellow->toolbox->readFile($this->fileName); $this->statusCode = 200; - $this->parseMeta(); + $this->parseMetaData(); } } // Parse page meta data - public function parseMeta($pageError = "") { + public function parseMetaData() { $this->metaData = new YellowArray(); if (!is_null($this->rawData)) { $this->set("title", $this->yellow->toolbox->createTextTitle($this->location)); $this->set("language", $this->yellow->lookup->findContentLanguage($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")); + $this->parseMetaDataRaw(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")); @@ -516,20 +485,19 @@ class YellowPage { $this->yellow->system->get("coreServerAddress"), $this->yellow->system->get("coreServerBase"), rtrim($this->yellow->system->get("editLocation"), "/").$this->location)); - $this->parseMetaShared(); + $this->parseMetaDataShared(); } else { $this->set("type", $this->yellow->toolbox->getFileType($this->fileName)); $this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("coreMediaDirectory"))); $this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName))); } - if (!empty($pageError)) $this->set("pageError", $pageError); foreach ($this->yellow->extension->data as $key=>$value) { if (method_exists($value["object"], "onParseMeta")) $value["object"]->onParseMeta($this); } } // Parse page meta data from raw data - public function parseMetaRaw($defaultKeys) { + public function parseMetaDataRaw($defaultKeys) { foreach ($defaultKeys as $key) { $value = $this->yellow->system->get($key); if (!empty($key) && !strempty($value)) $this->set($key, $value); @@ -547,8 +515,8 @@ class YellowPage { } } - // Parse page meta data with shared pages - public function parseMetaShared() { + // Parse page meta data for shared pages + public function parseMetaDataShared() { $this->sharedPages["main"] = $this; if ($this->available && $this->statusCode!=0) { foreach ($this->yellow->content->getShared($this->location) as $page) { @@ -580,7 +548,7 @@ class YellowPage { } } else { $this->parserData = $this->getContent(true, $sizeMax); - $this->parserData = preg_replace("/\[yellow error\]/i", $this->get("pageError"), $this->parserData); + $this->parserData = preg_replace("/\[yellow error\]/i", $this->errorMessage, $this->parserData); } if (!$this->isExisting("description")) { $description = $this->yellow->toolbox->createTextDescription($this->parserData, 150); @@ -603,7 +571,7 @@ class YellowPage { } if (is_null($output)) { if ($name=="yellow" && $type=="inline" && $text=="error") { - $output = $this->get("pageError"); + $output = $this->errorMessage; } } if ($this->yellow->system->get("coreDebugMode")>=3 && !empty($name)) { @@ -746,7 +714,7 @@ class YellowPage { // Return page content, HTML encoded or raw format public function getContent($rawFormat = false, $sizeMax = 0) { if ($rawFormat) { - $this->parseDataUpdate(); + $this->parseMetaUpdate(); $text = substrb($this->rawData, $this->metaDataOffsetBytes); } else { $this->parseContent($sizeMax); @@ -903,27 +871,38 @@ class YellowPage { return $httpFormat ? $this->yellow->toolbox->getHttpDateFormatted($lastModified) : $lastModified; } + // Return raw data for error page + public function getRawDataError() { + $statusCode = $this->statusCode; + $sharedLocation = $this->yellow->content->getHomeLocation($this->location)."shared/"; + $fileNameError = $this->yellow->lookup->findFileFromContentLocation($sharedLocation, true).$this->yellow->system->get("coreContentErrorFile"); + $fileNameError = str_replace("(.*)", $statusCode, $fileNameError); + $languageError = $this->yellow->lookup->findContentLanguage($this->fileName, $this->yellow->system->get("language")); + if (is_file($fileNameError)) { + $rawData = $this->yellow->toolbox->readFile($fileNameError); + } elseif ($this->yellow->language->isText("coreError${statusCode}Title", $languageError)) { + $rawData = "---\nTitle: ".$this->yellow->language->getText("coreError${statusCode}Title", $languageError)."\n"; + $rawData .= "Layout: error\n---\n".$this->yellow->language->getText("coreError${statusCode}Text", $languageError); + } else { + $rawData = "---\nTitle:".$this->yellow->toolbox->getHttpStatusFormatted($statusCode, true)."\n"; + $rawData .= "Layout:error\n---\n".$this->errorMessage; + } + return $rawData; + } + // Return page status code, number or HTTP format public function getStatusCode($httpFormat = false) { $statusCode = $this->statusCode; if ($httpFormat) { $statusCode = $this->yellow->toolbox->getHttpStatusFormatted($statusCode); - if ($this->isExisting("pageError")) $statusCode .= ": ".$this->get("pageError"); + if (!empty($this->errorMessage)) $statusCode .= ": ".$this->errorMessage; } return $statusCode; } - // Respond with error page - public function error($statusCode, $pageError = "") { - if (!$this->isExisting("pageError") && $statusCode>0) { - $this->statusCode = $statusCode; - $this->set("pageError", empty($pageError) ? "Page error!" : $pageError); - } - } - // Respond with status code, no page content public function clean($statusCode, $location = "") { - if (!$this->isExisting("pageClean") && $statusCode>0) { + if ($statusCode>0 && !$this->isExisting("pageClean")) { $this->statusCode = $statusCode; $this->lastModified = 0; $this->headerData = array(); @@ -935,6 +914,14 @@ class YellowPage { } } + // Respond with error page + public function error($statusCode, $errorMessage = "") { + if ($statusCode>=400 && empty($this->errorMessage)) { + $this->statusCode = $statusCode; + $this->errorMessage = empty($errorMessage) ? "Page error!" : $errorMessage; + } + } + // Check if page is available public function isAvailable() { return $this->available; @@ -1245,8 +1232,8 @@ class YellowContent { $rootLocations = $this->yellow->lookup->findContentRootLocations(); foreach ($rootLocations as $rootLocation=>$rootFileName) { $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $rootLocation, $rootFileName); - $page->parseData("", false, 0); + $page->setRequestInformation($scheme, $address, $base, $rootLocation, $rootFileName, false); + $page->parseMeta(""); array_push($this->pages[$location], $page); } } else { @@ -1255,8 +1242,8 @@ class YellowContent { foreach ($fileNames as $fileName) { $page = new YellowPage($this->yellow); $page->setRequestInformation($scheme, $address, $base, - $this->yellow->lookup->findContentLocationFromFile($fileName), $fileName); - $page->parseData($this->yellow->toolbox->readFile($fileName, 4096), false, 0); + $this->yellow->lookup->findContentLocationFromFile($fileName), $fileName, false); + $page->parseMeta($this->yellow->toolbox->readFile($fileName, 4096)); if (strlenb($page->rawData)<4096) $page->statusCode = 200; array_push($this->pages[$location], $page); } @@ -1299,8 +1286,8 @@ class YellowContent { foreach ($matches as $match) { if ($match[1]==2) { $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $one->location."#".$match[2], $one->fileName); - $page->parseData("---\nTitle: $match[3]\n---\n", false, 0); + $page->setRequestInformation($scheme, $address, $base, $one->location."#".$match[2], $one->fileName, false); + $page->parseMeta("---\nTitle: $match[3]\n---\n"); $pages->append($page); } } @@ -1451,8 +1438,8 @@ class YellowMedia { foreach ($fileNames as $fileName) { $file = new YellowPage($this->yellow); $file->setRequestInformation($scheme, $address, $base, - $this->yellow->lookup->findMediaLocationFromFile($fileName), $fileName); - $file->parseData(null, false, 0); + $this->yellow->lookup->findMediaLocationFromFile($fileName), $fileName, false); + $file->parseMeta(null); array_push($this->files[$location], $file); } } diff --git a/system/extensions/edit.php b/system/extensions/edit.php @@ -2,7 +2,7 @@ // Edit extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/edit class YellowEdit { - const VERSION = "0.8.60"; + const VERSION = "0.8.61"; public $yellow; // access to API public $response; // web response public $merge; // text merge @@ -64,7 +64,7 @@ class YellowEdit { $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); + $this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); $statusCode = $this->processRequest($scheme, $address, $base, $location, $fileName); } return $statusCode; @@ -724,7 +724,7 @@ class YellowEdit { $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } else { - $this->yellow->page->error(500, $page->get("pageError")); + $this->yellow->page->error(500, $page->errorMessage); $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } @@ -757,7 +757,7 @@ class YellowEdit { $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } else { - $this->yellow->page->error(500, $page->get("pageError")); + $this->yellow->page->error(500, $page->errorMessage); $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } @@ -788,7 +788,7 @@ class YellowEdit { $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } else { - $this->yellow->page->error(500, $page->get("pageError")); + $this->yellow->page->error(500, $page->errorMessage); $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } @@ -814,7 +814,7 @@ class YellowEdit { $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } else { - $this->yellow->page->error(500, $page->get("pageError")); + $this->yellow->page->error(500, $page->errorMessage); $statusCode = $this->yellow->processRequest($scheme, $address, $base, $location, $fileName, false); } } @@ -825,7 +825,11 @@ class YellowEdit { public function processRequestPreview($scheme, $address, $base, $location, $fileName) { $page = $this->response->getPagePreview($scheme, $address, $base, $location, $fileName, $this->yellow->page->getRequest("rawdataedit"), $this->yellow->page->getRequest("rawdataendofline")); - $statusCode = $this->yellow->sendData(200, $page->outputData, "", false); + $page->headerData = array( + "Cache-Control"=>"no-cache, no-store", + "Content-Type"=>$this->yellow->toolbox->getMimeContentType("a.html"), + "Last-Modified"=>$this->yellow->toolbox->getHttpDateFormatted(time())); + $statusCode = $this->yellow->sendData($page->statusCode, $page->headerData, $page->outputData); if ($this->yellow->system->get("coreDebugMode")>=1) echo "YellowEdit::processRequestPreview file:$fileName<br/>\n"; return $statusCode; } @@ -849,8 +853,11 @@ class YellowEdit { } else { $data["error"] = "Can't write file '$fileNameShort'!"; } - $statusCode = $this->yellow->sendData(isset($data["error"]) ? 500 : 200, json_encode($data), "a.json", false); - return $statusCode; + $headerData = array( + "Cache-Control"=>"no-cache, no-store", + "Content-Type"=>$this->yellow->toolbox->getMimeContentType("a.json"), + "Last-Modified"=>$this->yellow->toolbox->getHttpDateFormatted(time())); + return $this->yellow->sendData(isset($data["error"]) ? 500 : 200, $headerData, json_encode($data)); } // Check user authentication @@ -1063,8 +1070,8 @@ class YellowEditResponse { public function getPageNew($scheme, $address, $base, $location, $fileName, $rawData, $endOfLine) { $rawData = $this->yellow->toolbox->normaliseLines($rawData, $endOfLine); $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $page->parseData($rawData, false, 0); + $page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $page->parseMeta($rawData); $this->editContentFile($page, "create", $this->userEmail); if ($this->yellow->content->find($page->location)) { $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("pageNewLocation")); @@ -1095,11 +1102,11 @@ class YellowEditResponse { $rawDataFile = $this->yellow->toolbox->normaliseLines($rawDataFile, $endOfLine); $rawData = $this->extension->merge->merge($rawDataSource, $rawDataEdit, $rawDataFile); $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $page->parseData($rawData, false, 0); + $page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $page->parseMeta($rawData); $pageSource = new YellowPage($this->yellow); - $pageSource->setRequestInformation($scheme, $address, $base, $location, $fileName); - $pageSource->parseData(($rawDataSource), false, 0); + $pageSource->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $pageSource->parseMeta($rawDataSource); $this->editContentFile($page, "edit", $this->userEmail); if ($this->isMetaModified($pageSource, $page) && $page->location!=$this->yellow->content->getHomeLocation($page->location)) { $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("pageNewLocation"), true); @@ -1120,8 +1127,8 @@ class YellowEditResponse { public function getPageDelete($scheme, $address, $base, $location, $fileName, $rawData, $endOfLine) { $rawData = $this->yellow->toolbox->normaliseLines($rawData, $endOfLine); $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $page->parseData($rawData, false, 0); + $page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $page->parseMeta($rawData); $this->editContentFile($page, "delete", $this->userEmail); if (!$this->isUserAccess("delete", $page->location)) { $page->error(500, "Page '".$page->get("title")."' is restricted!"); @@ -1132,8 +1139,8 @@ class YellowEditResponse { // Return restored page public function getPageRestore($scheme, $address, $base, $location, $fileName) { $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $page->parseData("", false, 0); + $page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $page->parseMeta(""); $this->editContentFile($page, "restore", $this->userEmail); if (!$this->isUserAccess("restore", $page->location)) { $page->error(500, "Page '".$page->get("title")."' is restricted!"); @@ -1145,23 +1152,24 @@ class YellowEditResponse { public function getPagePreview($scheme, $address, $base, $location, $fileName, $rawData, $endOfLine) { $rawData = $this->yellow->toolbox->normaliseLines($rawData, $endOfLine); $page = new YellowPage($this->yellow); - $page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $page->parseData($rawData, false, 200); + $page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $page->parseMeta($rawData, 200); $this->yellow->language->set($page->get("language")); $class = "page-preview layout-".$page->get("layout"); $output = "<div class=\"".htmlspecialchars($class)."\"><div class=\"content\"><div class=\"main\">"; if ($this->yellow->system->get("editToolbarButtons")!="none") $output .= "<h1>".$page->getHtml("titleContent")."</h1>\n"; $output .= $page->getContent(); $output .= "</div></div></div>"; - $page->setOutput($output); + $page->statusCode = 200; + $page->outputData = $output; return $page; } // Return uploaded file public function getFileUpload($scheme, $address, $base, $pageLocation, $fileNameTemp, $fileNameShort) { $file = new YellowPage($this->yellow); - $file->setRequestInformation($scheme, $address, $base, "/".$fileNameTemp, $fileNameTemp); - $file->parseData(null, false, 0); + $file->setRequestInformation($scheme, $address, $base, "/".$fileNameTemp, $fileNameTemp, false); + $file->parseMeta(null); $file->set("fileNameShort", $fileNameShort); $file->set("type", $this->yellow->toolbox->getFileType($fileNameShort)); if ($file->get("type")=="html" || $file->get("type")=="svg") { @@ -1187,8 +1195,8 @@ class YellowEditResponse { // Return system file public function getFileSystem($scheme, $address, $base, $pageLocation, $fileNameSystem, $settings) { $file = new YellowPage($this->yellow); - $file->setRequestInformation($scheme, $address, $base, "/".$fileNameSystem, $fileNameSystem); - $file->parseData(null, false, 0); + $file->setRequestInformation($scheme, $address, $base, "/".$fileNameSystem, $fileNameSystem, false); + $file->parseMeta(null); foreach ($settings as $key=>$value) $file->set($key, $value); $this->editSystemFile($file, "configure", $this->userEmail); return $file; diff --git a/system/extensions/install.php b/system/extensions/install.php @@ -2,7 +2,7 @@ // Install extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/install class YellowInstall { - const VERSION = "0.8.70"; + const VERSION = "0.8.71"; const PRIORITY = "1"; public $yellow; // access to API @@ -35,10 +35,13 @@ class YellowInstall { $status = trim($this->yellow->page->getRequest("status")); $statusCode = $this->updateLog(); $statusCode = max($statusCode, $this->updateLanguages()); + $errorMessage = $this->yellow->page->errorMessage; $this->yellow->content->pages["root/"] = array(); $this->yellow->page = new YellowPage($this->yellow); - $this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName); - $this->yellow->page->parseData($this->getRawDataInstall(), false, $statusCode, $this->yellow->page->get("pageError")); + $this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); + $this->yellow->page->parseMeta($this->getRawDataInstall(), $statusCode, $errorMessage); + $this->yellow->page->parseContent(); + $this->yellow->page->parsePage(); 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->updateAuthentication($scheme, $address, $base, $email)==200 ? "ok" : "error"; @@ -58,7 +61,7 @@ class YellowInstall { $location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, "/"); $statusCode = $this->yellow->sendStatus(303, $location); } else { - $statusCode = $this->yellow->sendPage(); + $statusCode = $this->yellow->sendData($this->yellow->page->statusCode, $this->yellow->page->headerData, $this->yellow->page->outputData); } } return $statusCode; @@ -88,14 +91,14 @@ class YellowInstall { echo "The installation has not been completed. Please type 'php yellow.php serve'.\n"; } if ($statusCode>=400) { - echo "ERROR installing files: ".$this->yellow->page->get("pageError")."\n"; + echo "ERROR installing files: ".$this->yellow->page->errorMessage."\n"; echo "The installation has not been completed. Please run command again.\n"; } } else { $statusCode = $this->removeInstall(); $this->yellow->log($statusCode==200 ? "info" : "error", "Uninstall extension 'Install ".YellowInstall::VERSION."'"); if ($statusCode>=400) { - echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; + echo "ERROR updating files: ".$this->yellow->page->errorMessage."\n"; echo "Detected ZIP-files, 0 extensions installed. Please run command again.\n"; } } diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -11,21 +11,21 @@ Tag: feature system/extensions/bundle.php: bundle.php, create, update Extension: Command -Version: 0.8.39 +Version: 0.8.40 Description: Command line of the website. DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/command DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/command.zip -Published: 2022-04-19 18:00:05 +Published: 2022-05-03 12:12:57 Developer: Datenstrom Tag: feature system/extensions/command.php: command.php, create, update Extension: Core -Version: 0.8.75 +Version: 0.8.76 Description: Core functionality of the website. DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip -Published: 2022-04-29 07:50:15 +Published: 2022-05-03 13:03:22 Developer: Datenstrom Tag: feature system/extensions/core.php: core.php, create, update @@ -37,11 +37,11 @@ system/layouts/navigation.html: navigation.html, create, update, careful system/layouts/pagination.html: pagination.html, create, update, careful Extension: Edit -Version: 0.8.60 +Version: 0.8.61 Description: Edit your website in a web browser. DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/edit DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/edit.zip -Published: 2022-04-29 14:50:00 +Published: 2022-05-03 12:48:30 Developer: Datenstrom Tag: feature system/extensions/edit.php: edit.php, create, update @@ -64,11 +64,11 @@ media/images/photo.jpg: photo.jpg, create, optional media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional Extension: Install -Version: 0.8.70 +Version: 0.8.71 Description: Install a brand new, shiny website. DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/install DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/install.zip -Published: 2022-04-19 22:49:34 +Published: 2022-05-03 12:14:50 Developer: Datenstrom Status: unlisted system/extensions/install.php: install.php, create @@ -131,11 +131,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful Extension: Update -Version: 0.8.73 +Version: 0.8.74 Description: Keep your website up to date. DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip -Published: 2022-04-29 10:36:26 +Published: 2022-05-03 12:49:27 Developer: Datenstrom Tag: feature system/extensions/update.php: update.php, create, update diff --git a/system/extensions/update.php b/system/extensions/update.php @@ -2,7 +2,7 @@ // Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update class YellowUpdate { - const VERSION = "0.8.73"; + const VERSION = "0.8.74"; const PRIORITY = "2"; public $yellow; // access to API public $extensions; // number of extensions @@ -210,7 +210,7 @@ class YellowUpdate { list($statusCode, $settings) = $this->getExtensionInstallInformation($extensions); if ($statusCode==200) $statusCode = $this->downloadExtensions($settings); if ($statusCode==200) $statusCode = $this->updateExtensions("install"); - if ($statusCode>=400) echo "ERROR installing files: ".$this->yellow->page->get("pageError")."\n"; + if ($statusCode>=400) echo "ERROR installing files: ".$this->yellow->page->errorMessage."\n"; echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated"; echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." installed\n"; } else { @@ -226,7 +226,7 @@ class YellowUpdate { $this->extensions = 0; list($statusCode, $settings) = $this->getExtensionUninstallInformation($extensions, "core, update"); if ($statusCode==200) $statusCode = $this->removeExtensions($settings); - if ($statusCode>=400) echo "ERROR uninstalling files: ".$this->yellow->page->get("pageError")."\n"; + if ($statusCode>=400) echo "ERROR uninstalling files: ".$this->yellow->page->errorMessage."\n"; echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated"; echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." uninstalled\n"; } else { @@ -244,7 +244,7 @@ class YellowUpdate { $this->extensions = 0; if ($statusCode==200) $statusCode = $this->downloadExtensions($settings); if ($statusCode==200) $statusCode = $this->updateExtensions("update"); - if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; + if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->errorMessage."\n"; echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated"; echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." updated\n"; } else { @@ -258,7 +258,7 @@ class YellowUpdate { } echo "Yellow $command: Updates are available. Please type 'php yellow.php update all'.\n"; } elseif ($statusCode!=200) { - echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; + echo "ERROR updating files: ".$this->yellow->page->errorMessage."\n"; } else { echo "Your website is up to date\n"; } @@ -273,7 +273,7 @@ class YellowUpdate { if ($this->isExtensionPending()) { $this->extensions = 0; $statusCode = $this->updateExtensions("install"); - if ($statusCode!=200) echo "ERROR installing files: ".$this->yellow->page->get("pageError")."\n"; + if ($statusCode!=200) echo "ERROR installing files: ".$this->yellow->page->errorMessage."\n"; echo "Detected ZIP-file".($this->extensions!=1 ? "s" : ""); echo ", $this->extensions extension".($this->extensions!=1 ? "s" : "")." installed. Please run command again.\n"; } @@ -307,7 +307,7 @@ class YellowUpdate { if ($value->isExisting("translator")) $description = "$text Translated by ".$value["translator"]."."; echo ucfirst($key)." - $description\n"; } - if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->get("pageError")."\n"; + if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->errorMessage."\n"; return $statusCode; }