From 5e156fb0180ef9dae888afc60c5ad2d1b6552752 Mon Sep 17 00:00:00 2001 From: ArturSierzant Date: Wed, 1 Dec 2021 23:22:20 +0100 Subject: [PATCH] HRA category rearranged --- ajax-hra-new-albums.php | 26 +------- api/hra_api/hra_api.php | 42 ++++--------- include/library.inc.php | 18 ++---- include/new_albums_hra.inc.php | 4 +- index.php | 107 +++++++++------------------------ 5 files changed, 49 insertions(+), 148 deletions(-) diff --git a/ajax-hra-new-albums.php b/ajax-hra-new-albums.php index 5c6f1cb..9105393 100644 --- a/ajax-hra-new-albums.php +++ b/ajax-hra-new-albums.php @@ -23,7 +23,7 @@ global $cfg, $db; -$type = $_POST["type"]; +$prefix = $_POST["prefix"]; $size = $_POST["tileSize"]; $limit = $_POST["limit"]; $offset = $_POST["offset"]; @@ -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') { diff --git a/api/hra_api/hra_api.php b/api/hra_api/hra_api.php index a39b2e7..cfdf0a9 100644 --- a/api/hra_api/hra_api.php +++ b/api/hra_api/hra_api.php @@ -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(); } diff --git a/include/library.inc.php b/include/library.inc.php index df1a30e..f37ecca 100644 --- a/include/library.inc.php +++ b/include/library.inc.php @@ -1485,9 +1485,9 @@ function showGenreFromHRA() { $genreList = ''; $genreList .= ''; foreach ($sorted as $key=>$value) { - $genreList .= ''; $genreList .= ''; @@ -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 ' -

 New ' . $categoryName . ' albums (more...)

+

 ' . $categoryName . ' (more...)

'; require_once('include/footer.inc.php'); @@ -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'); @@ -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 ('

New albums

'); - break; - case "pop": - $nav['name'][] = 'New pop albums:'; - require_once('include/header.inc.php'); - echo ('

New pop albums

'); - break; - case "rock": - $nav['name'][] = 'New rock albums:'; - require_once('include/header.inc.php'); - echo ('

New rock albums

'); - break; - case "jazz": - $nav['name'][] = 'New jazz albums:'; - require_once('include/header.inc.php'); - echo ('

New jazz albums

'); - break; - case "classical": - $nav['name'][] = 'New classical albums:'; - require_once('include/header.inc.php'); - echo ('

New classical albums

'); - break; - case "blues": - $nav['name'][] = 'New blues albums:'; - require_once('include/header.inc.php'); - echo ('

New blues albums

'); - break; - case "rb": - $nav['name'][] = 'New R&B albums:'; - require_once('include/header.inc.php'); - echo ('

New R&B albums

'); - break; - default: - $nav['name'][] = 'New ' . $genreM . $type . ' albums:'; - require_once('include/header.inc.php'); - echo ('

New ' . $genreM . $type . ' albums

'); + if ($subgenre) { + $nav['name'][] = $genreM; + $nav['url'][] = 'index.php?action=viewNewFromHRA&prefix=' . urlencode("/" . $exploded[1] . "/" . $exploded[2] . "/" . $exploded[3] . "/" . $exploded[4]); + $nav['name'][] = $subgenre; } + else { + $nav['name'][] = $categoryName . ':'; + } + require_once('include/header.inc.php'); + echo ('

' . $categoryName . '

'); //echo "
Prefix: $prefix
"; ?> @@ -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') {
GenreSubgenre
' . html($key) . ''; + $genreList .= '
' . html($key) . ''; foreach($value[1] as $key=>$value) { - $genreList .= '' . html($key) . ' | '; + $genreList .= '' . html($key) . ' | '; } $genreList .= '