468de280f72cfd6a6cb480269256fa9f59621901
[minimedit.git] / nieuws / index.php
1 <?php
2 include 'nieuws.inc.php';
3
4 $replyform = $Page == 'melding' && !empty($User);
5 @list ($year, $page) = explode('/', trim($Args, '/'));
6
7 if ($page and !is_numeric($page)) {
8         $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
9         $article = new ArchiveArticle("$Page$Args.html");
10         $Place[1] = ' <small class="date">'.$article->date.'</small>';
11         print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
12         if ($article->image) {
13                 $Place['image'] = "https://lijtweg.nl/".$article->thumb('600x');
14         }
15         if ($replyform) {
16                 print placeholder_include('nieuws/replies');
17         }
18         return 1;
19 }
20
21 if ($year) {
22         ob_clean();
23         $match = $Page;
24         $title = "Nieuws";
25         if (is_numeric($year) and $year > 999) {
26                 $match .= "/$year";
27                 if (is_numeric($page)) {
28                         $title .= ' '.$monthname[intval($page)];
29                         $match .= sprintf('%02d-', $page);
30                 }
31                 $title .= ' '.$year;
32         }
33         elseif ($year === '19') {
34                 $match .= "/19??";
35                 $title .= " vóór 2000";
36         }
37
38         print "<h2>$title</h2>\n\n";
39         print placeholder_include('nieuws', [$match]);
40         return 1;
41 }
42
43 $html = ob_get_clean();
44 printf('<div class="nav right"><a href="%s"%s>Feed</a></div>'."\n",
45         "/$Page/feed",
46         ' rel="alternate" title="Atom feed van nieuwsberichten" type="application/atom+xml"'
47 );
48 print $html;
49
50 print '<div id="news">'."\n\n";
51
52 foreach (array_reverse(glob("$Page/2???")) as $page) {
53         $year = basename($page, '.html');
54         printf('<h3><a href="/%s">%s</a></h3>'."\n", $page, $year);
55         printtoc($page);
56 }
57
58 if ($pages = glob("$Page/19??/*.html")) {
59         printf('<h3><a href="/%s">%s</a></h3>'."\n", "$Page/19", 'Eerder');
60         printtoc($pages);
61 }
62
63 print "</div>\n\n";
64
65 if ($replyform) {
66         print "<h3>Melding rapporteren</h3>\n";
67         $_REQUEST['subject'] = 'melding';
68         require 'contact.php';
69 ?>
70 <form method="post">
71 <p>
72         <textarea name="body" cols=60 rows=4></textarea>
73         <input type="submit" value="Versturen" />
74 </p>
75 </form>
76 <?php
77 }
78
79 if (!empty($User['admin'])) {
80         print '<script src="/nieuws/edit.js"></script>'."\n";
81 }