Browse Source

Updated API, experimental

markseu 1 year ago
parent
commit
f10341ccc8

+ 53 - 2
system/extensions/core.php

@@ -2,7 +2,7 @@
 // Core extension, https://github.com/annaesvensson/yellow-core
 
 class YellowCore {
-    const VERSION = "0.8.127";
+    const VERSION = "0.8.128";
     const RELEASE = "0.8.23";
     public $content;        // content files
     public $media;          // media files
@@ -1066,7 +1066,7 @@ class YellowExtension {
     // Load extensions
     public function load($path) {
         foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.php$/", true, false) as $entry) {
-            $this->modified = max($this->modified, filemtime($entry));
+            $this->modified = max($this->modified, $this->yellow->toolbox->getFileModified($entry));
             require_once($entry);
             $name = $this->yellow->lookup->normaliseName(basename($entry), true, true);
             $this->register(lcfirst($name), "Yellow".ucfirst($name));
@@ -2014,6 +2014,33 @@ class YellowToolbox {
         return $entries;
     }
     
+    // Return directory information recursively, Unix time and file count
+    public function getDirectoryInformationRecursive($path, $levelMax = 0) {
+        --$levelMax;
+        $modified = $fileCount = 0;
+        $directoryHandle = @opendir($path);
+        if ($directoryHandle) {
+            $path = rtrim($path, "/");
+            while (($entry = readdir($directoryHandle))!==false) {
+                if (substru($entry, 0, 1)==".") continue;
+                $modified = max($modified, $this->getFileModified("$path/$entry"));
+                if (is_file("$path/$entry")) ++$fileCount;
+            }
+            rewinddir($directoryHandle);
+            if ($levelMax!=0) {
+                while (($entry = readdir($directoryHandle))!==false) {
+                    if (substru($entry, 0, 1)==".") continue;
+                    if (is_dir("$path/$entry")) {
+                        list($modifiedBelow, $fileCountBelow) = $this->getDirectoryInformationRecursive("$path/$entry", $levelMax);
+                        $modified = max($modified, $modifiedBelow);
+                        $fileCount += $fileCountBelow;
+                    }
+                }
+            }
+        }
+        return array($modified, $fileCount);
+    }
+    
     // Read file, empty string if not found
     public function readFile($fileName, $sizeMax = 0) {
         $fileData = "";
@@ -3065,6 +3092,30 @@ class YellowPage {
         }
     }
     
+    // Parse page content element, experimental
+    public function parseContentElement($name, $text, $attrributes, $type) {
+        $output = null;
+        foreach ($this->yellow->extension->data as $key=>$value) {
+            if (method_exists($value["object"], "onParseContentElement")) {
+                $output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type);
+                if (!is_null($output)) break;
+            }
+            if (method_exists($value["object"], "onParseContentShortcut")) {
+                $output = $value["object"]->onParseContentShortcut($this, $name, $text, $type);
+                if (!is_null($output)) break;
+            }
+        }
+        if (is_null($output)) {
+            if ($name=="yellow" && $type=="inline" && $text=="error") {
+                $output = $this->errorMessage;
+            }
+        }
+        if ($this->yellow->system->get("coreDebugMode")>=3 && !is_string_empty($name)) {
+            echo "YellowPage::parseContentElement name:$name type:$type<br/>\n";
+        }
+        return $output;
+    }
+    
     // Parse page content shortcut
     public function parseContentShortcut($name, $text, $type) {
         $output = null;

+ 2 - 2
system/extensions/update-available.ini

@@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
 system/themes/copenhagen.png: copenhagen.png, create
 
 Extension: Core
-Version: 0.8.127
+Version: 0.8.128
 Description: Core functionality of your website.
 Developer: Anna Svensson
 Tag: feature
 DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
 DocumentationUrl: https://github.com/annaesvensson/yellow-core
 DocumentationLanguage: en, de, sv
-Published: 2024-03-29 20:32:14
+Published: 2024-03-30 17:29:58
 Status: available
 system/extensions/core.php: core.php, create, update
 system/layouts/default.html: default.html, create, update, careful

+ 2 - 2
system/extensions/update-current.ini

@@ -1,14 +1,14 @@
 # Datenstrom Yellow update settings for installed extensions
 
 Extension: Core
-Version: 0.8.127
+Version: 0.8.128
 Description: Core functionality of your website.
 Developer: Anna Svensson
 Tag: feature
 DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
 DocumentationUrl: https://github.com/annaesvensson/yellow-core
 DocumentationLanguage: en, de, sv
-Published: 2024-03-29 20:32:14
+Published: 2024-03-30 17:29:58
 Status: available
 system/extensions/core.php: core.php, create, update
 system/layouts/default.html: default.html, create, update, careful