- $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
- print shownewsarticle($Page.$Args, FALSE, $edit);
-
- if ($replyform) {
- print '<h3>Reacties</h3>'."\n";
- $pagelink = $Page.$Args;
-
- if ($_POST) {
- try {
- @mkdir($pagelink);
- $target = $pagelink.'/'.date('YmdHis').':'.$User['name'].'.txt';
- $written = file_put_contents($target, $_POST['reply']);
- if ($written === FALSE) {
- throw new Exception('Fout bij opslaan');
- }
- $_POST['reply'] = NULL;
- }
- catch (Exception $e) {
- print '<p class=warn>Antwoord niet opgeslagen.</p>'."\n\n";
- }
+ $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">'.$Page->date.'</small>';
+ }
+ else {
+ $Page->place[1] = '';
+ }
+ print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Page->raw);
+ if ($User->admin("edit {$Page->link}")) {
+ $taglist = [];
+ foreach (glob("{$Page->handler}/.tags/*") as $tagpath) {
+ $tagname = pathinfo($tagpath, PATHINFO_BASENAME);
+ $tagvalue = file_exists("$tagpath/$year-$page.html");
+ $tagtarget = is_writable($tagpath);
+ $taglist[] = sprintf(
+ '<input type="checkbox" name="%s" value="%s" id="%s"%s%s />' .
+ '<label for="%3$s"> %s</label>',
+ "tags[$tagname]", $tagname, "tag-$tagname",
+ $tagvalue ? ' checked' : '',
+ ' disabled',
+ ucfirst($tagname)
+ );