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

204 lines
8.9 KiB
PHP

<?php
require_once 'includes/globals.php';
require_once 'vendor/autoload.php';
use DJMixHosting\Database;
use DJMixHosting\DJ;
use DJMixHosting\Genre;
use DJMixHosting\Mix;
// if there's a query parameter named 'dj', load the DJ class
$db = new Database($config);
$djFound = false;
if (isset($_GET['dj']) && $_GET['dj'] != "") {
$dj = new DJ($_GET['dj'], $db);
if ($dj->getName() != "") {
$djFound = true;
$title = $dj->getName();
}
}
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="/djs"><?php echo $locale['djs']; ?></a></li>
<li class="breadcrumb-item active"
aria-current="page"><?php
if (isset($dj)) {
if ($dj->getName() != "") {
echo $dj->getName();
} else {
echo $locale['notfound'];
}
}
?></li>
</ol>
</nav>
</div>
</div>
<?php if ($djFound): ?>
<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 $dj->getImg(); ?>"
alt="avatar"
class="rounded-circle img-fluid" style="width: 150px;">
<h5 class="my-3"><?php echo $dj->getName();
?></h5>
<?php
if ($dj->getClaimed()) {
echo '<p class="text-muted mb-1">';
echo "<i class='fa fa-user-shield' style='color: gold'>Claimed</i>";
echo "</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>
<button type="button" data-mdb-button-init data-mdb-ripple-init
class="btn btn-outline-primary ms-1"><?php echo $locale['message']; ?>
</button>
</div>
</div>
</div>
<?php
if ($dj->getSocials() != []) {
?>
<div class="card mb-4 mb-lg-0">
<div class="card-body p-0 ">
<ul class="list-group list-group-flush rounded-3">
<?php
$socials = $dj->getSocials();
foreach ($socials as $key => $value) {
echo social_line($key, $value);
}
?>
</ul>
</div>
</div>
<?php } ?>
</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['djName']; ?></p>
</div>
<div class="col-sm-9">
<p class="text-muted mb-0"><?php echo $dj->getName(); ?></p>
</div>
</div>
<?php
if ($dj->getBio() != "") {
echo box_line($locale['bio'], $dj->getBio());
}
echo box_line($locale['lastupdated'], $dj->getUpdated());
?>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card mb-4">
<div class="card-body bg-body-secondary">
<?php
$mixes = $dj->getDJMixes();
$count = 0;
foreach ($mixes as $mix) {
$output = new Mix($mix['slug'], $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 text-truncate" >';
echo '<p class="mb-0 " >';
echo '<a title="' . $output->get_name() . '" 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['djNotFound']; ?>
</div>
</div>
</div><?php endif; ?>
</div>
</div>
</div>
</section>
<?php require_once 'includes/footer.php'; ?>