aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/archivelist.php8
-rw-r--r--models/user.php16
-rw-r--r--models/webpage.php71
3 files changed, 48 insertions, 47 deletions
diff --git a/models/archivelist.php b/models/archivelist.php
index 75bee1f..779365e 100644
--- a/models/archivelist.php
+++ b/models/archivelist.php
@@ -23,14 +23,6 @@ class ArchiveList extends Table {
);
}
- static function allListsByUser(int $UID) : array {
- return Table::_get_all(
- 'ArchiveLists',
- 'Database\ArchiveList',
- "WHERE AuthorUID = \"$UID\""
- );
- }
-
function addItem(int $WID) {
Table::_create(
'ArchiveListsWebpages',
diff --git a/models/user.php b/models/user.php
index eff2c3e..04f5a83 100644
--- a/models/user.php
+++ b/models/user.php
@@ -31,7 +31,19 @@ class User extends Table {
);
}
- static function get_all() : array {
- return Table::_get_all("Users", "Database\User");
+ function archives() : array {
+ return Table::_get_all(
+ 'Webpages',
+ 'Database\Webpage',
+ "WHERE RequesterUID = \"$this->UID\" ORDER BY Date DESC"
+ );
+ }
+
+ function archiveLists() : array {
+ return Table::_get_all(
+ 'ArchiveLists',
+ 'Database\ArchiveList',
+ "WHERE AuthorUID = \"$this->UID\""
+ );
}
}
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() {