aboutsummaryrefslogtreecommitdiff
path: root/models/webpage.php
diff options
context:
space:
mode:
Diffstat (limited to 'models/webpage.php')
-rw-r--r--models/webpage.php71
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() {