orm to frontend connected. for a time, i'll be trying multiple solutions at once.

This commit is contained in:
2025-05-16 16:41:07 -06:00
parent 228cf1137b
commit a93c30c40f
38 changed files with 1442 additions and 2407 deletions
-49
View File
@@ -1,49 +0,0 @@
<?php
/*
* Generates cards for a given article.
*/
function article_card($article_id)
{
$article = exec_stmt('SELECT * FROM article WHERE article_id = ?', 'i', $article_id)->fetch_assoc();
$tags_results = exec_stmt('SELECT tag FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE article_id = ?', 'i', $article_id);
$tags_html = '';
if ($tags_results != null) {
$tags_html .= '<div class="tag_row">';
while ($row = $tags_results->fetch_assoc())
$tags_html .= '<a href="/articles.php?view=filter&tag=' . $row['tag'] . '" class="tag">#' . $row['tag'] . '</a>';
$tags_html .= '</div>';
}
$author = exec_stmt('SELECT user_id, username, profile_picture FROM user WHERE user_id = ?', 'i', $article['author_id'])->fetch_assoc();
$card = '
<div class="article_card">
<div class="row_space_between">
<h4>' . $article['title'] . '</h4>
<div class="card_info_box">
<div class="col-right">
<a href="user.php?view=display&user_id=' . $author['user_id'] . '">Written by: ' . $author['username'] . '</a>
<small>Published: ' . $article['published_at'] . '</small>
<small>Updated: ' . $article['updated_at'] . '</small>
</div>
<div class="card_pic_box">
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . $author['profile_picture'] . '" class="card_profile_picture">
</div>
</div>
</div>
<div class="line"></div>
<p>' . $article['excerpt'] . '</p>
<div class="row_space_between">
<a href="/articles.php?view=read&article_id=' . $article['article_id'] . '" class="button">Read More</a>
<div class="tag_box">' . $tags_html . '</div>
</div>
</div>
';
return $card;
}
+84
View File
@@ -0,0 +1,84 @@
<?php
require_once 'functions/space.php';
/*
* Generates a card for a given Space.
*
* @* @param int $space_id "Retrieves information from the database using this ID."
* @* @param int $user_id "Retrieves information from the database using this ID. Default is -1, which will limit queries to a singular Open Space."
* @* @return String $html "The HTML card component for a Space."
*/
function spaceCard(Space $space)
{
$html = '';
return $html;
}
/*
* Generates a card for a given Thought.
*
* @* @param Integer $post_id "Retrieves information from the database using this ID."
* @* @return String $html "The HTML card component for a Thought."
*/
function thoughtCard(Post $post)
{
$html = '';
return $html;
}
/*
* Generates a card for a given Moment.
*
* @* @param Integer $post_id "Retrieves information from the database using this ID."
* @* @return String $html "The HTML card component for a Moment."
*/
function momentCard(Post $post)
{
$html = '';
return $html;
}
/*
* Generates a card for a given Moment.
*
* @* @param Integer $post_id "Retrieves information from the database using this ID."
* @* @return String $html "The HTML card component for a Moment."
*/
function essayCard(Post $post)
{
$topics_html = '';
$topics_html .= '<div class="tag_row">';
$topics_html .= '<a href="/articles.php?view=filter&tag=' . $row['tag'] . '" class="tag">#' . $row['tag'] . '</a>';
$topics_html .= '</div>';
$author = exec_stmt('SELECT user_id, username, profile_picture FROM user WHERE user_id = ?', 'i', $essay['author_id'])->fetch_assoc();
$html = '
<div class="article_card">
<div class="row_space_between">
<h4>' . $essay['title'] . '</h4>
<div class="card_info_box">
<div class="col-right">
<a href="user.php?view=display&user_id=' . $author['user_id'] . '">Written by: ' . $author['username'] . '</a>
<small>Published: ' . $essay['published_at'] . '</small>
<small>Updated: ' . $essay['updated_at'] . '</small>
</div>
<div class="card_pic_box">
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . $author['profile_picture'] . '" class="card_profile_picture">
</div>
</div>
</div>
<div class="line"></div>
<p>' . $essay['excerpt'] . '</p>
<div class="row_space_between">
<a href="/articles.php?view=read&article_id=' . $essay['article_id'] . '" class="button">Read More</a>
<div class="tag_box">' . $topics_html . '</div>
</div>
</div>
';
return $html;
}
@@ -7,11 +7,11 @@
<link rel="stylesheet" href="https://nerdfonts.com/assets/css/webfont.css">
<link rel="icon" type="image/x-icon" href="data/vintagecoding-favicon.png">
<?php
if (!isset($_SESSION['theme']) || $_SESSION['theme'] == 'dark')
if (!isset($_SESSION['theme']) || $_SESSION['theme'] == 'dark')
echo '<link href="css/dark.css" rel="stylesheet" type="text/css">';
else
else
echo '<link href="css/light.css" rel="stylesheet" type="text/css">';
?>
?>
</head>
+13 -13
View File
@@ -6,20 +6,20 @@ $nav = '
<div class="site_navigation">
<ul>
<li><a href="/index.php"' . ($current_page == '/index.php' ? ' class="underline"' : '') . '>Home</a></li>
<li><a href="/articles.php?view=sort&sort=newest"' . ($current_page == '/articles.php' ? ' class="underline"' : '') . '>Articles</a></li>
<li><a href="/spaces.php?view=displaySpaces"' . ($current_page == '/spaces.php' ? ' class="underline"' : '') . '>Spaces</a></li>
';
if (isset($_SESSION['role_id']) && $_SESSION['role_id'] <= admin) {
$nav .= '
<li><a href="/admin.php?view=users"' . ($current_page == '/admin.php' ? ' class="underline"' : '') . '>Admin</a></li>
';
}
if (isset($_SESSION['user_id'])) {
$nav .= '
if (isset($_SESSION['user'])) {
$nav .= '
<li><a href="/user.php?view=display&user_id=' . $_SESSION['user_id'] . '"' . ($current_page == '/user.php' ? ' class="underline"' : '') . '>Account</a></li>
<li><a href="/todo.php?view=display"' . ($current_page == '/todo.php' ? ' class="underline"' : '') . '>Todos</a></li>
';
if ($_SESSION['user'] <= developer) {
$nav .= '
<li><a href="/admin.php?view=users"' . ($current_page == '/admin.php' ? ' class="underline"' : '') . '>Admin</a></li>
';
}
}
$nav .= '
@@ -31,9 +31,9 @@ $nav .= '
$theme_toggle = '';
if ($_SESSION['theme'] == 'dark')
$theme_toggle = 'light';
$theme_toggle = 'light';
else
$theme_toggle = 'dark';
$theme_toggle = 'dark';
$nav .= '
<button id="theme_toggle" value="' . $theme_toggle . '" name="theme"><i class="nf ' . ($theme_toggle == 'dark' ? 'nf-oct-moon' : 'nf-oct-sun') . '"></i></button>
@@ -41,11 +41,11 @@ $nav .= '
';
if (isset($_SESSION['username'])) {
$nav .= '
$nav .= '
<a href="user.php?view=logout">Log Out</a>
';
} else {
$nav .= '
$nav .= '
<a href="user.php?view=login">Login</a>
<a href="user.php?view=signup">Sign Up</a>
';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
include_once 'components/article/card.php';
include_once 'components/core/card.php';
function user_view($user_id)
{