Rewrite some stuff

This commit is contained in:
Bruno Rybársky 2024-04-26 20:24:09 +02:00
parent c5b5cc9722
commit 154cff0372
6 changed files with 8 additions and 8 deletions

@ -273,7 +273,7 @@ async function onPageLoad() {
if ("news" === currentSite && "index" === currentPage) { if ("news" === currentSite && "index" === currentPage) {
await articleInit(); await articleInit();
} }
if ("files" === currentSite && "index" === currentPage) { if ("account" === currentSite && "files" === currentPage) {
await listFiles(); await listFiles();
} }
if ("memes" === currentSite && "create" === currentPage) { if ("memes" === currentSite && "create" === currentPage) {

@ -54,12 +54,15 @@ function renderMemeGallery(): string
// Fetch the results // Fetch the results
$memes_out = ''; $memes_out = '';
$meme_template = file_get_contents($routerConfig['template_dir'] . "meme.html");
while ($stmtlist->fetch()) { while ($stmtlist->fetch()) {
if (str_starts_with($fileType, 'image')) { if (str_starts_with($fileType, 'image')) {
$memes_out .= renderMeme($memeID, $authorID, $title, $textContent, $createdAt, $filePath, $userNickname, file_get_contents($routerConfig['template_dir'] . "meme.html")); $memes_out .= renderMeme($memeID, $authorID, $title, $textContent, $createdAt, $filePath, $userNickname, $meme_template);
} }
} }
$meme_add = isLoggedIn() ? file_get_contents($routerConfig['template_dir'] . 'meme_add.html') : '';
$meme_gallery_out = str_replace('__TEMPLATE_MEMES_HERE__', $memes_out, $meme_gallery_template); $meme_gallery_out = str_replace('__TEMPLATE_MEMES_HERE__', $memes_out, $meme_gallery_template);
$meme_gallery_out = str_replace('__TEMPLATE_MEME_ADD__', $meme_add, $meme_gallery_out);
// Close the statement // Close the statement
$stmtlist->close(); $stmtlist->close();

@ -1,5 +1,6 @@
<!--suppress HtmlUnknownTag, HtmlUnknownTag --> <!--suppress HtmlUnknownTag, HtmlUnknownTag -->
<page minimal_permission_level="2" secret="yes" page_title="Nahrať"></page> <page minimal_permission_level="2" secret="yes" page_title="Súbory"></page>
<div id="filelist"></div>
<form id="uploadForm" enctype="multipart/form-data" method="POST"> <form id="uploadForm" enctype="multipart/form-data" method="POST">
<label for="fileInput">Send this file: </label> <label for="fileInput">Send this file: </label>
<input name="userfile" type="file" id="fileInput" multiple /> <input name="userfile" type="file" id="fileInput" multiple />

@ -1,3 +0,0 @@
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
<page minimal_permission_level="2" secret="yes" page_title="Zoznam"></page>
<div id="filelist"></div>

@ -1,5 +1,3 @@
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
<page minimal_permission_level="2" secret="yes" page_title="Vytvoriť"></page>
<form id="memeAddForm"> <form id="memeAddForm">
<label for="meme_title_input">Názov meme-u: </label> <label for="meme_title_input">Názov meme-u: </label>
<input type="text" id="meme_title_input"/> <input type="text" id="meme_title_input"/>

@ -7,4 +7,5 @@
<div id="meme_gallery"> <div id="meme_gallery">
__TEMPLATE_MEMES_HERE__ __TEMPLATE_MEMES_HERE__
</div> </div>
__TEMPLATE_MEME_ADD__
</main> </main>