mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
parent
531d4d7735
commit
3f7bb2267b
4 changed files with 16 additions and 16 deletions
|
|
@ -92,7 +92,7 @@ class Content
|
|||
);
|
||||
|
||||
// Update history in database
|
||||
$this->page->container->browser->database->renewBrowserPageHistory(
|
||||
$this->page->container->browser->database->renewHistory(
|
||||
$address->get(),
|
||||
// @TODO title
|
||||
);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Content
|
|||
{
|
||||
$this->table->data->clear();
|
||||
|
||||
if ($records = $this->container->history->browser->database->findBrowserPageHistory($filter))
|
||||
if ($records = $this->container->history->browser->database->findHistory($filter))
|
||||
{
|
||||
foreach ($records as $record)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Delete extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Na
|
|||
{
|
||||
if ($id = $this->navbar->container->content->table->getSelectedId())
|
||||
{
|
||||
$this->navbar->container->history->browser->database->deleteBrowserPageHistory(
|
||||
$this->navbar->container->history->browser->database->deleteHistory(
|
||||
$id
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Database
|
|||
);
|
||||
|
||||
$this->_database->query('
|
||||
CREATE TABLE IF NOT EXISTS "browser_page_history"
|
||||
CREATE TABLE IF NOT EXISTS "history"
|
||||
(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"time" INTEGER NOT NULL,
|
||||
|
|
@ -44,13 +44,13 @@ class Database
|
|||
');
|
||||
}
|
||||
|
||||
public function addBrowserPageHistory(
|
||||
public function addHistory(
|
||||
string $url,
|
||||
?string $title = null
|
||||
): int
|
||||
{
|
||||
$query = $this->_database->prepare(
|
||||
'INSERT INTO `browser_page_history` (`time`, `url`, `title`) VALUES (:time, :url, :title)'
|
||||
'INSERT INTO `history` (`time`, `url`, `title`) VALUES (:time, :url, :title)'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
|
|
@ -64,7 +64,7 @@ class Database
|
|||
return (int) $this->_database->lastInsertId();
|
||||
}
|
||||
|
||||
public function findBrowserPageHistory(
|
||||
public function findHistory(
|
||||
string $value = '',
|
||||
int $start = 0,
|
||||
int $limit = 1000
|
||||
|
|
@ -72,7 +72,7 @@ class Database
|
|||
{
|
||||
$query = $this->_database->prepare(
|
||||
sprintf(
|
||||
'SELECT * FROM `browser_page_history`
|
||||
'SELECT * FROM `history`
|
||||
WHERE `url` LIKE :value OR `title` LIKE :value
|
||||
ORDER BY `id` DESC
|
||||
LIMIT %d,%d',
|
||||
|
|
@ -93,13 +93,13 @@ class Database
|
|||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
public function deleteBrowserPageHistory(
|
||||
public function deleteHistory(
|
||||
int $id
|
||||
): int
|
||||
{
|
||||
$query = $this->_database->query(
|
||||
sprintf(
|
||||
'DELETE FROM `browser_page_history` WHERE `id` = %d',
|
||||
'DELETE FROM `history` WHERE `id` = %d',
|
||||
$id
|
||||
)
|
||||
);
|
||||
|
|
@ -107,13 +107,13 @@ class Database
|
|||
return $query->rowCount();
|
||||
}
|
||||
|
||||
public function cleanBrowserPageHistory(
|
||||
public function cleanHistory(
|
||||
int $timeout = 0
|
||||
): int
|
||||
{
|
||||
$query = $this->_database->query(
|
||||
sprintf(
|
||||
'DELETE FROM `browser_page_history` WHERE `time` + %d < %d',
|
||||
'DELETE FROM `history` WHERE `time` + %d < %d',
|
||||
$timeout,
|
||||
time()
|
||||
)
|
||||
|
|
@ -123,14 +123,14 @@ class Database
|
|||
return $query->rowCount();
|
||||
}
|
||||
|
||||
public function renewBrowserPageHistory(
|
||||
public function renewHistory(
|
||||
string $url,
|
||||
?string $title = null
|
||||
): void
|
||||
{
|
||||
// Find same records match URL
|
||||
$query = $this->_database->prepare(
|
||||
'SELECT * FROM `browser_page_history` WHERE `url` LIKE :url'
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :url'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
|
|
@ -142,13 +142,13 @@ class Database
|
|||
// Drop previous records
|
||||
foreach ($query->fetchAll() as $record)
|
||||
{
|
||||
$this->deleteBrowserPageHistory(
|
||||
$this->deleteHistory(
|
||||
$record->id
|
||||
);
|
||||
}
|
||||
|
||||
// Add new record
|
||||
$this->addBrowserPageHistory(
|
||||
$this->addHistory(
|
||||
$url,
|
||||
$title
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue