Various new features.
This commit is contained in:
parent
ad68f515e0
commit
36e6e23a68
14 changed files with 437 additions and 523 deletions
|
@ -16,7 +16,7 @@ class DJ
|
|||
private string $created = "";
|
||||
private string $updated = "";
|
||||
private string $claimed_by = "";
|
||||
private $db = null;
|
||||
private mysqli $db;
|
||||
|
||||
|
||||
public function __construct($value, $db)
|
||||
|
@ -125,8 +125,8 @@ class DJ
|
|||
if (isset($dj['created'])) {
|
||||
$this->created = $dj['created'];
|
||||
}
|
||||
if (isset($dj['updated'])) {
|
||||
$this->updated = $dj['updated'];
|
||||
if (isset($dj['lastupdated'])) {
|
||||
$this->updated = $dj['lastupdated'];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
51
classes/DJs.php
Normal file
51
classes/DJs.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
class DJs
|
||||
{
|
||||
|
||||
private $db;
|
||||
private $djs = [];
|
||||
|
||||
public function __construct($db)
|
||||
{
|
||||
|
||||
$this->db = $db;
|
||||
if (!$this->load_all_djs()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function load_all_djs(): bool
|
||||
{
|
||||
$djs = $this->get_all_djs();
|
||||
if ($djs) {
|
||||
$this->djs = $djs;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_all_djs($order = "ASC")
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM djs ORDER BY name $order");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$djs = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
return $djs;
|
||||
}
|
||||
|
||||
public function get_nonzero_djs($order = "ASC")
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM djs WHERE count > 0 ORDER BY name $order");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$djs = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
return $djs;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ class Mix
|
|||
private $created;
|
||||
private $updated;
|
||||
private $playcount = 0;
|
||||
private $tracklist = [];
|
||||
|
||||
|
||||
public function __construct($value, $db)
|
||||
|
@ -121,6 +122,34 @@ class Mix
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private function evaluate_tracklist(): array
|
||||
{
|
||||
if (empty($this->tracklist)){
|
||||
return [];
|
||||
} else {
|
||||
// if the first item in the array is also an array, then return it
|
||||
if (is_array($this->tracklist[0]['value'])){
|
||||
|
||||
return $this->tracklist[0]['value'];
|
||||
} else {
|
||||
return explode("\n", $this->tracklist[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function load_mix_tracklist()
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT value FROM mix_meta WHERE attribute = 'tracklist' AND mix_id = ?");
|
||||
$stmt->bind_param("i", $this->id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$tracklist = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
return $tracklist;
|
||||
}
|
||||
|
||||
public function get_img(): string
|
||||
{
|
||||
return $this->cover;
|
||||
|
@ -186,10 +215,21 @@ class Mix
|
|||
|
||||
$this->genre = $this->get_mix_genres();
|
||||
$this->playcount = $this->get_playcount();
|
||||
|
||||
$this->tracklist = $this->load_mix_tracklist();
|
||||
$this->tracklist = $this->evaluate_tracklist();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_description()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function get_tracklist(): array
|
||||
{
|
||||
return $this->tracklist;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue