Kaynağa Gözat

Refactored code and some cleanup

markseu 5 yıl önce
ebeveyn
işleme
0df1efec6c
2 değiştirilmiş dosya ile 27 ekleme ve 47 silme
  1. 26 26
      system/extensions/edit.php
  2. 1 21
      system/extensions/meta.php

+ 26 - 26
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) !=

+ 1 - 21
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;