mikuli.cz

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

commit 8dd44870cc145dff673dbf5d9108717f126f8af7
parent e92d5ab9733dcf6f7fa990bb61a3a4ecba4663b6
Author: markseu <mark2011@mayberg.se>
Date:   Tue,  9 Oct 2018 14:49:48 +0200

Updated loading of plugins and themes

Diffstat:
Msystem/plugins/bundle.php | 2--
Msystem/plugins/command.php | 2--
Msystem/plugins/core.php | 36+++++++++++++++++++-----------------
Msystem/plugins/edit.php | 2--
Msystem/plugins/image.php | 2--
Msystem/plugins/install-blog.zip | 0
Msystem/plugins/install-language.zip | 0
Msystem/plugins/install-wiki.zip | 0
Msystem/plugins/install.php | 3+--
Msystem/plugins/markdown.php | 3---
Msystem/plugins/update.php | 3+--
Msystem/themes/assets/flatsite.php | 2--
12 files changed, 21 insertions(+), 34 deletions(-)

diff --git a/system/plugins/bundle.php b/system/plugins/bundle.php @@ -1935,5 +1935,3 @@ class MinifyBasic extends Minify { return $this->restoreExtractedData($content); } } - -$yellow->plugins->register("bundle", "YellowBundle", YellowBundle::VERSION); diff --git a/system/plugins/command.php b/system/plugins/command.php @@ -578,5 +578,3 @@ class YellowCommand { return $statusCode; } } - -$yellow->plugins->register("command", "YellowCommand", YellowCommand::VERSION); diff --git a/system/plugins/core.php b/system/plugins/core.php @@ -4,7 +4,7 @@ // This file may be used and distributed under the terms of the public license. class YellowCore { - const VERSION = "0.7.7"; + const VERSION = "0.7.8"; public $page; //current page public $pages; //pages from file system public $files; //files from file system @@ -1468,25 +1468,26 @@ class YellowPlugins { $this->modified = max($this->modified, filemtime($entry)); global $yellow; require_once($entry); + $name = $this->yellow->lookup->normaliseName(basename($entry), true, true, true); + $this->register($name, "Yellow".ucfirst($name)); } $callback = function ($a, $b) { return $a["priority"] - $b["priority"]; }; uasort($this->plugins, $callback); foreach ($this->plugins as $key=>$value) { - $this->plugins[$key]["obj"] = new $value["plugin"]; - if (method_exists($this->plugins[$key]["obj"], "onLoad")) $this->plugins[$key]["obj"]->onLoad($yellow); + if (method_exists($this->plugins[$key]["obj"], "onLoad")) $this->plugins[$key]["obj"]->onLoad($this->yellow); } } // Register plugin - public function register($name, $plugin, $version, $priority = 0) { - if (!$this->isExisting($name)) { - if ($priority==0) $priority = count($this->plugins) + 10; + public function register($name, $plugin, $obsoleteVersion = 0, $obsoletePriority = 0) { + if (!$this->isExisting($name) && class_exists($plugin)) { $this->plugins[$name] = array(); + $this->plugins[$name]["obj"] = new $plugin; $this->plugins[$name]["plugin"] = $plugin; - $this->plugins[$name]["version"] = $version; - $this->plugins[$name]["priority"] = $priority; + $this->plugins[$name]["version"] = defined("$plugin::VERSION") ? $plugin::VERSION : 0; + $this->plugins[$name]["priority"] = defined("$plugin::PRIORITY") ? $plugin::PRIORITY : count($this->plugins) + 10; } } @@ -1537,31 +1538,32 @@ class YellowThemes { $this->modified = max($this->modified, filemtime($entry)); global $yellow; require_once($entry); + $name = $this->yellow->lookup->normaliseName(basename($entry), true, true, true); + $this->register($name, "YellowTheme".ucfirst($name)); } foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.css$/", true, false) as $entry) { if (defined("DEBUG") && DEBUG>=3) echo "YellowThemes::load file:$entry<br/>\n"; $this->modified = max($this->modified, filemtime($entry)); - $name = $this->yellow->lookup->normaliseName(basename($entry), true, true); - if (substru($name, 0, 7)!="bundle-") $this->register($name, "", ""); + $name = $this->yellow->lookup->normaliseName(basename($entry), true, true, true); + if (substru($name, 0, 7)!="bundle-") $this->register($name, "stdClass"); } $callback = function ($a, $b) { return $a["priority"] - $b["priority"]; }; uasort($this->themes, $callback); foreach ($this->themes as $key=>$value) { - $this->themes[$key]["obj"] = empty($value["theme"]) ? new stdClass : new $value["theme"]; - if (method_exists($this->themes[$key]["obj"], "onLoad")) $this->themes[$key]["obj"]->onLoad($yellow); + if (method_exists($this->themes[$key]["obj"], "onLoad")) $this->themes[$key]["obj"]->onLoad($this->yellow); } } // Register theme - public function register($name, $theme, $version, $priority = 0) { - if (!$this->isExisting($name)) { - if ($priority==0) $priority = count($this->themes) + 10; + public function register($name, $theme, $obsoleteVersion = 0, $obsoletePriority = 0) { + if (!$this->isExisting($name) && class_exists($theme)) { $this->themes[$name] = array(); + $this->themes[$name]["obj"] = new $theme; $this->themes[$name]["theme"] = $theme; - $this->themes[$name]["version"] = $version; - $this->themes[$name]["priority"] = $priority; + $this->themes[$name]["version"] = defined("$theme::VERSION") ? $theme::VERSION : 0; + $this->themes[$name]["priority"] = defined("$theme::PRIORITY") ? $theme::PRIORITY : count($this->themes) + 10; } } diff --git a/system/plugins/edit.php b/system/plugins/edit.php @@ -1775,5 +1775,3 @@ class YellowMerge { return !$conflict ? $output : null; } } - -$yellow->plugins->register("edit", "YellowEdit", YellowEdit::VERSION); diff --git a/system/plugins/image.php b/system/plugins/image.php @@ -257,5 +257,3 @@ class YellowImage { ((imagetypes()&(IMG_GIF|IMG_JPG|IMG_PNG))==(IMG_GIF|IMG_JPG|IMG_PNG)); } } - -$yellow->plugins->register("image", "YellowImage", YellowImage::VERSION); diff --git a/system/plugins/install-blog.zip b/system/plugins/install-blog.zip Binary files differ. diff --git a/system/plugins/install-language.zip b/system/plugins/install-language.zip Binary files differ. diff --git a/system/plugins/install-wiki.zip b/system/plugins/install-wiki.zip Binary files differ. diff --git a/system/plugins/install.php b/system/plugins/install.php @@ -5,6 +5,7 @@ class YellowInstall { const VERSION = "0.7.4"; + const PRIORITY = "1"; public $yellow; //access to API // Handle initialisation @@ -299,5 +300,3 @@ class YellowInstall { return $features; } } - -$yellow->plugins->register("install", "YellowInstall", YellowInstall::VERSION, 1); diff --git a/system/plugins/markdown.php b/system/plugins/markdown.php @@ -3863,6 +3863,3 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser { return $this->hashPart($output); } } - -$yellow->plugins->register("markdown", "YellowMarkdown", YellowMarkdown::VERSION); - diff --git a/system/plugins/update.php b/system/plugins/update.php @@ -5,6 +5,7 @@ class YellowUpdate { const VERSION = "0.7.22"; + const PRIORITY = "2"; public $yellow; //access to API public $updates; //number of updates @@ -632,5 +633,3 @@ class YellowUpdate { return !is_null($data[$software]); } } - -$yellow->plugins->register("update", "YellowUpdate", YellowUpdate::VERSION, 2); diff --git a/system/themes/assets/flatsite.php b/system/themes/assets/flatsite.php @@ -6,5 +6,3 @@ class YellowThemeFlatsite { const VERSION = "0.7.6"; } - -$yellow->themes->register("flatsite", "YellowThemeFlatsite", YellowThemeFlatsite::VERSION);