diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-01 10:02:14 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-01 10:28:22 +0200 |
| commit | faabc462d3080cac67687f450135a078731fb3d1 (patch) | |
| tree | b0d050b510386c3abcc48852bda16480b7c27e8e /models/webpage.php | |
| parent | 5a0d4f4a00c9162fbf773ca6b73d34354c6650fe (diff) | |
| download | nowayforward_human-faabc462d3080cac67687f450135a078731fb3d1.tar nowayforward_human-faabc462d3080cac67687f450135a078731fb3d1.tar.gz nowayforward_human-faabc462d3080cac67687f450135a078731fb3d1.zip | |
feat: Rework models methods to be more object-oriented where applicable
Diffstat (limited to 'models/webpage.php')
| -rw-r--r-- | models/webpage.php | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/models/webpage.php b/models/webpage.php index ceb9cea..6347397 100644 --- a/models/webpage.php +++ b/models/webpage.php @@ -34,37 +34,12 @@ class Webpage extends Table { ); } - static function getPreviousPageId(string $url, string $date) : int { - $foundId = Table::_get_all( - "Webpages", - "Database\Webpage", - "WHERE URL = \"$url\" && Date < \"$date\" ORDER BY Date DESC LIMIT 1", - "WID" - ); - if (count($foundId) > 0) { - return $foundId[0]->WID; - } - return 0; - } - - static function getNextPageId(string $url, string $date) : int { - $foundId = Table::_get_all( - "Webpages", - "Database\Webpage", - "WHERE URL = \"$url\" && Date > \"$date\" ORDER BY Date ASC LIMIT 1", - "WID" - ); - if (count($foundId) > 0) { - return $foundId[0]->WID; - } - return 0; - } - + // TODO: remove this, refer to archive.php static function getPagesCount() : int { return Table::_get_entries_count("Webpages"); } - static function mostVisited(int $count) : array { + static function fromDBmostVisited(int $count) : array { return Table::_get_all( 'Webpages', 'Database\Webpage', @@ -73,29 +48,51 @@ class Webpage extends Table { ); } - static function allArchives(string $URL) : array { + static function getArchivePathsByPattern(string $URLPattern) : array { return Table::_get_all( 'Webpages', 'Database\Webpage', - "WHERE URL = \"$URL\" ORDER BY Date DESC" + "WHERE URL LIKE \"$URLPattern\" ORDER BY Date DESC", + "Path, WID" ); } - static function allArchivesByUser(int $UID) : array { + function allArchives() : array { return Table::_get_all( 'Webpages', 'Database\Webpage', - "WHERE RequesterUID = \"$UID\" ORDER BY Date DESC" + "WHERE URL = \"$this->URL\" ORDER BY Date DESC" ); } - static function getArchivePathsByPattern(string $URLPattern) : array { - return Table::_get_all( - 'Webpages', - 'Database\Webpage', - "WHERE URL LIKE \"$URLPattern\" ORDER BY Date DESC", - "Path, WID" + function previousPageId() : int { + $foundId = Table::_get_all( + "Webpages", + "Database\Webpage", + "WHERE URL = \"$this->URL\" AND Date < \"$this->Date\" + ORDER BY Date DESC + LIMIT 1", + "WID" ); + if (count($foundId) > 0) { + return $foundId[0]->WID; + } + return 0; + } + + function nextPageId() : int { + $foundId = Table::_get_all( + "Webpages", + "Database\Webpage", + "WHERE URL = \"$this->URL\" AND Date > \"$this->Date\" + ORDER BY Date ASC + LIMIT 1", + "WID" + ); + if (count($foundId) > 0) { + return $foundId[0]->WID; + } + return 0; } function incrementVisits() { |
