diff options
| -rw-r--r-- | controllers/archive.php | 92 | ||||
| -rw-r--r-- | views/archive/topbar.css | 44 | ||||
| -rw-r--r-- | views/archive/topbar.php | 34 |
3 files changed, 82 insertions, 88 deletions
diff --git a/controllers/archive.php b/controllers/archive.php index 6b6098c..c1ff4a2 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -355,93 +355,10 @@ class DownloadPage { } function getArchiveTop() : array { - $content = '<?php - require_once "../../models/database.php"; - require_once "../../models/webpage.php"; - require_once "../../models/user.php"; - - function debugPrintToConsole($data) : void { - $output = $data; - if (is_array($output)) - $output = implode(",", $output); - - echo "<script>console.log(\"Debug Objects: " . $output . "\" );</script>"; - } - debugPrintToConsole("This is necessary for some reason, without it the content is not actually shown!"); - - $currentPageId = basename(__DIR__); - $currentPage = Database\Webpage::fromDBwid($currentPageId); - $requesterUsername = Database\User::fromDBuid($currentPage->RequesterUID); - - $previousPageId = Database\Webpage::getPreviousPageId($currentPage->URL, $currentPage->Date); - $nextPageId = Database\Webpage::getNextPageId($currentPage->URL, $currentPage->Date); - - echo "<div class=\"navbar\">"; - echo "<div class=\"navbar-info\">"; - echo "<span>Title: $currentPage->Title</span>"; - echo "<span>Url: $currentPage->URL</span>"; - echo "<span>Date of archival: $currentPage->Date</span>"; - echo "<span>Visits: $currentPage->Visits</span>"; - echo "<span>Requested by: $requesterUsername->Username</span>"; - - echo "<div class=\"navbar-links\">"; - if ($previousPageId != 0) { - echo "<a href=\"../$previousPageId/index.php\">Previous version</a>"; - } - if ($nextPageId != 0) { - echo "<a href=\"../$nextPageId/index.php\">Next version</a>"; - } - echo "</div>"; - echo "</div>"; - ?>'; - - $style = ' - .navbar { - display: flex; - justify-content: space-between; - align-items: center; - background-color: #343a40; - color: #ffffff; - padding: 10px; - border-bottom: 1px solid #ccc; - width: 100%; - position: fixed; - top: 0; - left: 0; - z-index: 1000; - } - - .navbar-info { - display: flex; - justify-content: center; - flex-grow: 1; - } - - .navbar-info span { - margin-right: 15px; - } - - .navbar-links { - display: flex; - gap: 20px; - } - - .navbar a { - text-decoration: none; - color: #007bff; - } - - .navbar a:hover { - text-decoration: underline; - color: #66b3ff; - } - - /* Add some margin to the body to prevent content from being hidden behind the navbar */ - body { - margin-top: 60px; - } - '; - return array($content, $style); + return array( + file_get_contents(__DIR__ . '/../views/archive/topbar.php'), + file_get_contents(__DIR__ . '/../views/archive/topbar.css') + ); } function createArchive($simular_pages) : void { @@ -467,7 +384,6 @@ class DownloadPage { // Add the header for the archives list($archive_top, $archive_top_style) = $this->getArchiveTop(); $phpTag = $dom->createElement('script', $archive_top); - $phpTag->setAttribute('type', 'text/php'); // Set the type to PHP $body = $dom->getElementsByTagName('body')->item(0); $body->appendChild($phpTag); diff --git a/views/archive/topbar.css b/views/archive/topbar.css new file mode 100644 index 0000000..21b72d8 --- /dev/null +++ b/views/archive/topbar.css @@ -0,0 +1,44 @@ +.navbar { + display: flex; + justify-content: space-between; + align-items: center; + background-color: #343a40; + color: #ffffff; + padding: 10px; + border-bottom: 1px solid #ccc; + width: 100%; + position: fixed; + top: 0; + left: 0; + z-index: 1000; +} + +.navbar-info { + display: flex; + justify-content: center; + flex-grow: 1; +} + +.navbar-info span { + margin-right: 15px; +} + +.navbar-links { + display: flex; + gap: 20px; +} + +.navbar a { + text-decoration: none; + color: #007bff; +} + +.navbar a:hover { + text-decoration: underline; + color: #66b3ff; +} + +/* Add some margin to the body to prevent content from being hidden behind the navbar */ +body { + margin-top: 60px; +} diff --git a/views/archive/topbar.php b/views/archive/topbar.php new file mode 100644 index 0000000..f521fcb --- /dev/null +++ b/views/archive/topbar.php @@ -0,0 +1,34 @@ +<!-- Dirty hack to escape all PHP dom sanitization and checks --> +</script> + +<?php + require_once "../../models/database.php"; + require_once "../../models/webpage.php"; + require_once "../../models/user.php"; + + $currentPageId = basename(__DIR__); + $currentPage = Database\Webpage::fromDBwid($currentPageId); + $requesterUsername = Database\User::fromDBuid($currentPage->RequesterUID); + + $previousPageId = Database\Webpage::getPreviousPageId($currentPage->URL, $currentPage->Date); + $nextPageId = Database\Webpage::getNextPageId($currentPage->URL, $currentPage->Date); +?> + +<div class="navbar"> + <div class="navbar-info"> + <span>Title: <?= $currentPage->Title ?></span> + <span>Url: <?= $currentPage->URL ?></span> + <span>Date of archival: <?= $currentPage->Date ?></span> + <span>Visits: <?= $currentPage->Visits ?></span> + <span>Requested by: <?= $requesterUsername->Username ?></span> + </div> + + <div class="navbar-links"> + <? if ($previousPageId != 0): ?> + <a href="<?= "../$previousPageId/index.php" ?>">Previous version</a> + <? endif; ?> + <? if ($nextPageId != 0): ?> + <a href="<?= "../$nextPageId/index.php" ?>">Next version</a> + <? endif; ?> + </div> +</div> |
