change addressing tags by name in query string to addressing by id

This commit is contained in:
Tomáš Mládek 2019-04-30 19:13:45 +02:00 committed by Tomáš Mládek
parent c94e1329ca
commit deb0d071bb
7 changed files with 9 additions and 10 deletions

View file

@ -10,7 +10,7 @@
<?php if ($_GET["tag"] != "*" && <?php if ($_GET["tag"] != "*" &&
$_GET["tag"] != "_"): ?> $_GET["tag"] != "_"): ?>
<div class="text doc-item doc-new-item"> <div class="text doc-item doc-new-item">
<a href="?action=new_item&tag=<?= $tag["Name"] ?>"> <a href="?action=new_item&tag=<?= $tag["ID"] ?>">
<div class="doc-item-text"> <div class="doc-item-text">
<h2>Upload a new document</h2> <h2>Upload a new document</h2>
</div> </div>

View file

@ -24,7 +24,7 @@
<ul> <ul>
<?php <?php
foreach ($tags as $tag) { foreach ($tags as $tag) {
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>"; echo '<li><a href="?tag=' . $tag['id'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
} }
?> ?>
</ul> </ul>

View file

@ -13,7 +13,7 @@
<h3 class="doc-taglist">Tags: <h3 class="doc-taglist">Tags:
<?php <?php
foreach ($doc["tags"] as $tag) { foreach ($doc["tags"] as $tag) {
echo '<li><a href="?tag=' . $tag["Name"] . "\">" . $tag["Name"] . "</a></li>"; echo '<li><a href="?tag=' . $tag["ID"] . "\">" . $tag["Name"] . "</a></li>";
} }
?> ?>
</h3> </h3>

View file

@ -25,7 +25,7 @@
<?php <?php
foreach ($tags as $tag) { foreach ($tags as $tag) {
if ($tag['count'] > 0) { if ($tag['count'] > 0) {
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>"; echo '<li><a href="?tag=' . $tag['id'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
} }
} }
?> ?>

View file

@ -51,7 +51,7 @@ class PileDB
$tags = []; $tags = [];
while ($row = $tags_ret->fetchArray(SQLITE3_NUM)) { while ($row = $tags_ret->fetchArray(SQLITE3_NUM)) {
array_push($tags, array( array_push($tags, array(
'href' => $row[0], 'id' => $row[0],
'name' => $row[1], 'name' => $row[1],
'count' => $row[2] 'count' => $row[2]
)); ));

View file

@ -114,9 +114,9 @@ if (isset($_SESSION['ID'])) {
} elseif ($_GET["tag"] == "_") { } elseif ($_GET["tag"] == "_") {
$docs = $db->listDocs(-1); $docs = $db->listDocs(-1);
} else { } else {
$tag = $db->findTag($_GET["tag"]); $tag = $db->fetchTag($_GET["tag"]);
$docs = $db->listDocs($tag["ID"]); $docs = $db->listDocs($tag["ID"]);
$doc_list_template->tag = $db->fetchTag($tag["ID"]); $doc_list_template->tag = $tag;
} }
$doc_list_template->docs = $docs; $doc_list_template->docs = $docs;
$content = $doc_list_template->render('admin_doc_listing.php'); $content = $doc_list_template->render('admin_doc_listing.php');

View file

@ -21,9 +21,8 @@ if (isset($_GET["item"])) {
} elseif ($_GET["tag"] == "_") { } elseif ($_GET["tag"] == "_") {
$docs = $db->listDocs(-1); $docs = $db->listDocs(-1);
} else { } else {
$tagObj = $db->findTag($_GET["tag"]); $tag = $db->fetchTag($_GET["tag"]);
$docs = $db->listDocs($tagObj["ID"]); $docs = $db->listDocs($tag["ID"]);
$tag = $db->fetchTag($tagObj["ID"]);
$tag["Description"] = $pd->text($tag["Description"]); $tag["Description"] = $pd->text($tag["Description"]);
$doc_list_template->tag = $tag; $doc_list_template->tag = $tag;
} }