diff options
| author | Georgi Nikolov <ggeorgi60@gmail.com> | 2025-01-25 18:31:11 +0200 |
|---|---|---|
| committer | Georgi Nikolov <ggeorgi60@gmail.com> | 2025-01-25 18:31:11 +0200 |
| commit | 9863aa1bfcf0ce9874034bfc8fff05fd428c8019 (patch) | |
| tree | 36e1e62745c64324f6451f4f10a075ecfbffc93d /controllers | |
| parent | 2a9fdd8be41ace81dfedc0c5f19f0d3c09b1e74d (diff) | |
| download | nowayforward_human-9863aa1bfcf0ce9874034bfc8fff05fd428c8019.tar nowayforward_human-9863aa1bfcf0ce9874034bfc8fff05fd428c8019.tar.gz nowayforward_human-9863aa1bfcf0ce9874034bfc8fff05fd428c8019.zip | |
Added a title field in the database
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/archive_page.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/controllers/archive_page.php b/controllers/archive_page.php index 37ce4ee..9467eab 100644 --- a/controllers/archive_page.php +++ b/controllers/archive_page.php @@ -13,6 +13,7 @@ class DownloadPage { private $page_url; private $page_contents; private $favicon_path; + private $page_title; private function debugPrintToConsole($data) : void{ $output = $data; @@ -38,7 +39,7 @@ class DownloadPage { // Fallback and try to download them from the server directly $this->tryDownloadFavicon(); } - Database\Webpage::create($folder_location, $page_url, 1, $this->favicon_path); + Database\Webpage::create($folder_location, $page_url, 1, $this->favicon_path, $this->page_title); } else { echo "Website does not exist"; } @@ -247,6 +248,14 @@ class DownloadPage { return ($code >= 200 && $code < 400); } + function updatePageTitle(&$dom) { + $titles = $dom->getElementsByTagName("title"); + if ($titles->length > 0) { + $this->page_title = $titles->item(0)->textContent; + } + } + + function createArchive($simular_pages) : void { // Creates the folder with the correct resources and the main html page in a index.html tag $dom = new DOMDocument(); @@ -262,6 +271,8 @@ class DownloadPage { $this->downloadSource($dom, $folder_path, 'script', 'src', $simular_pages); $this->downloadSource($dom, $folder_path, 'img', 'src', $simular_pages); + $this->updatePageTitle($dom); + $this->changeHyperlinkToLocal($dom, 'a', 'href'); $this->page_contents = $dom->saveHTML(); |
