From 9c92fe4901f89617a9198f9f7b4e84d269895818 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:24:11 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BB=D0=B5=D0=B3=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B5=D0=B1=D0=B0=D0=BB=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKAPI/Handlers/Audio.php | 15 +-------------- Web/Models/Repositories/Audios.php | 16 ++-------------- Web/Presenters/AudioPresenter.php | 4 ++-- Web/Presenters/templates/Audio/bigplayer.xml | 2 +- Web/Presenters/templates/Audio/tabs.xml | 9 ++++----- Web/static/css/audios.css | 9 +++++++-- Web/static/css/main.css | 2 +- Web/static/js/al_music.js | 3 ++- 8 files changed, 20 insertions(+), 40 deletions(-) diff --git a/VKAPI/Handlers/Audio.php b/VKAPI/Handlers/Audio.php index 90d060fb9..e0991af92 100644 --- a/VKAPI/Handlers/Audio.php +++ b/VKAPI/Handlers/Audio.php @@ -587,20 +587,7 @@ function searchAlbums(string $query = '', int $offset = 0, int $limit = 25, int $playlists = []; $params = []; - $order_str = 'id'; - switch($order) { - default: - case 0: - $order_str = 'id'; - break; - case 1: - $order_str = 'length'; - break; - case 2: - $order_str = 'listens'; - break; - } - + $order_str = (['id', 'length', 'listens'][$order] ?? 'id'); if($from_me === 1) $params['from_me'] = $this->getUser()->getId(); diff --git a/Web/Models/Repositories/Audios.php b/Web/Models/Repositories/Audios.php index 7ff00a1dc..73f5ac293 100644 --- a/Web/Models/Repositories/Audios.php +++ b/Web/Models/Repositories/Audios.php @@ -251,19 +251,7 @@ function find(string $query, array $params = [], array $order = ['type' => 'id', "unlisted" => 0, "deleted" => 0, ]); - $order_str = 'id'; - - switch($order['type']) { - case 'id': - $order_str = 'id ' . ($order['invert'] ? 'ASC' : 'DESC'); - break; - case 'length': - $order_str = 'length ' . ($order['invert'] ? 'ASC' : 'DESC'); - break; - case 'listens': - $order_str = 'listens ' . ($order['invert'] ? 'ASC' : 'DESC'); - break; - } + $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); @@ -304,7 +292,7 @@ function findPlaylists(string $query, array $params = [], array $order = ['type' $result = $this->playlists->where([ "deleted" => 0, ])->where("CONCAT_WS(' ', name, description) LIKE ?", $query); - $order_str = (['id', 'length', 'listens'][$order['type']] ?? 'id') . ' ' . ($order['invert'] ? 'ASC' : 'DESC'); + $order_str = (in_array($order['type'], ['id', 'length', 'listens']) ? $order['type'] : 'id') . ' ' . ($order['invert'] ? 'ASC' : 'DESC'); if(is_null($params['from_me']) || empty($params['from_me'])) $result->where(["unlisted" => 0]); diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index b47ba0f0e..7e2825c13 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -109,8 +109,8 @@ function renderList(?int $owner = NULL, ?string $mode = "list"): void $this->template->mode = $mode; $this->template->page = $page; - - if(in_array($mode, ["list", "new", "popular"]) && $this->user->identity) + + if(in_array($mode, ["list", "new", "popular"]) && $this->user->identity && $page < 2) $this->template->friendsAudios = $this->user->identity->getBroadcastList("all", true); } diff --git a/Web/Presenters/templates/Audio/bigplayer.xml b/Web/Presenters/templates/Audio/bigplayer.xml index 4baa9dbd6..6ae6326df 100644 --- a/Web/Presenters/templates/Audio/bigplayer.xml +++ b/Web/Presenters/templates/Audio/bigplayer.xml @@ -18,7 +18,7 @@