diff --git a/classes/DJ.php b/classes/DJ.php index 56514fe..dc17038 100644 --- a/classes/DJ.php +++ b/classes/DJ.php @@ -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; diff --git a/classes/DJs.php b/classes/DJs.php new file mode 100644 index 0000000..636238e --- /dev/null +++ b/classes/DJs.php @@ -0,0 +1,51 @@ +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; + } +} \ No newline at end of file diff --git a/classes/Mix.php b/classes/Mix.php index 1108d8a..0c34416 100644 --- a/classes/Mix.php +++ b/classes/Mix.php @@ -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; + } + } diff --git a/dj.php b/dj.php index f4af77c..6fddd5a 100644 --- a/dj.php +++ b/dj.php @@ -1,14 +1,6 @@ - - -
- - - -$value -
-Full Name
+Johnatan Smith
-example@example.com
-Phone
-(097) 234-5678
-Mobile
-(098) 765-4321
-Address
-Bay Area, San Francisco, CA
-assigment Project - Status -
-Web Design
-Website Markup
-One Page
-Mobile Template
-Backend API
-assigment Project - Status -
-Web Design
-Website Markup
-One Page
-Mobile Template
-Backend API
-get_name(); ?>
' . $genre['count'] . ' '; - if ($genre['count'] == 1) { - echo $locale['mix']; - } else { - echo $locale['mixes']; - } - echo '
'; + card_output($count, $genre, $locale); echo '' . $locale['view'] . ''; echo '