dj_mix_hosting_software/mixshow.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

179 lines
7.7 KiB
PHP

<?php
require_once 'includes/globals.php';
require_once 'vendor/autoload.php';
use DJMixHosting\Database;
use DJMixHosting\Genre;
use DJMixHosting\Mix;
use DJMixHosting\Mixshow;
// if there's a query parameter named 'dj', load the DJ class
$db = new Database($config);
$mixshowFound = false;
if (isset($_GET['mixshow']) && $_GET['mixshow'] != "") {
$mixshow = new Mixshow($_GET['mixshow'], $db);
if ($mixshow->get_name() != "") {
$mixshowFound = true;
$title = $mixshow->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="/mixshows"><?php echo $locale['mixshows']; ?></a></li>
<li class="breadcrumb-item active"
aria-current="page"><?php
if ($mixshow && $mixshow->get_name() != "") {
echo $mixshow->get_name();
} else {
echo $locale['notfound'];
}
?></li>
</ol>
</nav>
</div>
</div>
<?php if ($mixshowFound): ?>
<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 $mixshow->get_cover(); ?>"
alt="avatar"
class="rounded-circle img-fluid" style="width: 150px;">
<h5 class="my-3"><?php echo $mixshow->get_name();
?></h5>
<?php
?>
<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['mixshowName']; ?></p>
</div>
<div class="col-sm-9">
<p class="text-muted mb-0"><?php echo $mixshow->get_name(); ?></p>
</div>
</div>
<?php
if ($mixshow->get_description() != "") {
echo box_line($locale['desc'], $mixshow->get_description());
}
echo box_line($locale['lastupdated'], $mixshow->get_updated());
?>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card mb-4">
<div class="card-body bg-body-secondary">
<?php
$mixes = $mixshow->get_mixes();
$count = 0;
foreach ($mixes as $mix) {
$output = new Mix($mix['mix_id'], $db);
$genres = $output->get_genres();
$genrelist = [];
foreach ($genres as $genre) {
$genr = new Genre($genre, $db);
$genrelist[$genr->get_slug()] = $genr->get_name();
}
echo '<div class="row">'; // Start row for each mix
// Column for mix name and link
echo '<div class="col-md">';
echo '<p class="mb-0 " >';
echo '<a href="/mix/' . $output->get_slug() . '">';
echo $output->get_name();
echo '</a>';
echo '</p>';
echo '</div>'; // End column
// Column for genres
echo '<div class="col-md ">';
echo '<p class="mb-0">';
foreach ($genrelist as $slug => $name) {
echo ' <a href="/genre/' . $slug . '">';
// ellipse the genre name if it's too long
echo '<span class="">' . $name . '</span>';
echo '</a>';
}
echo '</p>';
echo '</div>'; // End column
// Column for duration
echo '<div class="col-md">';
echo '<p class="mb-0">';
$duration = $output->get_duration();
echo $duration['t'];
echo '</p>';
echo '</div>'; // End column
// Column for date
echo '<div class="col-md">';
echo '<p class="mb-0">';
// date format should just be year
$date = $output->get_recorded();
if ($date == "") {
$date = $output->get_created();
}
echo date('Y', strtotime($date));
echo '</p>';
echo '</div>'; // End column
echo '</div>'; // End row
$count++;
// Add horizontal rule only if it's not the last mix
if ($count < count($mixes)) {
echo '<hr>';
}
}
?>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="row">
<div class="col">
<div class="alert alert-danger" role="alert">
<?php echo $locale['mixshowNotFound']; ?>
</div>
</div>
</div><?php endif; ?>
</div>
</div>
</div>
</section>
<?php require_once 'includes/footer.php'; ?>