From f690ff7df7c0675e0a361816086aefa1ef8ac07b Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:27:15 +0300 Subject: [PATCH 01/15] Make audio player pizdatey --- Web/Models/Entities/Audio.php | 5 + Web/Models/Repositories/Audios.php | 8 +- Web/Presenters/AudioPresenter.php | 25 +- Web/Presenters/templates/@layout.xml | 2 +- Web/Presenters/templates/Audio/List.xml | 26 +- Web/Presenters/templates/Audio/Playlist.xml | 8 +- Web/Presenters/templates/Audio/bigplayer.xml | 40 +- Web/Presenters/templates/Audio/player.xml | 22 +- Web/Presenters/templates/Audio/tabs.xml | 9 +- Web/Presenters/templates/Search/Index.xml | 14 +- Web/routes.yml | 6 - Web/static/css/audios.css | 416 +++-- Web/static/css/main.css | 8 +- Web/static/js/al_music.js | 1515 +++++++++--------- Web/static/js/al_wall.js | 29 +- Web/static/js/utils.js | 8 + 16 files changed, 1114 insertions(+), 1027 deletions(-) diff --git a/Web/Models/Entities/Audio.php b/Web/Models/Entities/Audio.php index 3b998f32..23941f4c 100644 --- a/Web/Models/Entities/Audio.php +++ b/Web/Models/Entities/Audio.php @@ -147,6 +147,11 @@ class Audio extends Media return $this->getRecord()->performer; } + function getPerformers(): array + { + return explode(", ", $this->getRecord()->performer); + } + function getName(): string { return $this->getPerformer() . " — " . $this->getTitle(); diff --git a/Web/Models/Repositories/Audios.php b/Web/Models/Repositories/Audios.php index 73f5ac29..1b8b174d 100644 --- a/Web/Models/Repositories/Audios.php +++ b/Web/Models/Repositories/Audios.php @@ -248,15 +248,17 @@ class Audios { $query = "%$query%"; $result = $this->audios->where([ - "unlisted" => 0, - "deleted" => 0, + "unlisted" => 0, + "deleted" => 0, + /*"withdrawn" => 0, + "processed" => 1,*/ ]); $order_str = (in_array($order['type'], ['id', 'length', 'listens']) ? $order['type'] : 'id') . ' ' . ($order['invert'] ? 'ASC' : 'DESC');; if($params["only_performers"] == "1") { $result->where("performer LIKE ?", $query); } else { - $result->where("name LIKE ? OR performer LIKE ?", $query, $query); + $result->where("CONCAT_WS(' ', performer, name) LIKE ?", $query); } foreach($params as $paramName => $paramValue) { diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index ae38d1d0..796e91f0 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -779,16 +779,21 @@ final class AudioPresenter extends OpenVKPresenter $audiosArr = []; foreach($audios as $audio) { - $audiosArr[] = [ - "id" => $audio->getId(), - "name" => $audio->getTitle(), - "performer" => $audio->getPerformer(), - "keys" => $audio->getKeys(), - "url" => $audio->getUrl(), - "length" => $audio->getLength(), - "available" => $audio->isAvailable(), - "withdrawn" => $audio->isWithdrawn(), - ]; + $output_array = []; + $output_array['id'] = $audio->getId(); + $output_array['name'] = $audio->getTitle(); + $output_array['performer'] = $audio->getPerformer(); + + if(!$audio->isWithdrawn() && $audio->isAvailable()) { + $output_array['keys'] = $audio->getKeys(); + $output_array['url'] = $audio->getUrl(); + } + + $output_array['length'] = $audio->getLength(); + $output_array['available'] = $audio->isAvailable(); + $output_array['withdrawn'] = $audio->isWithdrawn(); + + $audiosArr[] = $output_array; } $resultArr = [ diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index 0e514bb8..ce6c080c 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -20,7 +20,6 @@ {script "js/utils.js"} {script "js/node_modules/dashjs/dist/dash.all.min.js"} - {script "js/al_music.js"} {css "js/node_modules/tippy.js/dist/backdrop.css"} {css "js/node_modules/cropperjs/dist/cropper.css"} @@ -392,6 +391,7 @@ {script "js/al_suggestions.js"} {script "js/al_navigation.js"} {script "js/al_comments.js"} + {script "js/al_music.js"} {ifset $thisUser} {script "js/al_notifs.js"} diff --git a/Web/Presenters/templates/Audio/List.xml b/Web/Presenters/templates/Audio/List.xml index 32d2e26b..19496114 100644 --- a/Web/Presenters/templates/Audio/List.xml +++ b/Web/Presenters/templates/Audio/List.xml @@ -54,18 +54,24 @@ {include "bigplayer.xml"} - - - -
+
-
-
+
+
{include "../components/content_error.xml", description => $ownerId > 0 ? ($ownerId == $thisUser->getId() ? tr("no_audios_thisuser") : tr("no_audios_user")) : tr("no_audios_club")}
-
-
+
+
{include "player.xml", audio => $audio, club => $club}
@@ -81,12 +87,12 @@
-
+
{include "../components/content_error.xml", description => $ownerId > 0 ? ($ownerId == $thisUser->getId() ? tr("no_playlists_thisuser") : tr("no_playlists_user")) : tr("no_playlists_club")}
-
+
{include 'playlistListView.xml', playlist => $playlist}
diff --git a/Web/Presenters/templates/Audio/Playlist.xml b/Web/Presenters/templates/Audio/Playlist.xml index 7f8c7348..5a96ad6c 100644 --- a/Web/Presenters/templates/Audio/Playlist.xml +++ b/Web/Presenters/templates/Audio/Playlist.xml @@ -32,8 +32,14 @@ {block content} {include "bigplayer.xml"} + -
{if $cover} diff --git a/Web/Presenters/templates/Audio/bigplayer.xml b/Web/Presenters/templates/Audio/bigplayer.xml index 6ae6326d..44f7bfd0 100644 --- a/Web/Presenters/templates/Audio/bigplayer.xml +++ b/Web/Presenters/templates/Audio/bigplayer.xml @@ -1,56 +1,56 @@
-