Страница с одобренными тегами

This commit is contained in:
2024-01-27 01:43:27 +03:00
parent 93a2286d46
commit 751476c4f8
5 changed files with 86 additions and 7 deletions

View File

@@ -6,11 +6,14 @@
$MARKUP_CURRENT_PAGE = "class=\"current\"";
$MARKUP_CURRENT_PAGE_LOGIN = "";
$MARKUP_CURRENT_PAGE_REGISTER = "";
$MARKUP_CURRENT_PAGE_VIEWTAGS = "";
if ($WHAT_PAGE_IS_CURRENT["login"])
$MARKUP_CURRENT_PAGE_LOGIN = $MARKUP_CURRENT_PAGE;
if ($WHAT_PAGE_IS_CURRENT["register"])
elseif ($WHAT_PAGE_IS_CURRENT["register"])
$MARKUP_CURRENT_PAGE_REGISTER = $MARKUP_CURRENT_PAGE;
elseif ($WHAT_PAGE_IS_CURRENT["view_tags"])
$MARKUP_CURRENT_PAGE_VIEWTAGS = $MARKUP_CURRENT_PAGE;
@@ -33,7 +36,7 @@ if ($WHAT_PAGE_IS_CURRENT["register"])
<p><a title="A paginated list of every post" href="./?do=search_posts">Posts</p></a>
</li>
<span>|</span>
<li>
<li <?php echo $MARKUP_CURRENT_PAGE_VIEWTAGS; ?>>
<p><a title="A paginated list of every tag" href="./?do=view_tags">Tags</p></a>
</li>
<span>|</span>

View File

@@ -0,0 +1,62 @@
<?php
// Approved tags list
// Includes
require_once("api/_config.php");
require_once("api/user/index.php");
require_once("api/tags/index.php");
require_once("front/pages/main_nav.php");
require_once("front/notifications.php");
$TAGS_NEED_TO_BE_FILTERED = false;
if (isset($_GET["s"])) {
if (strlen($_GET["s"]) > 0 && strlen($_GET["s"]) < $Config["posting"]["tags"]["max_single_length"])
$TAGS_NEED_TO_BE_FILTERED = true;
}
$result = Tags_GetListOfApproved_Method();
if ($result->IsError())
NTFY_AddNotice("Error occured while trying to get tags list:<br>" . $result->GetError(), "fail");
NTFY_EchoAllNotices();
?>
<div class="visualbox">
<h1>Approved tags list</h1>
<?php
if ($TAGS_NEED_TO_BE_FILTERED)
echo "<p style=\"margin-bottom: 15px;\"><b>Search term:</b> " . $_GET["s"] . "</p>\n";
$cachedAuthorsInfo = array();
if (!$result->GetData()) {
echo "<h2 style=\"color: gray; font-style: italic;\">Nothing here yet</h2>";
} else {
foreach ($result->GetData() as $tagInfo) {
if ($TAGS_NEED_TO_BE_FILTERED && !str_contains($tagInfo["value"], $_GET["s"]))
continue;
echo "<div style=\"display: inline-block; margin-right: 20px; margin-bottom: 10px;\">\n";
echo "<p>" . $tagInfo["value"] . "</p>\n";
echo "<p style=\"font-size: 70%\">Added by: ";
$aid = $tagInfo["author_id"];
if (!isset($cachedAuthorsInfo[$aid])) {
$uinfo = User_GetInfoByID($aid);
if ($uinfo->IsError()) { // Seems like no such user id
$cachedAuthorsInfo[$aid] = strval($aid) . " <i>(user deleted)</i>";
} else {
$cachedAuthorsInfo[$aid] = "<a href=\"./?do=user_info&id=" . strval($aid) . "\">" . $uinfo->GetData()["login"] . "</a>";
}
}
echo $cachedAuthorsInfo[$aid];
echo "</p>\n</div>\n";
}
}
?>
</div>