mirror of
https://github.com/YGGverse/Pulsar.git
synced 2026-03-31 17:55:37 +00:00
add channel sort order
This commit is contained in:
parent
30a7f69083
commit
63ec2df6b0
2 changed files with 18 additions and 11 deletions
|
|
@ -63,6 +63,7 @@
|
||||||
{
|
{
|
||||||
"source":"https://www.omglinux.com/feed",
|
"source":"https://www.omglinux.com/feed",
|
||||||
"alias":"omglinux.gmi",
|
"alias":"omglinux.gmi",
|
||||||
|
"order":1,
|
||||||
"enabled":true,
|
"enabled":true,
|
||||||
"item":
|
"item":
|
||||||
{
|
{
|
||||||
|
|
@ -95,6 +96,7 @@
|
||||||
{
|
{
|
||||||
"source":"https://omgubuntu.co.uk/feed",
|
"source":"https://omgubuntu.co.uk/feed",
|
||||||
"alias":"omgubuntu.gmi",
|
"alias":"omgubuntu.gmi",
|
||||||
|
"order":2,
|
||||||
"enabled":false,
|
"enabled":false,
|
||||||
"item":
|
"item":
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class Database
|
||||||
?string $username = null,
|
?string $username = null,
|
||||||
?string $password = null
|
?string $password = null
|
||||||
) {
|
) {
|
||||||
|
// Init connection
|
||||||
$this->_database = new \PDO(
|
$this->_database = new \PDO(
|
||||||
sprintf(
|
sprintf(
|
||||||
'sqlite:%s',
|
'sqlite:%s',
|
||||||
|
|
@ -40,11 +41,13 @@ class Database
|
||||||
\PDO::FETCH_OBJ
|
\PDO::FETCH_OBJ
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Init structure
|
||||||
$this->_database->query('
|
$this->_database->query('
|
||||||
CREATE TABLE IF NOT EXISTS "channel"
|
CREATE TABLE IF NOT EXISTS "channel"
|
||||||
(
|
(
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
"time" INTEGER NOT NULL,
|
"time" INTEGER NOT NULL,
|
||||||
|
"order" INTEGER NOT NULL,
|
||||||
"alias" VARCHAR NOT NULL,
|
"alias" VARCHAR NOT NULL,
|
||||||
"source" TEXT NOT NULL,
|
"source" TEXT NOT NULL,
|
||||||
"link" TEXT,
|
"link" TEXT,
|
||||||
|
|
@ -90,7 +93,7 @@ class Database
|
||||||
public function getChannels(): ?array
|
public function getChannels(): ?array
|
||||||
{
|
{
|
||||||
$query = $this->_database->query(
|
$query = $this->_database->query(
|
||||||
'SELECT * FROM `channel`'
|
'SELECT * FROM `channel` ORDER BY `order` ASC, `title` ASC, `id` ASC'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result = $query->fetchAll())
|
if ($result = $query->fetchAll())
|
||||||
|
|
@ -142,17 +145,18 @@ class Database
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addChannel(
|
public function addChannel(
|
||||||
string $alias,
|
string $alias,
|
||||||
string $source,
|
string $source,
|
||||||
?string $link,
|
?string $link = null,
|
||||||
?string $title,
|
?string $title = null,
|
||||||
?string $description,
|
?string $description = null,
|
||||||
?int $time = null
|
?int $time = null,
|
||||||
|
?int $order = null
|
||||||
): ?int
|
): ?int
|
||||||
{
|
{
|
||||||
$query = $this->_database->prepare(
|
$query = $this->_database->prepare(
|
||||||
'INSERT INTO `channel` (`alias`, `source`, `link`, `title`, `description`, `time`)
|
'INSERT INTO `channel` (`alias`, `source`, `link`, `title`, `description`, `time`, `order`)
|
||||||
VALUES (:alias, :source, :link, :title, :description, :time)'
|
VALUES (:alias, :source, :link, :title, :description, :time, :order)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$query->execute(
|
$query->execute(
|
||||||
|
|
@ -162,7 +166,8 @@ class Database
|
||||||
':link' => $link,
|
':link' => $link,
|
||||||
':title' => $title,
|
':title' => $title,
|
||||||
':description' => $description,
|
':description' => $description,
|
||||||
':time' => $time ? $time : time()
|
':time' => $time ? $time : time(),
|
||||||
|
':order' => $order ? $order : 0
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -199,7 +204,7 @@ class Database
|
||||||
{
|
{
|
||||||
$query = $this->_database->query(
|
$query = $this->_database->query(
|
||||||
sprintf(
|
sprintf(
|
||||||
'SELECT * FROM `channelItem` ORDER BY `time` DESC LIMIT %d,%d',
|
'SELECT * FROM `channelItem` ORDER BY `pubTime` DESC, `time` DESC, `id` DESC LIMIT %d,%d',
|
||||||
$start,
|
$start,
|
||||||
$limit
|
$limit
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue