Skip to content

Commit

Permalink
Updated API, experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
markseuffert committed Mar 30, 2024
1 parent 07d0fcd commit f10341c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
55 changes: 53 additions & 2 deletions system/extensions/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1066,7 +1066,7 @@ public function __construct($yellow) {
// 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));
Expand Down Expand Up @@ -2014,6 +2014,33 @@ public function getDirectoryEntriesRecursive($path, $regex = "/.*/", $sort = tru
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 = "";
Expand Down Expand Up @@ -3065,6 +3092,30 @@ public function parseContent() {
}
}

// 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;
Expand Down
4 changes: 2 additions & 2 deletions system/extensions/update-available.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions system/extensions/update-current.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f10341c

Please sign in to comment.