e949/front/pages/search_posts/gen_post_entry.php
shr3dd3r 62b7b68976 Функция поиска по постам
Мне это всё расписывать что-ли? Смотрите в содержание коммита, мне феерически индифферентно
2024-03-07 19:58:39 +03:00

58 lines
1.4 KiB
PHP

<?php
// Create entry in posts search list
// Includes
require_once("api/user/index.php");
// Create entry from post info
function GenPostEntry (array $data): string {
$userReqResp = User_GetInfoByID($data["author_id"]);
if ($userReqResp->IsError())
$userLogin = strval($data["author_id"]);
else
$userLogin = $userReqResp->GetData()["login"];
if (!is_string($data["created_at"]))
$timestamp = strval($data["created_at"]);
else
$timestamp = $data["created_at"];
$placeholderString = "ID: " . strval($data["id"]);
$placeholderString .= " | AUTHOR: $userLogin";
$placeholderString .= " | TIMESTAMP: $timestamp";
$placeholderString .= " | TAGS: " . $data["tags"];
$result = "<a class=\"entry\">\n"; // TODO: href
$result .= "<img src=\"";
if ($data["preview_path"])
$result .= $data["preview_path"];
else
$result .= $data["pic_path"];
$result .= "\" alt=\"$placeholderString\" title=\"$placeholderString\">\n";
$result .= "<div class=\"stats\">\n";
$result .= "<p><b>+</b>" . strval($data["votes_up"]);
$result .= " <b>-</b>" . strval($data["votes_down"]);
$result .= " <b>V</b> " . strval($data["views"]);
/*
if ($data["comments_enabled"]) {
$result .= " <b>C</b> " . null; // TODO: resolve comment section by id and count comments amount
}
*/
$result .= "</p>\n";
$result .= "</div>\n";
$result .= "</a>\n";
return $result;
}
?>