login/pass: error messages below page title
[minimedit.git] / nieuws / index.php
index 23cfe4f7b78a3c3ec2beb846d3332921a44d1475..1cbaf9459c488571249aa020b17e2fd83a6fee9b 100644 (file)
@@ -1,25 +1,32 @@
 <?php
-$replyform = $Page == 'melding' && !empty($User);
-@list ($year, $page) = explode('/', trim($Args, '/'));
+$replyform = $Page->handler == 'melding' && $User->login;
+@list ($year, $page) = explode('/', trim($Page->path, '/'));
 
-if ($User and $User->admin) {
-       print '<script src="/nieuws/edit.js"></script>'."\n";
+if ($Page->api) {
+       if ($Page->path) return;
+       return (new PageSearch($Page->link))->files();
+}
+
+if ($User->admin("edit {$Page->handler}")) {
+       $Page->raw = '<script src="/nieuws/edit.js"></script>'."\n" . $Page->raw;
 }
 
 if ($page and !is_numeric($page)) {
-       $edit = $User && $User->admin ? htmlspecialchars(@$_GET['edit']) : NULL;
-       $Place['title'] = $edit ?: $Article->title;
-       if ($Article->file) {
-               $Place['description'] = $Article->teaser;
+       $Page->meta['og:type'] = 'article';
+       $edit = $User->admin("edit {$Page->link}") ? htmlspecialchars(@$_GET['edit']) : NULL;
+       if ($edit) {
+               $Page->title = $edit;
+       }
+       if ($Page->dateparts) {
+               $Page->place[1] = ' <small class="date">'.showdate($Page->dateparts).'</small>';
        }
-       $Place[1] = ' <small class="date">'.$Article->date.'</small>';
-       print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
-       if ($Article->file and $Article->image) {
-               $Place['image'] = "/".$Article->thumb('600x');
+       else {
+               $Page->place[1] = '';
        }
-       if ($User and $User->admin) {
+       print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Page->raw);
+       if ($User->admin("edit {$Page->link}")) {
                $taglist = [];
-               foreach (glob("$Page/.tags/*") as $tagpath) {
+               foreach (glob("{$Page->handler}/.tags/*") as $tagpath) {
                        $tagname = pathinfo($tagpath, PATHINFO_BASENAME);
                        $tagvalue = file_exists("$tagpath/$year-$page.html");
                        $tagtarget = is_writable($tagpath);
@@ -39,14 +46,13 @@ if ($page and !is_numeric($page)) {
                }
        }
        if ($replyform) {
-               print placeholder_include('nieuws/replies');
+               print $Page->widget('reply');
        }
-       return 1;
+       return;
 }
 
 if ($year) {
-       ob_clean();
-       $match = $Page;
+       $match = $Page->handler;
        $title = "Nieuws";
        if (is_numeric($year) and $year > 999) {
                $match .= "/$year";
@@ -60,12 +66,12 @@ if ($year) {
                $match .= "/19??";
                $title .= " vóór 2000";
        }
-       elseif (file_exists("$Page/.tags/$year")) {
+       elseif (file_exists("{$Page->handler}/.tags/$year")) {
                $match .= "/.tags/$year";
                $title .= " met $year";
        }
 
        print "<h2>$title</h2>\n\n";
-       print placeholder_include('nieuws', [$match]);
-       return 1;
+       print $Page->widget('nieuws', [$match]);
+       return;
 }