Add font support, start support for genres.
This commit is contained in:
parent
5fe1a21b8e
commit
9a3d58fc83
2142 changed files with 373269 additions and 29 deletions
102
classes/Genre.php
Normal file
102
classes/Genre.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
class Genre
|
||||
{
|
||||
|
||||
private $id = "" ;
|
||||
private $enabled = "";
|
||||
private $count = "";
|
||||
private $name = "";
|
||||
private $slug = "";
|
||||
private $db = "";
|
||||
|
||||
public function __construct($value, $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
if (intval($value)) {
|
||||
$this->id = $value;
|
||||
if ($this->load_by_id()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->slug = $value;
|
||||
if ($this->load_by_slug()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function load_by_id(): bool
|
||||
{
|
||||
$genre = $this->get_genre_by_id();
|
||||
if ($genre && $genre['name'] != "") {
|
||||
$this->enabled = $genre['enabled'];
|
||||
$this->count = $genre['count'];
|
||||
$this->name = $genre['name'];
|
||||
$this->slug = $genre['slug'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_genre_by_id()
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM genres WHERE id = ?");
|
||||
$stmt->bind_param("i", $this->id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$dj = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
return $dj;
|
||||
}
|
||||
|
||||
private function load_by_slug(): bool
|
||||
{
|
||||
$genre = $this->get_genre_by_slug();
|
||||
|
||||
if ($genre && $genre['name'] != "") {
|
||||
$this->id = $genre['id'];
|
||||
$this->enabled = $genre['enabled'];
|
||||
$this->count = $genre['count'];
|
||||
$this->name = $genre['name'];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function get_genre_by_slug()
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM genres WHERE slug = ?");
|
||||
$stmt->bind_param("s", $this->slug);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$dj = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
return $dj;
|
||||
}
|
||||
|
||||
public function get_slug(): string
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
public function get_id(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function get_name(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue