Skip to content

Commit

Permalink
HRA category rearranged
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturSierzant committed Dec 1, 2021
1 parent d166344 commit 5e156fb
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 148 deletions.
26 changes: 2 additions & 24 deletions ajax-hra-new-albums.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

global $cfg, $db;

$type = $_POST["type"];
$prefix = $_POST["prefix"];
$size = $_POST["tileSize"];
$limit = $_POST["limit"];
$offset = $_POST["offset"];
Expand All @@ -34,29 +34,7 @@
$h = new HraAPI;
if (NJB_WINDOWS) $t->fixSSLcertificate();

switch ($type){
case "new":
$results = $h->getCategorieContent("new", $limit, $offset);
break;
case "pop":
$results = $h->getCategorieContent("pop", $limit, $offset);
break;
case "rock":
$results = $h->getCategorieContent("rock", $limit, $offset);
break;
case "jazz":
$results = $h->getCategorieContent("jazz", $limit, $offset);
break;
case "classical":
$results = $h->getCategorieContent("classical", $limit, $offset);
break;
case "blues":
$results = $h->getCategorieContent("blues", $limit, $offset);
break;
case "rb":
$results = $h->getCategorieContent("R & B", $limit, $offset);
break;
}
$results = $h->getCategorieContent($prefix, $limit, $offset);
if ($results['data']['results']){
foreach($results['data']['results'] as $res) {
if ($res['publishingStatus'] == 'published') {
Expand Down
42 changes: 11 additions & 31 deletions api/hra_api/hra_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,45 +234,25 @@ function getAllCategories() {
}

function getCategorieContent($categorie, $limit=30, $offset=0) {
//$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Latin/Alternativo%20%26%20Rock%20Latino";

$exploded = explode("/",$categorie);
$counter = count($exploded);
//if $categorie is 'prefix' from getAllGenres,
//e.g. /HIGHRES AUDIO/Musicstore/Genre/Instrumental/Compilations:
if ($counter > 1) {
$genre = "&genre=" . urlencode($exploded[4]);

if (strpos($categorie,"/Genre/") !== false) {
$genre = "&genre=" . urlencode($exploded[4]);
if ($counter == 6) { // with subgenre
$subgenre = "/" . urlencode($exploded[5]);
$genre .= "/" . urlencode($exploded[5]);
}
$categorie = "/HIGHRES%20AUDIO/Musicstore/" . $genre . $subgenre;
$categorie = "/HIGHRES%20AUDIO/Musicstore/" . $genre . "&sort=-releaseDate";
}
else {
switch ($categorie) {
case "new":
//$categorie = "/HIGHRES%20AUDIO/Musicstore/Neue%20Alben%20hinzugefügt";
$categorie = "/HIGHRES%20AUDIO/Musicstore/";
break;
case "pop":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Pop";
break;
case "rock":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Rock";
break;
case "jazz":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Jazz";
break;
case "classical":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Classical";
break;
case "blues":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Blues";
break;
case "R & B":
$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=R%26B";
break;
$categorie = "";
for ($i =1; $i<$counter; $i++) {
$categorie .= "/" . urlencode($exploded[$i]);
}
$categorie .= "&sort=-releaseDate";
}
//$categorie = "/HIGHRES%20AUDIO/Musicstore/&genre=Latin/Alternativo%20%26%20Rock%20Latino";

curl_setopt($this->curl, CURLOPT_URL, self::API_URL . "vault/categories/ListCategorieContent/?category=" . $categorie . "&limit=" . $limit . "&offset=" . $offset . "&lang=" . $this->lang);
return $this->request();
}
Expand Down
18 changes: 6 additions & 12 deletions include/library.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1485,9 +1485,9 @@ function showGenreFromHRA() {
$genreList = '<table class="border" cellspacing="0" cellpadding="0">';
$genreList .= '<tr class="header"><td></td><td>Genre</td><td>Subgenre</td></tr>';
foreach ($sorted as $key=>$value) {
$genreList .= '<tr class="artist_list"><td class="space"></td><td><a href="index.php?action=viewNewFromHRA&amp;type=' . rawurlencode($key) . '&amp;prefix=' . rawurlencode($value[0]). '">' . html($key) . '</a></td><td class= "lh2">';
$genreList .= '<tr class="artist_list"><td class="space"></td><td><a href="index.php?action=viewNewFromHRA&amp;prefix=' . rawurlencode($value[0]). '">' . html($key) . '</a></td><td class= "lh2">';
foreach($value[1] as $key=>$value) {
$genreList .= '<a href="index.php?action=viewNewFromHRA&amp;type=' . rawurlencode($key) . '&amp;prefix=' . rawurlencode($value). '">' . html($key) . '</a> | ';
$genreList .= '<a href="index.php?action=viewNewFromHRA&amp;prefix=' . rawurlencode($value). '">' . html($key) . '</a> | ';
}
$genreList .= '</td></tr>';
$genreList .= '<tr class="line"><td></td><td></td><td></td></tr>';
Expand Down Expand Up @@ -1644,23 +1644,17 @@ function getTracksFromHraAlbum($album_id, $order = '') {
// | New albums from HRA |
// +------------------------------------------------------------------------+

function showNewHRAAlbumsByCategory($category) {
$categoryName = $category;
if ($category == 'rb') {
$categoryName = 'R&B';
}
if ($category == 'new') {
$categoryName = '';
}
function showNewHRAAlbumsByCategory($categoryName, $prefix) {
$category = str_replace(" ", "_", $categoryName);
echo '
<h1>&nbsp;New ' . $categoryName . ' albums <a href="index.php?action=viewNewFromHRA&type=' . $category . '">(more...)</a></h1>
<h1>&nbsp;' . $categoryName . ' <a href="index.php?action=viewNewFromHRA&prefix=' . urlencode($prefix) . '&categoryName=' . urlencode($categoryName) . '">(more...)</a></h1>
<script>
calcTileSize();
var size = $tileSize;
var request = $.ajax({
url: "ajax-hra-new-albums.php",
type: "POST",
data: { type: "' . $category . '", tileSize : size, limit : 10, offset : 0 },
data: { prefix: "' . $prefix . '", tileSize : size, limit : 10, offset : 0 },
dataType: "html"
});
Expand Down
4 changes: 2 additions & 2 deletions include/new_albums_hra.inc.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<h1>&nbsp;New albums from <a href="index.php?action=viewHRA">HighResAudio</a> <a href="index.php?action=viewNewFromHRA&type=new">(more...)</a></h1>
<h1>&nbsp;New albums from <a href="index.php?action=viewHRA">HighResAudio</a> <a href="index.php?action=viewNewFromHRA&categoryName=New%20albums&prefix=/HIGHRES%20AUDIO/Musicstore/">(more...)</a></h1>
<script>
calcTileSize();
var size = $tileSize;
var request = $.ajax({
url: "ajax-hra-new-albums.php",
type: "POST",
data: { type: "new", tileSize : size, limit : 15, offset : 0 },
data: { categoryName: "New albums", prefix: "/HIGHRES AUDIO/Musicstore/", tileSize : size, limit : 15, offset : 0 },
dataType: "html"
});
Expand Down
107 changes: 28 additions & 79 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2107,13 +2107,12 @@ function viewHRA() {
</script>
<div class="area">
<?php
showNewHRAAlbumsByCategory('new');
showNewHRAAlbumsByCategory('rock');
showNewHRAAlbumsByCategory('blues');
showNewHRAAlbumsByCategory('rb');
showNewHRAAlbumsByCategory('pop');
showNewHRAAlbumsByCategory('jazz');
showNewHRAAlbumsByCategory('classical');
showNewHRAAlbumsByCategory('New albums', '/HIGHRES AUDIO/Musicstore/');
showNewHRAAlbumsByCategory('Editors Choice', '/HIGHRES AUDIO/Musicstore/Editors Choice');
showNewHRAAlbumsByCategory('High-Res Essentials', '/HIGHRES AUDIO/Musicstore/High-Res Essentials');
showNewHRAAlbumsByCategory('Bestsellers', '/HIGHRES AUDIO/Musicstore/Bestsellers');
showNewHRAAlbumsByCategory('Top albums', '/HIGHRES AUDIO/Musicstore/Top Alben');
showNewHRAAlbumsByCategory('Listening tips', '/HIGHRES AUDIO/Musicstore/Hörtipps');
echo '</div>';

require_once('include/footer.inc.php');
Expand All @@ -2130,14 +2129,20 @@ function viewNewFromHRA() {
global $cfg, $db;
global $base_size, $spaces, $scroll_bar_correction;

$type = get('type');
//$type = get('type');
$prefix = get('prefix');
$genreM = "";
$categoryName = get('categoryName');
$genreM = '';
if ($prefix) {
$exploded = explode("/",$prefix);
$counter = count($exploded);
if ($counter == 6) { // with subgenre
$genreM = $exploded[4] . " > ";
if (strpos($prefix,"/Genre/") !== false) {
$exploded = explode("/",$prefix);
$counter = count($exploded);
$genreM = $exploded[4];
$categoryName = "New " . $genreM . " albums";
if ($counter == 6) { // with subgenre
$subgenre = $exploded[5];
$categoryName = 'New ' . $genreM . ' > ' . $subgenre . ' albums';
}
}
}
authenticate('access_media');
Expand All @@ -2148,47 +2153,16 @@ function viewNewFromHRA() {
$nav['url'][] = 'index.php';
$nav['name'][] = 'HighResAudio';
$nav['url'][] = 'index.php?action=viewHRA';
switch ($type) {
case "new":
$nav['name'][] = 'New albums:';
require_once('include/header.inc.php');
echo ('<h1>New albums</h1>');
break;
case "pop":
$nav['name'][] = 'New pop albums:';
require_once('include/header.inc.php');
echo ('<h1>New pop albums</h1>');
break;
case "rock":
$nav['name'][] = 'New rock albums:';
require_once('include/header.inc.php');
echo ('<h1>New rock albums</h1>');
break;
case "jazz":
$nav['name'][] = 'New jazz albums:';
require_once('include/header.inc.php');
echo ('<h1>New jazz albums</h1>');
break;
case "classical":
$nav['name'][] = 'New classical albums:';
require_once('include/header.inc.php');
echo ('<h1>New classical albums</h1>');
break;
case "blues":
$nav['name'][] = 'New blues albums:';
require_once('include/header.inc.php');
echo ('<h1>New blues albums</h1>');
break;
case "rb":
$nav['name'][] = 'New R&B albums:';
require_once('include/header.inc.php');
echo ('<h1>New R&B albums</h1>');
break;
default:
$nav['name'][] = 'New ' . $genreM . $type . ' albums:';
require_once('include/header.inc.php');
echo ('<h1>New ' . $genreM . $type . ' albums</h1>');
if ($subgenre) {
$nav['name'][] = $genreM;
$nav['url'][] = 'index.php?action=viewNewFromHRA&amp;prefix=' . urlencode("/" . $exploded[1] . "/" . $exploded[2] . "/" . $exploded[3] . "/" . $exploded[4]);
$nav['name'][] = $subgenre;
}
else {
$nav['name'][] = $categoryName . ':';
}
require_once('include/header.inc.php');
echo ('<h1>' . $categoryName . '</h1>');
//echo "<div>Prefix: $prefix</div>";
?>

Expand All @@ -2202,32 +2176,7 @@ function viewNewFromHRA() {
$conn = $h->connect();
if ($conn === true) {
$curr_page = (get('page') ? get('page') : 1);
switch ($type){
case "new":
$results = $h->getCategorieContent("new", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "pop":
$results = $h->getCategorieContent("pop", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "rock":
$results = $h->getCategorieContent("rock", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "jazz":
$results = $h->getCategorieContent("jazz", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "classical":
$results = $h->getCategorieContent("classical", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "blues":
$results = $h->getCategorieContent("blues", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
case "rb":
$results = $h->getCategorieContent("R & B", $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
break;
default:
$results = $h->getCategorieContent($prefix, $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
}
//$results = $h->getCategorieContent($prefix, $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
$results = $h->getCategorieContent($prefix, $cfg['max_items_per_page'], $cfg['max_items_per_page'] * ($curr_page - 1));
if ($results['data']['results']){
foreach($results['data']['results'] as $res) {
if ($res['publishingStatus'] == 'published') {
Expand Down

0 comments on commit 5e156fb

Please sign in to comment.