id)]); Delete::byId(Table::FEED, $feed->id); add_info('Feed “' . htmlentities($feed->title) . '” deleted successfully'); frc_redirect('/feeds'); } catch (DocumentException $ex) { add_error("$ex"); } } if ($_SERVER['REQUEST_METHOD'] == 'POST') { try { $isNew = $_POST['id'] == '-1'; if ($isNew) { $result = Feed::add($_POST['url']); } else { $feedId = (int)$_POST['id']; $toEdit = Feed::retrieveById($feedId); $result = $toEdit ? Feed::update($toEdit, $_POST['url']) : ['error' => "Feed $feedId not found"]; } if (key_exists('ok', $result)) { add_info('Feed saved successfully'); frc_redirect('/feeds'); } add_error($result['error']); $feedId = 'error'; } catch (DocumentException $ex) { add_error("$ex"); } } if ($feedId == -1) { $title = 'Add RSS Feed'; $feed = new Feed(id: -1); } else { $title = 'Edit RSS Feed'; if ($feedId == 'error') { $feed = new Feed(id: (int)$_POST['id'], url: $_POST['url'] ?? ''); } elseif (!($feed = Feed::retrieveById((int)$feedId))) not_found(); } page_head($title); ?>