dj_mix_hosting_software/genre.php
Cody Cook 70c8a87e15
All checks were successful
SonarQube Scan / SonarQube Trigger (push) Successful in 30s
Changes.
2024-05-19 20:01:13 -07:00

149 lines
6.8 KiB
PHP

<?php
require_once 'includes/globals.php';
require_once 'vendor/autoload.php';
use DJMixHosting\Database;
use DJMixHosting\Genre;
use DJMixHosting\Mix;
$genre = null;
$genreFound = false;
// if there's a query parameter named 'dj', load the DJ class
$db = new Database($config);
$genreRequested = false;
if (isset($_GET['genre']) && $_GET['genre'] != "") {
$genre = new Genre($_GET['genre'], $db);
if ($genre->get_name() != "") {
$genreRequested = true;
$genreFound = true;
}
}
$title = $genre->get_name();
require_once 'includes/header.php';
?>
<section>
<div class="container py-5">
<div class="row">
<div class="col">
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item"><a href="/genres"><?php echo $locale['genres']; ?></a></li>
<li class="breadcrumb-item active"
aria-current="page"><?php
if ($genre && $genre->get_name() != "") {
echo $genre->get_name();
} else {
echo $locale['notfound'];
}
?></li>
</ol>
</nav>
</div>
</div>
<?php if ($genreFound): ?>
<div class="row">
<div class="col-lg-4">
<div class="card mb-4">
<div class="card-body bg-body-secondary text-center">
<img src="<?php echo $genre->get_img(); ?>"
alt="avatar"
class="rounded-circle img-fluid" style="width: 150px;">
<h5 class="my-3"><?php echo $genre->get_name();
?></h5>
</p>
<div class="d-flex justify-content-center mb-2">
<button type="button" data-mdb-button-init data-mdb-ripple-init
class="btn btn-primary">
<?php echo $locale['follow']; ?>
</button>
</div>
</div>
</div>
</div>
<div class="col-lg-8">
<div class="card mb-4">
<div class="card-body bg-body-secondary">
<div class="row">
<div class="col-sm-3">
<p class="mb-0"><?php echo $locale['genre']; ?></p>
</div>
<div class="col-sm-9">
<p class="text-muted mb-0"><?php echo $genre->get_name(); ?>
</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-3">
<p class="mb-0"><?php echo $locale['mix-count']; ?></p>
</div>
<div class="col-sm-9">
<p class="text-muted mb-0"><?php echo $genre->get_count(); ?>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card mb-4">
<div class="card-body bg-body-secondary">
<?php
$count = 0;
$mixes = $genre->get_mixes();
foreach ($mixes as $mix) {
$output = new Mix($mix, $db);
echo '<div class="row">';
echo '<p class="mb-0">';
echo '<a href="/mix/' . $output->get_slug() . '">';
echo $output->get_name();
echo '</a>';
echo ' &dash; ';
$djs = $output->get_djs();
$djCount = 0;
foreach ($djs as $dj) {
echo '<a href="/dj/' . $dj->getSlug() . '">';
echo $dj->getName();
echo '</a>';
$djCount++;
if ($djCount < count($djs)) {
echo ', ';
}
}
echo '</p>';
echo ' </div>';
$count++;
if ($count < count($mixes)) {
echo '<hr>';
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="row">
<div class="col">
<div class="alert alert-danger" role="alert">
<?php echo $locale['genreNotFound']; ?>
</div>
</div>
</div>
<?php endif;
?>
</div>
</section>
<?php require_once 'includes/footer.php'; ?>