2017-02-04 22:10:59 +01:00
|
|
|
<?php
|
|
|
|
require '_templates/Template.php';
|
2017-03-07 09:38:47 +01:00
|
|
|
require '_util/PileDB.php';
|
2018-07-31 10:59:14 +02:00
|
|
|
require '_vendor/erusev/parsedown/Parsedown.php';
|
2017-02-04 22:10:59 +01:00
|
|
|
|
2017-03-07 09:38:47 +01:00
|
|
|
$db = new PileDB();
|
2017-03-08 10:02:55 +01:00
|
|
|
$pd = new Parsedown();
|
2017-03-07 09:38:47 +01:00
|
|
|
session_start();
|
2017-02-04 22:10:59 +01:00
|
|
|
|
|
|
|
if (isset($_GET["item"])) {
|
2017-03-07 09:38:47 +01:00
|
|
|
$doc = $db->fetchDoc($_GET["item"]);
|
2017-03-08 10:02:55 +01:00
|
|
|
$doc["Description"] = $pd->text($doc["Description"]);
|
2017-02-04 22:10:59 +01:00
|
|
|
|
|
|
|
$doc_template = new Template();
|
|
|
|
$doc_template->doc = $doc;
|
|
|
|
$content = $doc_template->render('front_doc_overview.php');
|
|
|
|
} elseif (isset($_GET["tag"])) {
|
2017-03-07 09:38:47 +01:00
|
|
|
$doc_list_template = new Template();
|
2018-07-31 15:58:23 +02:00
|
|
|
if ($_GET["tag"] == "*") {
|
2017-03-07 09:38:47 +01:00
|
|
|
$docs = $db->listDocs();
|
2017-03-07 21:24:46 +01:00
|
|
|
} elseif ($_GET["tag"] == "_") {
|
|
|
|
$docs = $db->listDocs(-1);
|
2017-02-04 22:10:59 +01:00
|
|
|
} else {
|
2017-03-08 10:02:55 +01:00
|
|
|
$tagObj = $db->findTag($_GET["tag"]);
|
|
|
|
$docs = $db->listDocs($tagObj["ID"]);
|
|
|
|
$tag = $db->fetchTag($tagObj["ID"]);
|
|
|
|
$tag["Description"] = $pd->text($tag["Description"]);
|
|
|
|
$doc_list_template->tag = $tag;
|
2017-02-04 22:10:59 +01:00
|
|
|
}
|
|
|
|
$doc_list_template->docs = $docs;
|
|
|
|
$content = $doc_list_template->render('front_doc_listing.php');
|
|
|
|
} else {
|
|
|
|
$intro_template = new Template();
|
|
|
|
$content = $intro_template->render('front_intro.php');
|
|
|
|
}
|
|
|
|
|
|
|
|
$page = new Template();
|
2017-03-07 09:38:47 +01:00
|
|
|
$page->doc_count = $db->getDocCount();
|
2017-03-07 21:20:20 +01:00
|
|
|
$page->none_count = $db->getUntaggedDocCount();
|
2017-03-07 09:38:47 +01:00
|
|
|
$page->tags = $db->getTags();
|
2017-02-04 22:10:59 +01:00
|
|
|
$page->content = $content;
|
2017-03-07 09:38:47 +01:00
|
|
|
$page->logged = isset($_SESSION["ID"]);
|
2017-02-04 22:10:59 +01:00
|
|
|
echo $page->render('front_wrap.php');
|
2017-03-07 09:38:47 +01:00
|
|
|
?>
|