Various new features.

This commit is contained in:
Cody Cook 2024-04-30 19:38:37 -07:00
commit 36e6e23a68
14 changed files with 437 additions and 523 deletions

View file

@ -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;
}
}