From 1d0e94b9030f08157198b6e4911491698e9d2f5f Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 12 Dec 2020 15:29:24 +0100 Subject: [PATCH] page: index method to call metadata handler Clean up duplicate code on login and sitemap. --- article.inc.php | 12 ++++++++++++ login/index.php | 12 +----------- widget/linkref.php | 9 +-------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/article.inc.php b/article.inc.php index 2396f2b..a9c6ce4 100644 --- a/article.inc.php +++ b/article.inc.php @@ -65,6 +65,18 @@ class ArchiveArticle return; } + function index() + { + $this->handler; + if (empty($this->handler)) { + return; + } + $User = NULL; + $Page = $this; + $res = include "./{$this->handler}/index.php"; + return $res; + } + function restricted() { $this->handler; diff --git a/login/index.php b/login/index.php index 2b073f0..0f428ca 100644 --- a/login/index.php +++ b/login/index.php @@ -42,17 +42,7 @@ if (!$User or !$User->login) { if (empty($message)) http_response_code(403); $target = ltrim($_REQUEST['goto'], '/'); $target = new ArchiveArticle("$target.html"); - - if ($target and $target->handler) { - # run forbidden handler to determine metadata - $User = NULL; - $caller = $Page; - $Page = $target; - ob_start(); - include "./{$target->handler}/index.php"; - ob_end_clean(); - $Page = $caller; - } + $target->index; # run forbidden handler to determine metadata if ($target->title) { $Page->title .= ' voor ' . $target->title; diff --git a/widget/linkref.php b/widget/linkref.php index 4e173ac..7f0264a 100644 --- a/widget/linkref.php +++ b/widget/linkref.php @@ -1,13 +1,6 @@ place[0]); - if ($article->handler) { - $Page = $article; - $User = NULL; - ob_start(); - include "./{$article->handler}/index.php"; - ob_end_clean(); - $article = $Page; - } + $article->index; # apply handler metadata printf('%s', $article->link, $article->name); if ($article->image) { printf("\n\t".'', $article->thumb('100x100')); -- 2.30.0