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
+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;
}
+70
View File
@@ -0,0 +1,70 @@
</body>
<footer>
<?php
function get_args_from_url()
{
$args = [];
$arr = explode('&', $_SERVER['QUERY_STRING']);
foreach ($arr as $a) {
$tmp = explode('=', $a);
$key = $tmp[0];
$value = $tmp[1];
$args[$key] = $value;
}
return $args;
}
if ($_SERVER['SCRIPT_NAME'] == '/user.php') {
$args = get_args_from_url();
if (isset($args['view'])) {
if ($args['view'] == 'signup') {
echo '
<script src="js/profile_picture_cropper_modal.js"></script>
<script src="js/upload.js"></script>
';
} else if ($args['view'] == 'display') {
echo '
<script src="js/user_actions_modal.js"></script>
<script src="js/upload.js"></script>
';
}
}
} else if ($_SERVER['SCRIPT_NAME'] == '/admin.php') {
echo '
<script src="js/clickable_rows.js"></script>
';
$args = get_args_from_url();
if (isset($args['view'])) {
if ($args['view'] == 'users') {
echo '
<script src="js/upload.js"></script>
';
}
}
} else if ($_SERVER['SCRIPT_NAME'] == '/articles.php') {
$args = get_args_from_url();
if (isset($args['view'])) {
if ($args['view'] == 'compose') {
echo '
<script src="js/md_preview.js"></script>
';
}
}
} else if ($_SERVER['SCRIPT_NAME'] == '/todo.php') {
echo '<script src="js/todo.js"></script>';
}
echo '
<script src="js/override_browser_styles.js"></script>
';
?>
</footer>
</html>
+19
View File
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<link href="css/base.css" rel="stylesheet" type="text/css">
<link href="css/rewrite.css" rel="stylesheet" type="text/css">
<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')
echo '<link href="css/dark.css" rel="stylesheet" type="text/css">';
else
echo '<link href="css/light.css" rel="stylesheet" type="text/css">';
?>
</head>
<body>
<?php include 'nav.php'; ?>
+62
View File
@@ -0,0 +1,62 @@
<?php
$current_page = $_SERVER['SCRIPT_NAME'];
$nav = '
<nav>
<div class="row_space_between no_margin">
<div class="site_navigation">
<ul>
<li><a href="/index.php"' . ($current_page == '/index.php' ? ' class="underline"' : '') . '>Home</a></li>
<li><a href="/spaces.php?view=displaySpaces"' . ($current_page == '/spaces.php' ? ' class="underline"' : '') . '>Spaces</a></li>
';
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 .= '
</ul>
</div>
<div class="nav_right_hand">
<form method="post">
';
$theme_toggle = '';
if ($_SESSION['theme'] == 'dark')
$theme_toggle = 'light';
else
$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>
</form>
';
if (isset($_SESSION['username'])) {
$nav .= '
<a href="user.php?view=logout">Log Out</a>
';
} else {
$nav .= '
<a href="user.php?view=login">Login</a>
<a href="user.php?view=signup">Sign Up</a>
';
}
$nav .= '
</div>
</div>
<script src="js/nav.js" defer></script>
</nav>
';
echo $nav;