Commit 41d96197 authored by Michael Ochmann's avatar Michael Ochmann
Browse files

minor fixes complementing php 8 support

parent 32cbe08a
......@@ -13,8 +13,8 @@ class BlogRoll extends \tantum\plugins\Plugin {
}
public function init() : void {
$this->utils->registerComplexPlaceholder("roleTitle", [$this, "rollTitle"]);
$this->utils->registerComplexPlaceholder("blognav", [$this, "blognav"]);
$this->utils->registerContextAwareTag("roleTitle", [$this, "rollTitle"]);
$this->utils->registerContextAwareTag("blognav", [$this, "blognav"]);
$this->middleware->use(function(\tantum\models\Page $context, string $lastResult) {
if ($this->isBlogPage($context)) {
return "blog";
......@@ -73,7 +73,7 @@ class BlogRoll extends \tantum\plugins\Plugin {
$parent = false;
if (is_numeric(\tantum\Std::getToplevelFromPath($context->path)))
$this->currentPage = \tantum\Std::getToplevelFromPath($context->path);
$this->currentPage = intval(\tantum\Std::getToplevelFromPath($context->path));
$dir = __DIR__."/../../webcontent/$context->path/..";
if (!file_exists($dir))
......
......@@ -3,14 +3,15 @@
namespace DynamicTitle;
use tantum\models\Model;
use tantum\models\Page;
use tantum\plugins\Plugin;
class DynamicTitle extends Plugin {
const DEFAULT_TITLE = "CMS";
protected function init() : void {
$this->utils->registerSimplePlaceholder("title", $this->title());
$this->utils->registerComplexPlaceholder("subtitle", [$this, "subtitle"]);
$this->utils->registerTag("title", $this->title());
$this->utils->registerContextAwareTag("subtitle", [$this, "subtitle"]);
}
private function title() : string {
......
......@@ -16,14 +16,14 @@ use tantum\plugins\Utils;
* @autor Michael Ochmann
*/
class Application {
private Utils $utils;
private PluginManager $pluginManager;
private Tree $dirTree;
private Renderer $renderer;
private Page $page;
private TemplateMiddleware $templateMiddleware;
private float $startTime;
private string $locale;
private Utils $utils;
private PluginManager $pluginManager;
private Tree $dirTree;
private Renderer $renderer;
private Page $page;
private ?TemplateMiddleware $templateMiddleware;
private float $startTime;
private string $locale;
// builds the frame and puts out the time which was needed for
public function __construct() {
......@@ -34,8 +34,9 @@ class Application {
$this->startTime = microtime(true); // sets startTime on current Time
$this->utils = new plugins\Utils();
$this->templateMiddleware = null;
$this->dirTree = new models\Tree("/".$_GET["path"], $this->retrieveMenuOrder());
$this->utils = new plugins\Utils();
$this->page = new Page($this, $_GET["path"], $this->dirTree, $this->utils);
$this->templateMiddleware = new \tantum\TemplateMiddleware($this->page);
$this->templateMiddleware->use(function(Page $context, string $lastResult) : string {
......
......@@ -19,7 +19,7 @@ namespace tantum\plugins {
return $this->placeholders;
}
public function registerSimplePlaceholder(string $identifier, mixed $value) : bool {
public function registerTag(string $identifier, mixed $value) : bool {
if (array_key_exists($identifier, $this->simplePlaceholders) || array_key_exists($identifier, $this->placeholders))
return false;
$this->simplePlaceholders[$identifier] = $value;
......@@ -27,7 +27,7 @@ namespace tantum\plugins {
return true;
}
public function registerComplexPlaceholder(string $identifier, callable $callback) : bool {
public function registerContextAwareTag(string $identifier, callable $callback) : bool {
if (array_key_exists($identifier, $this->simplePlaceholders) || array_key_exists($identifier, $this->placeholders))
return false;
$this->placeholders[$identifier] = $callback;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment