This commit is contained in:
Cody Cook 2024-04-30 02:10:17 -07:00
commit 27373f0c61
16 changed files with 345 additions and 52 deletions

16
dj.php
View file

@ -9,8 +9,7 @@ require_once 'classes/DJ.php';
use Yosymfony\Toml\Toml;
$config = Toml::ParseFile('includes/config.toml');
$lang = $_SESSION['lang'] ?? $config['app']['locale'];
$locale = loadLocale($lang);
require_once 'includes/lang_loader.php';
// if there's a query parameter named 'dj', load the DJ class
$db = new Database($config);
$djFound = false;
@ -24,15 +23,10 @@ if (isset($_GET['dj']) && $_GET['dj'] != "") {
?>
<!doctype html >
<html lang="en">
<html lang="<?php echo $lang?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['app']['name']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fontawesome/css/all.css" rel="stylesheet"/>
<?php require_once 'header.php';
?>
</head>
<body style="background-color: #eee;">
<?php require 'navbar.php'; ?>
@ -309,6 +303,6 @@ if (isset($_GET['dj']) && $_GET['dj'] != "") {
</div>
</section>
<?php require 'footer.php'; ?>
</body>
</html>

1
footer.php Normal file
View file

@ -0,0 +1 @@
<script src="js/bootstrap.bundle.min.js"></script>

View file

@ -5,13 +5,12 @@ require_once 'vendor/autoload.php';
require_once 'functions/i18n.php';
require_once 'classes/Database.php';
require_once 'classes/Genre.php';
ob_start();
use Yosymfony\Toml\Toml;
$config = Toml::ParseFile('includes/config.toml');
$lang = $_SESSION['lang'] ?? $config['app']['locale'];
$locale = loadLocale($lang);
$genre= null;
require_once 'includes/lang_loader.php';$genre= null;
$genreFound = false;
// if there's a query parameter named 'dj', load the DJ class
$db = new Database($config);
@ -27,15 +26,10 @@ if (isset($_GET['genre']) && $_GET['genre'] != "") {
?>
<!doctype html >
<html lang="en">
<html lang="<?php echo $lang?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['app']['name']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fontawesome/css/all.css" rel="stylesheet"/>
<?php require_once 'header.php';
?>
</head>
<body style="background-color: #eee;">
<?php require 'navbar.php'; ?>
@ -198,6 +192,6 @@ if (isset($_GET['genre']) && $_GET['genre'] != "") {
</div>
</section>
<?php require 'footer.php'; ?>
</body>
</html>

5
header.php Normal file
View file

@ -0,0 +1,5 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['app']['name']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fontawesome/css/all.css" rel="stylesheet"/>

12
includes/lang_loader.php Normal file
View file

@ -0,0 +1,12 @@
<?php
$lang = $_SESSION['lang'] ?? $config['app']['locale'];
if (!isset($_SESSION['lang'])){
$_SESSION['lang'] = $lang;
}
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
$_SESSION['lang'] = $lang;
}
$locale = loadLocale($lang);

View file

@ -3,25 +3,18 @@
// read toml config file
require_once 'vendor/autoload.php';
require_once 'functions/i18n.php';
ob_start();
use Yosymfony\Toml\Toml;
$config = Toml::ParseFile('includes/config.toml');
$lang = $_SESSION['lang'] ?? $config['app']['locale'];
$locale = loadLocale($lang);
require_once 'includes/lang_loader.php';
?>
<html lang="en">
<html lang="<?php echo $lang ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['app']['name']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fontawesome/css/all.css" rel="stylesheet"/>
<?php require_once 'header.php';
?>
</head>
<body style="background-color: #eee;">
<?php require 'navbar.php'; ?>
@ -38,6 +31,6 @@ $locale = loadLocale($lang);
</div>
</div>
</section>
<script src="js/bootstrap.bundle.min.js"></script>
<?php require 'footer.php'; ?>
</body>
</html>

37
locale/de_DE/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Willkommen auf unserer Website!',
'description' => 'Dies ist eine Beschreibung auf Englisch.',
'userProfile' => "Benutzerprofil",
'user' => 'Benutzer',
'home' => 'Zuhause',
'djName' => 'DJ-Name',
'email' => 'E-Mail',
'location' => 'Standort',
'bio' => 'Bio',
'submit' => 'Absenden',
'login' => 'Anmelden',
'message' => 'Nachricht',
'follow' => 'Folgen',
'djs' => 'DJs',
"djNotFound" => "DJ konnte nicht geladen werden. Entweder wurde der DJ nicht gefunden oder dieser DJ ist privat.",
"notfound" => "Seite nicht gefunden",
"genre" => "Genre",
"genres" => "Genres",
"genreNotFound" => "Genre konnte nicht geladen werden; entweder wurde das Genre nicht gefunden, war leer oder dieses Genre ist privat.",
"mix-count" => "Mix-Anzahl",
"mixes" => "Mischungen",
"mix" => "Mix",
"mixNotFound" => "Mix konnte nicht geladen werden; entweder wurde der Mix nicht gefunden, war leer oder dieser Mix ist privat.",
"mixName" => "Mix-Name",
"mixDescription" => "Mix-Beschreibung",
"mixLength" => "Mix-Länge",
"mixGenre" => "Genre mischen",
"view" => "Ansicht",
"mixname" => "Mix-Name",
"search" => "Suchen",
"searchResults" => "Suchergebnisse",
"searchResultsFor" => "Suchergebnisse für",
"searchResultsFound" => "Suchergebnisse gefunden",
];

View file

@ -29,5 +29,9 @@ return [
"mixGenre" => "Mix Genre",
"view" => "View",
"mixname" => "Mix Name",
"search" => "Search",
"searchResults" => "Search Results",
"searchResultsFor" => "Search Results for",
"searchResultsFound" => "Search Results Found",
];

37
locale/es_ES/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => '¡Bienvenido a nuestro sitio web!',
'description' => 'This is a description in Spanish.',
'userProfile' => "Perfil de usuario",
'user' => 'Usuario',
'home' => 'Inicio',
'djName' => 'Nombre DJ',
'email' => 'E-mail',
'location' => 'Ubicación',
'bio' => 'Bio',
'submit' => 'Enviar',
'login' => 'Ingresar',
'message' => 'Mensaje',
'follow' => 'Seguir',
'djs' => 'DJs',
"djNotFound" => "No se pudo cargar el DJ; o el DJ no se encontró o este DJ es privado.",
"notfound" => "Página no encontrada",
"genre" => "Género",
"genres" => "Genres",
"genreNotFound" => "No se pudo cargar el género; o el género no fue encontrado, estaba vacío, o este género es privado.",
"mix-count" => "Conteo Mix",
"mixes" => "Mezclas",
"mix" => "Mezcla",
"mixNotFound" => "No se pudo cargar la mezcla; o bien la mezcla no fue encontrada, estaba vacía, o esta mezcla es privada.",
"mixName" => "Mezclar nombre",
"mixDescription" => "Mezclar descripción",
"mixLength" => "Mezclar longitud",
"mixGenre" => "Mezclar género",
"view" => "Ver",
"mixname" => "Mezclar nombre",
"search" => "Buscar",
"searchResults" => "Resultados de búsqueda",
"searchResultsFor" => "Resultados de búsqueda para",
"searchResultsFound" => "Resultados de búsqueda encontrados",
];

View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Maligayang pagdating sa aming website!',
'description' => 'Ito ay isang paglalarawan sa Tagalog.',
'userProfile' => "User Profile",
'user' => 'User',
'home' => 'Home',
'djName' => 'DJ Name',
'email' => 'Email',
'location' => 'Location',
'bio' => 'Bio',
'submit' => 'Submit',
'login' => 'Login',
'message' => 'Message',
'follow' => 'Follow',
'djs' => 'DJs',
"djNotFound" => "Could not load DJ; either the DJ wasn't found or this DJ is private.",
"notfound" => "Page not found",
"genre" => "Genre",
"genres" => "Genres",
"genreNotFound" => "Could not load genre; either the genre wasn't found, was empty, or this genre is private.",
"mix-count" => "Mix Count",
"mixes" => "Mixes",
"mix" => "Mix",
"mixNotFound" => "Could not load mix; either the mix wasn't found, was empty, or this mix is private.",
"mixName" => "Mix Name",
"mixDescription" => "Mix Description",
"mixLength" => "Mix Length",
"mixGenre" => "Mix Genre",
"view" => "View",
"mixname" => "Mix Name",
"search" => "Search",
"searchResults" => "Search Results",
"searchResultsFor" => "Search Results for",
"searchResultsFound" => "Search Results Found",
];

37
locale/fr_FR/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Bienvenue sur notre site Web!',
'description' => 'This is a description in English.',
'userProfile' => "Profil de l'utilisateur",
'user' => 'Utilisateur',
'home' => 'Domicile',
'djName' => 'Nom du DJ',
'email' => 'Courriel',
'location' => 'Localisation',
'bio' => 'Bio',
'submit' => 'Soumettre',
'login' => 'Se connecter',
'message' => 'Message',
'follow' => 'Suivre',
'djs' => 'DJs',
"djNotFound" => "Impossible de charger le DJ; soit le DJ n'a pas été trouvé, soit ce DJ est privé.",
"notfound" => "Page introuvable",
"genre" => "Genre",
"genres" => "Genres",
"genreNotFound" => "Impossible de charger le genre, soit le genre n'a pas été trouvé, soit ce genre est privé.",
"mix-count" => "Nombre de mixages",
"mixes" => "Mixes",
"mix" => "Mélanger",
"mixNotFound" => "Impossible de charger le mixage; soit le mixage n'a pas été trouvé, soit le mixage est vide, soit ce mixage est privé.",
"mixName" => "Nom du mixage",
"mixDescription" => "Description du mixage",
"mixLength" => "Longueur du mixage",
"mixGenre" => "Mélanger le genre",
"view" => "Voir",
"mixname" => "Nom du mixage",
"search" => "Chercher",
"searchResults" => "Résultats de recherche",
"searchResultsFor" => "Résultats de recherche pour",
"searchResultsFound" => "Résultats de recherche trouvés",
];

