Move list retrieve/render to class (#15)

- array_key_exists -> key_exists
This commit is contained in:
2024-05-25 23:03:39 -04:00
parent c4e85e6734
commit 210377b4da
9 changed files with 215 additions and 126 deletions

View File

@@ -16,7 +16,7 @@ session_start([
* @param string $message The message itself
*/
function add_message(string $level, string $message): void {
if (!array_key_exists(Key::USER_MSG, $_SESSION)) $_SESSION[Key::USER_MSG] = array();
if (!key_exists(Key::USER_MSG, $_SESSION)) $_SESSION[Key::USER_MSG] = array();
$_SESSION[Key::USER_MSG][] = ['level' => $level, 'message' => $message];
}
@@ -39,8 +39,7 @@ function add_info(string $message): void {
}
/** @var bool $is_htmx True if this request was initiated by htmx, false if not */
$is_htmx = array_key_exists('HTTP_HX_REQUEST', $_SERVER)
&& !array_key_exists('HTTP_HX_HISTORY_RESTORE_REQUEST', $_SERVER);
$is_htmx = key_exists('HTTP_HX_REQUEST', $_SERVER) && !key_exists('HTTP_HX_HISTORY_RESTORE_REQUEST', $_SERVER);
/**
* Render the title bar for the page
@@ -54,7 +53,7 @@ function title_bar(): void {
<header hx-target=#main hx-push-url=true>
<div><a href=/ class=title>Feed Reader Central</a><span class=version>v<?=$version?></span></div>
<div><?php
if (array_key_exists(Key::USER_ID, $_SESSION)) {
if (key_exists(Key::USER_ID, $_SESSION)) {
$db = Data::getConnection();
try {
$bookQuery = $db->prepare(<<<'SQL'