From 39f5b1fce005ff0a2c3cb552c4ec5f478ab0b831 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 26 Jan 2025 22:17:55 +0200 Subject: feat: Add fromWid, addItem --- controllers/archive.php | 2 +- models/archivelist.php | 10 +++++++++- models/webpage.php | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/controllers/archive.php b/controllers/archive.php index 0941d12..6b6098c 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -370,7 +370,7 @@ class DownloadPage { debugPrintToConsole("This is necessary for some reason, without it the content is not actually shown!"); $currentPageId = basename(__DIR__); - $currentPage = Database\Webpage::getPageById($currentPageId); + $currentPage = Database\Webpage::fromDBwid($currentPageId); $requesterUsername = Database\User::fromDBuid($currentPage->RequesterUID); $previousPageId = Database\Webpage::getPreviousPageId($currentPage->URL, $currentPage->Date); diff --git a/models/archivelist.php b/models/archivelist.php index 25b75fe..09d5d86 100644 --- a/models/archivelist.php +++ b/models/archivelist.php @@ -26,8 +26,16 @@ class ArchiveList extends Table { static function allListsByUser(int $UID) : array { return Table::_get_all( 'ArchiveLists', - 'Database\ArchiveLists', + 'Database\ArchiveList', "WHERE AuthorUID = \"$UID\"" ); } + + function addItem(int $WID) { + Table::_create( + 'ArchiveListsWebpages', + '(WID, LID, Position)', + "(\"$WID\", \"$this->LID\", \"0\")" + ); + } } diff --git a/models/webpage.php b/models/webpage.php index e6d964f..ceb9cea 100644 --- a/models/webpage.php +++ b/models/webpage.php @@ -27,9 +27,9 @@ class Webpage extends Table { ); } - static function getPageById(int $id) : Webpage { + static function fromDBwid(int $WID) : Webpage { return Table::_fromDB( - "SELECT * FROM Webpages WHERE WID = \"$id\"", + "SELECT * FROM Webpages WHERE WID = \"$WID\"", "Database\Webpage" ); } -- cgit v1.2.3