37
locale/it_IT/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Benvenuto nel nostro sito Web!',
'description' => 'Questa è una descrizione in inglese.',
'userProfile' => "Profilo Utente",
'user' => 'Utente',
'home' => 'Home',
'djName' => 'Nome DJ',
'email' => 'Email',
'location' => 'Posizione',
'bio' => 'Bio',
'submit' => 'Invia',
'login' => 'Accedi',
'message' => 'Messaggio',
'follow' => 'Segui',
'djs' => 'DJ',
"djNotFound" => "Impossibile caricare DJ; o il DJ non è stato trovato o questo DJ è privato.",
"notfound" => "Pagina non trovata",
"genre" => "Genere",
"genres" => "Genres",
"genreNotFound" => "Impossibile caricare il genere; o il genere non è stato trovato, è vuoto, o questo genere è privato.",
"mix-count" => "Conteggio Mix",
"mixes" => "Miscele",
"mix" => "Miscela",
"mixNotFound" => "Impossibile caricare il mix; o il mix non è stato trovato, è vuoto, o questo mix è privato.",
"mixName" => "Nome Mix",
"mixDescription" => "Descrizione Mix",
"mixLength" => "Miscela Lunghezza",
"mixGenre" => "Miscelare Genere",
"view" => "Visualizza",
"mixname" => "Nome Mix",
"search" => "Cerca",
"searchResults" => "Risultati Della Ricerca",
"searchResultsFor" => "Risultati della ricerca per",
"searchResultsFound" => "Risultati Di Ricerca Trovati",
];

37
locale/ru_RU/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Добро пожаловать на наш сайт!',
'description' => 'Это описание на английском языке.',
'userProfile' => "Профиль пользователя",
'user' => 'Пользователь',
'home' => 'Домашний',
'djName' => 'Имя DJ',
'email' => 'Почта',
'location' => 'Местоположение',
'bio' => 'Био',
'submit' => 'Отправить',
'login' => 'Логин',
'message' => 'Сообщение',
'follow' => 'Подписаться',
'djs' => 'DJ',
"djNotFound" => "Не удалось загрузить DJ; либо DJ не найден или этот DJ является приватным.",
"notfound" => "Страница не найдена",
"genre" => "Жанр",
"genres" => "Жанры",
"genreNotFound" => "Не удалось загрузить жанр; либо жанр не найден, был пуст, или этот жанр является приватным.",
"mix-count" => "Кол-во миксов",
"mixes" => "Миксы",
"mix" => "Микс",
"mixNotFound" => "Не удалось загрузить смесь; либо смесь не найдена, либо эта смесь является приватной.",
"mixName" => "Название микса",
"mixDescription" => "Описание смеси",
"mixLength" => "Длина микса",
"mixGenre" => "Смешанный жанр",
"view" => "Вид",
"mixname" => "Название микса",
"search" => "Искать",
"searchResults" => "Результаты поиска",
"searchResultsFor" => "Результаты поиска для",
"searchResultsFound" => "Найдены результаты поиска",
];

