diff options
| -rw-r--r-- | controllers/archive.php | 8 | ||||
| -rw-r--r-- | models/webpage.php | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/controllers/archive.php b/controllers/archive.php index 35ab1dd..ffe9c70 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -37,10 +37,7 @@ class DownloadPage { $page_url_pattern = $this->getCorrectLinkPattern($this->page_url); $simular_pages = Database\Webpage::getArchivePathsByPattern('%' . $page_url_pattern . '%'); if ($website_exists) { - // NOTE: This is incredibly dumb, Databas\Webpage::create returns the - // auto-incremented ID, so it should be used here. - // The logic needs to be reorganized! - $this->folder_name = Database\Webpage::getPagesCount() + 1; + $this->folder_name = Database\Webpage::create($folder_location, $this->page_url, $requester_uid, "default", "Default title"); $this->page_contents = $this->downloadFile($this->page_url); $this->createArchive($simular_pages); if (!$this->favicon_path) { @@ -48,7 +45,8 @@ class DownloadPage { // Fallback and try to download them from the server directly $this->tryDownloadFavicon(); } - Database\Webpage::create($folder_location, $this->page_url, $requester_uid, $this->favicon_path, $this->page_title); + Database\Webpage::updateNewArchive($this->folder_name, $this->favicon_path, $this->page_title); + } else { echo "Website does not exist"; } diff --git a/models/webpage.php b/models/webpage.php index 6347397..e85046f 100644 --- a/models/webpage.php +++ b/models/webpage.php @@ -35,10 +35,15 @@ class Webpage extends Table { } // TODO: remove this, refer to archive.php + // NOTE: Why remove? Let it be. Leave the thing alone static function getPagesCount() : int { return Table::_get_entries_count("Webpages"); } + static function updateNewArchive(int $WID, string $faviconPath, string $newTitle) : void { + Table::_update("Webpages", "FaviconPath = \"$faviconPath\", Title = \"$newTitle\"", "WID = $WID"); + } + static function fromDBmostVisited(int $count) : array { return Table::_get_all( 'Webpages', |
