commit 0df1efec6c70addf5c3b4ee04cc52d651f99701f
parent 7a724d780653e2da1af5b27dd08e3e3d9f7aaacc
Author: markseu <mark2011@mayberg.se>
Date: Thu, 16 Jan 2020 11:58:00 +0100
Refactored code and some cleanup
Diffstat:
2 files changed, 27 insertions(+), 47 deletions(-)
diff --git a/system/extensions/edit.php b/system/extensions/edit.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowEdit {
- const VERSION = "0.8.18";
+ const VERSION = "0.8.19";
const TYPE = "feature";
public $yellow; //access to API
public $response; //web response
@@ -1468,31 +1468,6 @@ class YellowEditResponse {
return $titleText.$titleNumber;
}
- // Normalise text lines, convert line endings
- public function normaliseLines($text, $endOfLine = "lf") {
- if ($endOfLine=="lf") {
- $text = preg_replace("/\R/u", "\n", $text);
- } else {
- $text = preg_replace("/\R/u", "\r\n", $text);
- }
- return $text;
- }
-
- // Create browser cookies
- public function createCookies($scheme, $address, $base, $email) {
- $expire = time() + $this->yellow->system->get("editLoginSessionTimeout");
- $authToken = $this->extension->users->createAuthToken($email, $expire);
- $csrfToken = $this->extension->users->createCsrfToken();
- setcookie("authtoken", $authToken, $expire, "$base/", "", $scheme=="https", true);
- setcookie("csrftoken", $csrfToken, $expire, "$base/", "", $scheme=="https", false);
- }
-
- // Destroy browser cookies
- public function destroyCookies($scheme, $address, $base) {
- setcookie("authtoken", "", 1, "$base/", "", $scheme=="https", true);
- setcookie("csrftoken", "", 1, "$base/", "", $scheme=="https", false);
- }
-
// Send mail to user
public function sendMail($scheme, $address, $base, $email, $action) {
if ($action=="approve") {
@@ -1531,6 +1506,21 @@ class YellowEditResponse {
$mailMessage = "$message\r\n\r\n$url\r\n-- \r\n$footer";
return mail($mailTo, $mailSubject, $mailMessage, $mailHeaders);
}
+
+ // Create browser cookies
+ public function createCookies($scheme, $address, $base, $email) {
+ $expire = time() + $this->yellow->system->get("editLoginSessionTimeout");
+ $authToken = $this->extension->users->createAuthToken($email, $expire);
+ $csrfToken = $this->extension->users->createCsrfToken();
+ setcookie("authtoken", $authToken, $expire, "$base/", "", $scheme=="https", true);
+ setcookie("csrftoken", $csrfToken, $expire, "$base/", "", $scheme=="https", false);
+ }
+
+ // Destroy browser cookies
+ public function destroyCookies($scheme, $address, $base) {
+ setcookie("authtoken", "", 1, "$base/", "", $scheme=="https", true);
+ setcookie("csrftoken", "", 1, "$base/", "", $scheme=="https", false);
+ }
// Change content file
public function editContentFile($page, $action) {
@@ -1559,6 +1549,16 @@ class YellowEditResponse {
}
}
+ // Normalise text lines, convert line endings
+ public function normaliseLines($text, $endOfLine = "lf") {
+ if ($endOfLine=="lf") {
+ $text = preg_replace("/\R/u", "\n", $text);
+ } else {
+ $text = preg_replace("/\R/u", "\r\n", $text);
+ }
+ return $text;
+ }
+
// Check if meta data has been modified
public function isMetaModified($pageSource, $pageOther) {
return substrb($pageSource->rawData, 0, $pageSource->metaDataOffsetBytes) !=
diff --git a/system/extensions/meta.php b/system/extensions/meta.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowMeta {
- const VERSION = "0.8.10";
+ const VERSION = "0.8.11";
const TYPE = "feature";
public $yellow; //access to API
@@ -14,26 +14,6 @@ class YellowMeta {
$this->yellow->system->setDefault("metaDefaultImage", "icon");
}
- // Handle update
- public function onUpdate($action) {
- if ($action=="update") { //TODO: remove later, converts old settings
- $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);
- $fileDataNew = preg_replace("/SocialtagsImageAlt:/i", "ImageAlt:", $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'!");
- }
- }
- }
- }
- }
-
// Handle page extra data
public function onParsePageExtra($page, $name) {
$output = null;