nieuws: list tag options below articles for admins
[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 (!empty($User['admin'])) {
16                 $taglist = [];
17                 foreach (glob("$Page/.tags/*") as $tagpath) {
18                         $tagname = pathinfo($tagpath, PATHINFO_BASENAME);
19                         $tagvalue = file_exists("$tagpath/$year-$page.html");
20                         $tagtarget = is_writable($tagpath);
21                         $taglist[] = sprintf(
22                                 '<input type="checkbox" name="%s" value="%s" id="%s"%s%s />' .
23                                 '<label for="%2$s"> %s</label>',
24                                 "tags[$tagname]", $tagname, "tag-$tagname",
25                                 $tagvalue ? ' checked' : '',
26                                 ' onclick="return false"',
27                                 ucfirst($tagname)
28                         );
29                 }
30                 printf("<p><strong>Tags:</strong> %s</p>\n",
31                         implode("\n\t", $taglist)
32                 );
33         }
34         if ($replyform) {
35                 print placeholder_include('nieuws/replies');
36         }
37         return 1;
38 }
39
40 if ($year) {
41         ob_clean();
42         $match = $Page;
43         $title = "Nieuws";
44         if (is_numeric($year) and $year > 999) {
45                 $match .= "/$year";
46                 if (is_numeric($page)) {
47                         $title .= ' '.$monthname[intval($page)];
48                         $match .= sprintf('%02d-', $page);
49                 }
50                 $title .= ' '.$year;
51         }
52         elseif ($year === '19') {
53                 $match .= "/19??";
54                 $title .= " vóór 2000";
55         }
56         elseif (file_exists("$Page/.tags/$year")) {
57                 $match .= "/.tags/$year";
58                 $title .= " met $year";
59         }
60
61         print "<h2>$title</h2>\n\n";
62         print placeholder_include('nieuws', [$match]);
63         return 1;
64 }
65
66 if (!empty($User['admin'])) {
67         print '<script src="/nieuws/edit.js"></script>'."\n";
68 }