37
locale/uk_UA/messages.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
'welcome' => 'Ласкаво просимо на наш сайт!',
'description' => 'Це опис англійською.',
'userProfile' => "Профіль користувача",
'user' => 'Користувач',
'home' => 'Домашній екран',
'djName' => 'Ім\'я DJ',
'email' => 'Ел. пошта',
'location' => 'Місцезнаходження',
'bio' => 'Біо',
'submit' => 'Ввести',
'login' => 'Логін',
'message' => 'Повідомлення',
'follow' => 'Слідкувати',
'djs' => 'Діс',
"djNotFound" => "Не можливо завантажити DJ; або DJ не знайдено, або цей DJ — приватний.",
"notfound" => "Сторінка не знайдена",
"genre" => "Жанр",
"genres" => "Genres",
"genreNotFound" => "Не вдалося завантажити жанр, або жанр не було знайдено, було порожнім, або цей жанр є приватним.",
"mix-count" => "Лічильник міксів",
"mixes" => "Змішати",
"mix" => "Змішати",
"mixNotFound" => "Не вдалось завантажити мікс; або суміш не знайдена, була порожня, або ця суміш приватна.",
"mixName" => "Змішане ім'я",
"mixDescription" => "Змішати опис",
"mixLength" => "Довжина мікса",
"mixGenre" => "Мікс-жанр",
"view" => "Дивитись",
"mixname" => "Змішане ім'я",
"search" => "Пошук",
"searchResults" => "Результати пошуку",
"searchResultsFor" => "Результати пошуку для",
"searchResultsFound" => "Результати пошуку знайдено",
];

17
mix.php
View file

@ -9,9 +9,7 @@ require_once 'classes/Mix.php';
use Yosymfony\Toml\Toml;
$config = Toml::ParseFile('includes/config.toml');
$lang = $_SESSION['lang'] ?? $config['app']['locale'];
$locale = loadLocale($lang);
// if there's a query parameter named 'dj', load the Mix class
require_once 'includes/lang_loader.php';// if there's a query parameter named 'dj', load the Mix class
$db = new Database($config);
$mixFound = false;
if (isset($_GET['mix']) && $_GET['mix'] != "") {
@ -24,15 +22,10 @@ if (isset($_GET['mix']) && $_GET['mix'] != "") {
?>
<!doctype html >
<html lang="en">
<html lang="<?php echo $lang?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['app']['name']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fontawesome/css/all.css" rel="stylesheet"/>
<?php require_once 'header.php';
?>
</head>
<body style="background-color: #eee;">
<?php require 'navbar.php'; ?>
@ -237,6 +230,6 @@ if (isset($_GET['mix']) && $_GET['mix'] != "") {
</div>
</section>
<?php require 'footer.php'; ?>
</body>
</html>

View file

@ -21,19 +21,57 @@
if (basename($_SERVER['SCRIPT_NAME']) == 'index.php') {
echo current_list();
}
?>" href="/">Home</a>
?>" href="/"><?php echo $locale['home']; ?></a>
</li>
<li class="nav-item">
<a class="nav-link<?php
if (basename($_SERVER['SCRIPT_NAME']) == 'genres.php') {
echo current_list();
}?>" href="/genres.php">Genres</a>
} ?>" href="/genres.php"><?php echo $locale['genres']; ?></a>
</li>
</ul>
<?php
// add a language switcher
// show all languages in a dropdown of flags
$languages = ["en_US" => "English", "es_ES" => "Spanish", "fr_FR" => "French", "de_DE" => "German", "it_IT" => "Italian", "ru_RU" => "Russian", "uk_UA" => "Ukrainian", "fil_PH" => "Filipino"];
if (isset($_SESSION['lang'])) {
$current_lang = $_SESSION['lang'];
} else {
$current_lang = $config['app']['locale'];
}
?>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1"
data-bs-toggle="dropdown" aria-expanded="false">
<?php echo $languages[$current_lang]; ?>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<?php
foreach ($languages as $key => $value) {
echo '<li><a class="dropdown-item" href="?lang=' . $key . '">' . $value . '</a></li>';
}
?>
</ul>
</div>
<?php
if (isset($_SESSION['user'])) {
echo '<a class="nav-link" href="/profile.php">' . $locale['userProfile'] . '</a>';
} else {
echo '<a class="nav-link" href="/login.php">' . $locale['login'] . '</a>';
}
?>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
<input class="form-control me-2" type="search" placeholder="<?php echo $locale['search']; ?>"
aria-label="<?php echo $locale['search']; ?>">
<button class="btn btn-outline-success" type="submit"><?php echo $locale['search']; ?></button>
</form>
</div>
</div>