page: header metadata from article object
[minimedit.git] / nieuws / index.php
index ad85011716c9825248995d28d4573d12ac67a5c8..18416b32ad342377fe3a5283608b05940e76e99c 100644 (file)
@@ -1,22 +1,22 @@
 <?php
-include 'nieuws.inc.php';
-
 $replyform = $Page == 'melding' && !empty($User);
 @list ($year, $page) = explode('/', trim($Args, '/'));
 
-if (!empty($User['admin'])) {
+if ($User and $User->admin) {
        print '<script src="/nieuws/edit.js"></script>'."\n";
 }
 
 if ($page and !is_numeric($page)) {
-       $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
-       $article = new ArchiveArticle("$Page$Args.html");
-       $Place[1] = ' <small class="date">'.$article->date.'</small>';
-       print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
-       if ($article->image) {
-               $Place['image'] = "https://lijtweg.nl/".$article->thumb('600x');
+       $edit = $User && $User->admin ? htmlspecialchars(@$_GET['edit']) : NULL;
+       if ($edit) {
+               $Article->title = $edit;
+       }
+       if ($Article->file) {
+               $Place['description'] = $Article->teaser;
        }
-       if (!empty($User['admin'])) {
+       $Place[1] = ' <small class="date">'.$Article->date.'</small>';
+       print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
+       if ($User and $User->admin) {
                $taglist = [];
                foreach (glob("$Page/.tags/*") as $tagpath) {
                        $tagname = pathinfo($tagpath, PATHINFO_BASENAME);
@@ -31,9 +31,11 @@ if ($page and !is_numeric($page)) {
                                ucfirst($tagname)
                        );
                }
-               printf('<p class="tags"><strong>Tags:</strong> %s</p>'."\n",
-                       implode("\n\t", $taglist)
-               );
+               if ($taglist) {
+                       printf('<p class="tags"><strong>Tags:</strong> %s</p>'."\n",
+                               implode("\n\t", $taglist)
+                       );
+               }
        }
        if ($replyform) {
                print placeholder_include('nieuws/replies');