Add date for RSS feeds (#4)

- First cut of user message add/display
This commit is contained in:
2024-04-11 19:07:39 -04:00
parent 8ca4bf2109
commit 7d294b9be8
4 changed files with 41 additions and 17 deletions

View File

@@ -12,6 +12,17 @@ require 'user-config.php';
Data::ensureDb();
/**
* Add a message to be displayed at the top of the page
*
* @param string $level The level (type) of the message
* @param string $message The message itself
*/
function add_message(string $level, string $message): void {
if (!array_key_exists('USER_MSG', $_REQUEST)) $_REQUEST['USER_MSG'] = array();
$_REQUEST['USER_MSG'][] = ['level' => $level, 'message' => $message];
}
/**
* Render the page title
* @param string $title The title of the page being displayed
@@ -29,14 +40,19 @@ function page_head(string $title): void {
<div><?php
if (array_key_exists('FRC_USER_ID', $_REQUEST)) {
echo '<a href=/feed?id=new>Add Feed</a>';
if ($_REQUEST['FRC_USER_EMAIL'] != 'solouser@example.com') {
echo " | {$_REQUEST['FRC_USER_EMAIL']}";
}
if ($_REQUEST['FRC_USER_EMAIL'] != 'solouser@example.com') echo " | {$_REQUEST['FRC_USER_EMAIL']}";
} ?>
</div>
</header>
<main hx-target=this>
<?php
<main hx-target=this><?php
if (array_key_exists('USER_MSG', $_REQUEST)) {
foreach ($_REQUEST['USER_MSG'] as $msg) { ?>
<div>
<?=$msg['level'] == 'INFO' ? '' : "<strong>{$msg['level']}</strong><br>"?>
<?=$msg['message']?>
</div><?php
}
}
}
/**