page: index method to call metadata handler
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 12 Dec 2020 14:29:24 +0000 (15:29 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 21 Dec 2020 16:46:33 +0000 (17:46 +0100)
Clean up duplicate code on login and sitemap.

article.inc.php
login/index.php
widget/linkref.php

index 2396f2be6e078e12af9d1ea2933ca25cafe6d49e..a9c6ce41195307f44c01d4e7d8ad6b0a67c6b686 100644 (file)
@@ -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;
index 2b073f03d6da4c563bfbab9639610047070ebcea..0f428ca48f95e8d70bda44ccb11eb31b4013e4a3 100644 (file)
@@ -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;
index 4e173ace79216e7d9de286cf07e65ec10a5e90a5..7f0264ae142600113d54bda5eeab8c73671a4e04 100644 (file)
@@ -1,13 +1,6 @@
 <?php
        $article = new ArchiveArticle($Page->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('<a href="%s">%s</a>', $article->link, $article->name);
        if ($article->image) {
                printf("\n\t".'<img class="right" src="/%s" />', $article->thumb('100x100'));