diff --git a/classes/Genres.php b/classes/Genres.php index b881859..9253186 100644 --- a/classes/Genres.php +++ b/classes/Genres.php @@ -1,53 +1,53 @@ -db = $db; - if (!$this->load_all_genres()) { - return false; - } else { - return true; - } - - } - - private function load_all_genres(): bool - { - $genres = $this->get_all_genres(); - if ($genres) { - $this->genres = $genres; - return true; - } else { - return false; - } - - - } - - public function get_all_genres($order = "ASC") - { - $stmt = $this->db->prepare("SELECT * FROM genres ORDER BY name $order"); - $stmt->execute(); - $result = $stmt->get_result(); - $genres = $result->fetch_all(MYSQLI_ASSOC); - $stmt->close(); - return $genres; - } - - public function get_nonzero_genres() - { - $stmt = $this->db->prepare("SELECT * FROM genres WHERE count > 0 ORDER BY name ASC"); - $stmt->execute(); - $result = $stmt->get_result(); - $genres = $result->fetch_all(MYSQLI_ASSOC); - $stmt->close(); - return $genres; - } +db = $db; + if (!$this->load_all_genres()) { + return false; + } else { + return true; + } + + } + + private function load_all_genres(): bool + { + $genres = $this->get_all_genres(); + if ($genres) { + $this->genres = $genres; + return true; + } else { + return false; + } + + + } + + public function get_all_genres($order = "ASC") + { + $stmt = $this->db->prepare("SELECT * FROM genres ORDER BY name $order"); + $stmt->execute(); + $result = $stmt->get_result(); + $genres = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $genres; + } + + public function get_nonzero_genres() + { + $stmt = $this->db->prepare("SELECT * FROM genres WHERE count > 0 ORDER BY name ASC"); + $stmt->execute(); + $result = $stmt->get_result(); + $genres = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $genres; + } } \ No newline at end of file diff --git a/classes/Mix.php b/classes/Mix.php index 079718d..1108d8a 100644 --- a/classes/Mix.php +++ b/classes/Mix.php @@ -1,195 +1,195 @@ -db = $db; - - if (ctype_digit((string)$value)) { - $this->id = (int)$value; - return $this->load_by_id(); - - } else { - $this->slug = $value; - return $this->load_by_slug(); - } - } - - private function load_by_id(): bool - { - $mix = $this->get_mix_by_id(); - if ($mix && $mix['name'] != "") { - return $this->build_mix($mix); - } else { - return false; - } - } - - private function get_mix_by_id() - { - $stmt = $this->db->prepare("SELECT * FROM mix WHERE id = ?"); - $stmt->bind_param("i", $this->id); - $stmt->execute(); - $result = $stmt->get_result(); - $mix = $result->fetch_assoc(); - $stmt->close(); - return $mix; - } - - private function get_mix_genres() - { - $stmt = $this->db->prepare("SELECT * FROM mix_meta WHERE attribute = 'genre' AND mix_id = ?"); - $stmt->bind_param("i", $this->id); - $stmt->execute(); - $result = $stmt->get_result(); - $genres = $result->fetch_all(MYSQLI_ASSOC); - $stmt->close(); - return $genres; - } - - private function get_playcount() - { - $stmt = $this->db->prepare("SELECT value FROM mix_meta WHERE attribute = 'playcount' AND mix_id = ?"); - $stmt->bind_param("i", $this->id); - $stmt->execute(); - $result = $stmt->get_result(); - $genres = $result->fetch_all(MYSQLI_ASSOC); - $stmt->close(); - return $genres; - } - - private function load_by_slug(): bool - { - $mix = $this->get_mix_by_slug(); - - if ($mix['title'] != "") { - return $this->build_mix($mix); - } else { - return false; - } - } - - private function get_mix_by_slug() - { - $stmt = $this->db->prepare("SELECT * FROM mix WHERE slug = ?"); - $stmt->bind_param("s", $this->slug); - $stmt->execute(); - $result = $stmt->get_result(); - $mix = $result->fetch_assoc(); - $stmt->close(); - return $mix; - } - - private function load_mix_genres() - { - $genres = $this->get_mix_genres(); - if (count($genres) == 0) { - $this->genres = []; - } else { - // iterate through the genres; add each of the rest to the array - $this->genres = []; - require_once 'Genre.php'; - foreach ($genres as $genre) { - $genre = new Genre($genre['value'], $this->db); - if ($genre->get_id() != -1) { - $this->genres[] = ['id' => $genre->get_id(), 'name' => $genre->get_name(), 'slug' => $genre->get_slug()]; - } - - } - - } - - } - public function get_img(): string - { - return $this->cover; - } - - public function get_id(): int - { - return $this->id; - } - - public function get_name(): string - { - return $this->name; - } - - public function get_slug(): string - { - return $this->slug; - } - - public function get_djs(){ - return $this->djs; - } - - /** - * @param $mix - * @return true - */ - private function build_mix($mix): bool - { - $this->id = $mix['id']; - $this->name = $mix['title']; - $this->slug = $mix['slug']; - $this->description = $mix['description']; - if (isset($mix['cover'])) { - - // is this legacy code? - // the code is legacy if it starts with /dj/, - // if it does, prefix with https://www.utahsdjs.com - if (substr($mix['cover'], 0, 5) == "/djs/") { - $mix['cover'] = substr($mix['cover'], 4); - $this->cover = "https://cdn.utahsdjs.com" . $mix['cover']; - } else { - $this->cover = $mix['cover']; - } - } - $this->url = $mix['url']; - $this->seconds = $mix['seconds']; - $this->mediaplayer = $mix['mediaplayer']; - $this->recorded = $mix['recorded']; - $this->created = $mix['created']; - $this->updated = $mix['lastupdated']; - $this->enabled = $mix['pending']; - require 'DJ.php'; - $this->djs[] = new DJ($mix['dj1'], $this->db); - if ($mix['dj2'] != null) - $this->djs[] = new DJ($mix['dj2'], $this->db); - if ($mix['dj3'] != null) - $this->djs[] = new DJ($mix['dj3'], $this->db); - - // delete any nulls from the array - $this->djs = array_filter($this->djs); - - $this->genre = $this->get_mix_genres(); - $this->playcount = $this->get_playcount(); - - - return true; - } - -} - +db = $db; + + if (ctype_digit((string)$value)) { + $this->id = (int)$value; + return $this->load_by_id(); + + } else { + $this->slug = $value; + return $this->load_by_slug(); + } + } + + private function load_by_id(): bool + { + $mix = $this->get_mix_by_id(); + if ($mix && $mix['name'] != "") { + return $this->build_mix($mix); + } else { + return false; + } + } + + private function get_mix_by_id() + { + $stmt = $this->db->prepare("SELECT * FROM mix WHERE id = ?"); + $stmt->bind_param("i", $this->id); + $stmt->execute(); + $result = $stmt->get_result(); + $mix = $result->fetch_assoc(); + $stmt->close(); + return $mix; + } + + private function get_mix_genres() + { + $stmt = $this->db->prepare("SELECT * FROM mix_meta WHERE attribute = 'genre' AND mix_id = ?"); + $stmt->bind_param("i", $this->id); + $stmt->execute(); + $result = $stmt->get_result(); + $genres = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $genres; + } + + private function get_playcount() + { + $stmt = $this->db->prepare("SELECT value FROM mix_meta WHERE attribute = 'playcount' AND mix_id = ?"); + $stmt->bind_param("i", $this->id); + $stmt->execute(); + $result = $stmt->get_result(); + $genres = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $genres; + } + + private function load_by_slug(): bool + { + $mix = $this->get_mix_by_slug(); + + if ($mix['title'] != "") { + return $this->build_mix($mix); + } else { + return false; + } + } + + private function get_mix_by_slug() + { + $stmt = $this->db->prepare("SELECT * FROM mix WHERE slug = ?"); + $stmt->bind_param("s", $this->slug); + $stmt->execute(); + $result = $stmt->get_result(); + $mix = $result->fetch_assoc(); + $stmt->close(); + return $mix; + } + + private function load_mix_genres() + { + $genres = $this->get_mix_genres(); + if (count($genres) == 0) { + $this->genres = []; + } else { + // iterate through the genres; add each of the rest to the array + $this->genres = []; + require_once 'Genre.php'; + foreach ($genres as $genre) { + $genre = new Genre($genre['value'], $this->db); + if ($genre->get_id() != -1) { + $this->genres[] = ['id' => $genre->get_id(), 'name' => $genre->get_name(), 'slug' => $genre->get_slug()]; + } + + } + + } + + } + public function get_img(): string + { + return $this->cover; + } + + public function get_id(): int + { + return $this->id; + } + + public function get_name(): string + { + return $this->name; + } + + public function get_slug(): string + { + return $this->slug; + } + + public function get_djs(){ + return $this->djs; + } + + /** + * @param $mix + * @return true + */ + private function build_mix($mix): bool + { + $this->id = $mix['id']; + $this->name = $mix['title']; + $this->slug = $mix['slug']; + $this->description = $mix['description']; + if (isset($mix['cover'])) { + + // is this legacy code? + // the code is legacy if it starts with /dj/, + // if it does, prefix with https://www.utahsdjs.com + if (substr($mix['cover'], 0, 5) == "/djs/") { + $mix['cover'] = substr($mix['cover'], 4); + $this->cover = "https://cdn.utahsdjs.com" . $mix['cover']; + } else { + $this->cover = $mix['cover']; + } + } + $this->url = $mix['url']; + $this->seconds = $mix['seconds']; + $this->mediaplayer = $mix['mediaplayer']; + $this->recorded = $mix['recorded']; + $this->created = $mix['created']; + $this->updated = $mix['lastupdated']; + $this->enabled = $mix['pending']; + require 'DJ.php'; + $this->djs[] = new DJ($mix['dj1'], $this->db); + if ($mix['dj2'] != null) + $this->djs[] = new DJ($mix['dj2'], $this->db); + if ($mix['dj3'] != null) + $this->djs[] = new DJ($mix['dj3'], $this->db); + + // delete any nulls from the array + $this->djs = array_filter($this->djs); + + $this->genre = $this->get_mix_genres(); + $this->playcount = $this->get_playcount(); + + + return true; + } + +} + diff --git a/genres.php b/genres.php index a407117..1ac9647 100644 --- a/genres.php +++ b/genres.php @@ -1,111 +1,111 @@ - - - -
- - -' . $genre['count'] . ' ' ; - if ($genre['count'] == 1) { - echo $locale['mix']; - } else { - echo $locale['mixes']; - } - echo '
'; - echo '' . $locale['view'] . ''; - echo '' . $genre['count'] . ' ' ; + if ($genre['count'] == 1) { + echo $locale['mix']; + } else { + echo $locale['mixes']; + } + echo '
'; + echo '' . $locale['view'] . ''; + echo 'get_name(); ?>
-- get_djs(); - $djCount = count($djs); - $i = 0; - foreach ($djs as $dj) { - echo "" . $dj->get_name() . ""; - if ($i < $djCount - 1) { - echo ", "; - } - $i++; - } - - - ?> - -
-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(); ?>
++ get_djs(); + $djCount = count($djs); + $i = 0; + foreach ($djs as $dj) { + echo "" . $dj->get_name() . ""; + if ($i < $djCount - 1) { + echo ", "; + } + $i++; + } + + + ?> + +
+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
+