From 68e16cfbb04e063ad3b6c17cd2f555fe90e8e726 Mon Sep 17 00:00:00 2001 From: lalka2018 <99399973+lalka2016@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:25:46 +0300 Subject: [PATCH] Update en.strings --- Web/Models/Entities/Report.php | 3 +- Web/Models/Entities/User.php | 10 +- Web/Presenters/AudioPresenter.php | 51 +++++-- Web/Presenters/GroupPresenter.php | 4 +- Web/Presenters/ReportPresenter.php | 4 +- Web/Presenters/UserPresenter.php | 1 + Web/Presenters/templates/Audio/List.xml | 84 ++++++------ .../templates/Audio/NewPlaylist.xml | 71 +++------- Web/Presenters/templates/Audio/Playlist.xml | 128 +++++------------- Web/Presenters/templates/Audio/Upload.xml | 2 +- Web/Presenters/templates/Audio/bigplayer.xml | 41 ++++++ Web/Presenters/templates/Audio/player.xml | 13 +- Web/Presenters/templates/Audio/tabs.xml | 11 +- Web/Presenters/templates/Group/View.xml | 19 +++ Web/Presenters/templates/Report/Tabs.xml | 3 + .../templates/Report/ViewContent.xml | 2 + Web/Presenters/templates/User/Settings.xml | 12 ++ Web/static/css/audios.css | 35 +++++ Web/static/img/song.jpg | Bin 2763 -> 2481 bytes Web/static/js/al_music.js | 29 +++- locales/en.strings | 15 +- locales/ru.strings | 14 ++ 22 files changed, 335 insertions(+), 217 deletions(-) create mode 100644 Web/Presenters/templates/Audio/bigplayer.xml diff --git a/Web/Models/Entities/Report.php b/Web/Models/Entities/Report.php index d449a2e8..5487056f 100644 --- a/Web/Models/Entities/Report.php +++ b/Web/Models/Entities/Report.php @@ -5,7 +5,7 @@ use Nette\Database\Table\ActiveRow; use openvk\Web\Models\RowModel; use openvk\Web\Models\Entities\Club; use Chandler\Database\DatabaseConnection; -use openvk\Web\Models\Repositories\{Applications, Comments, Notes, Reports, Users, Posts, Photos, Videos, Clubs}; +use openvk\Web\Models\Repositories\{Applications, Comments, Notes, Reports, Audios, Users, Posts, Photos, Videos, Clubs}; use Chandler\Database\DatabaseConnection as DB; use Nette\InvalidStateException as ISE; use Nette\Database\Table\Selection; @@ -74,6 +74,7 @@ class Report extends RowModel else if ($this->getContentType() == "note") return (new Notes)->get($this->getContentId()); else if ($this->getContentType() == "app") return (new Applications)->get($this->getContentId()); else if ($this->getContentType() == "user") return (new Users)->get($this->getContentId()); + else if ($this->getContentType() == "audio") return (new Audios)->get($this->getContentId()); else return null; } diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 7dc42a4a..fa9eb28a 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -4,7 +4,7 @@ use morphos\Gender; use openvk\Web\Themes\{Themepack, Themepacks}; use openvk\Web\Util\DateTime; use openvk\Web\Models\RowModel; -use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift}; +use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift, Audio}; use openvk\Web\Models\Repositories\{Applications, Bans, Comments, Notes, Posts, Users, Clubs, Albums, Gifts, Notifications, Videos, Photos}; use openvk\Web\Models\Exceptions\InvalidUserNameException; use Nette\Database\Table\ActiveRow; @@ -463,7 +463,8 @@ class User extends RowModel "news", "links", "poster", - "apps" + "apps", + "audios", ], ])->get($id); } @@ -483,6 +484,7 @@ class User extends RowModel "friends.add", "wall.write", "messages.write", + "audios.read", ], ])->get($id); } @@ -1011,6 +1013,7 @@ class User extends RowModel "friends.add", "wall.write", "messages.write", + "audios.read", ], ])->set($id, $status)->toInteger()); } @@ -1021,6 +1024,7 @@ class User extends RowModel "length" => 1, "mappings" => [ "photos", + "audios", "videos", "messages", "notes", @@ -1028,7 +1032,7 @@ class User extends RowModel "news", "links", "poster", - "apps" + "apps", ], ])->set($id, (int) $status)->toInteger(); diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index cec9c452..3776a52e 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -58,6 +58,9 @@ final class AudioPresenter extends OpenVKPresenter if (!$entity || $entity->isDeleted() || $entity->isBanned()) $this->redirect("/audios" . $this->user->id); + if(!$entity->getPrivacyPermission("audios.read", $this->user->identity)) + $this->flashFail("err", tr("forbidden"), tr("forbidden_comment")); + $audios = $this->audios->getByUser($entity, $page, 10); $audiosCount = $this->audios->getUserCollectionSize($entity); } @@ -66,11 +69,38 @@ final class AudioPresenter extends OpenVKPresenter $this->notFound(); $this->template->owner = $entity; + $this->template->ownerId = $owner; $this->template->isMy = ($owner > 0 && ($entity->getId() === $this->user->id)); $this->template->isMyClub = ($owner < 0 && $entity->canBeModifiedBy($this->user->identity)); } else if ($mode === "new") { $audios = $this->audios->getNew(); $audiosCount = $audios->size(); + } else if ($mode === "playlists") { + if($owner < 0) { + $entity = (new Clubs)->get(abs($owner)); + if (!$entity || $entity->isBanned()) + $this->redirect("/playlists" . $this->user->id); + + $playlists = $this->audios->getPlaylistsByClub($entity, $page, 10); + $playlistsCount = $this->audios->getClubPlaylistsCount($entity); + } else { + $entity = (new Users)->get($owner); + if (!$entity || $entity->isDeleted() || $entity->isBanned()) + $this->redirect("/playlists" . $this->user->id); + + if(!$entity->getPrivacyPermission("audios.read", $this->user->identity)) + $this->flashFail("err", tr("forbidden"), tr("forbidden_comment")); + + $playlists = $this->audios->getPlaylistsByUser($entity, $page, 10); + $playlistsCount = $this->audios->getUserPlaylistsCount($entity); + } + + $this->template->playlists = iterator_to_array($playlists); + $this->template->playlistsCount = $playlistsCount; + $this->template->owner = $entity; + $this->template->ownerId = $owner; + $this->template->isMy = ($owner > 0 && ($entity->getId() === $this->user->id)); + $this->template->isMyClub = ($owner < 0 && $entity->canBeModifiedBy($this->user->identity)); } else { $audios = $this->audios->getPopular(); $audiosCount = $audios->size(); @@ -223,24 +253,24 @@ final class AudioPresenter extends OpenVKPresenter $owner = $this->user->id; if ($this->requestParam("owner")) { - $club = (new Clubs)->get((int) $this->requestParam("owner") * -1); + $club = (new Clubs)->get((int) abs($this->requestParam("owner"))); if (!$club || $club->isBanned() || !$club->canBeModifiedBy($this->user->identity)) $this->redirect("/audios" . $this->user->id); $owner = ($club->getId() * -1); + + $this->template->club = $club; } $this->template->owner = $owner; - // exit(var_dump($owner)); - if ($_SERVER["REQUEST_METHOD"] === "POST") { $title = $this->postParam("title"); $description = $this->postParam("description"); $audios = !empty($this->postParam("audios")) ? explode(",", $this->postParam("audios")) : []; - if (!$title) - $this->returnJson(["success" => false, "error" => "Название не указано"]); + if(empty($title) || iconv_strlen($title) < 1) + $this->flash("err", tr("error"), "ну там короч нету имени ну хз"); $playlist = new Playlist; $playlist->setOwner($owner); @@ -254,7 +284,7 @@ final class AudioPresenter extends OpenVKPresenter DatabaseConnection::i()->getContext()->query("INSERT INTO `playlist_imports` (`entity`, `playlist`) VALUES (?, ?)", $owner, $playlist->getId()); - $this->returnJson(["success" => true, "payload" => "/playlist" . $owner . "_" . $playlist->getId()]); + $this->redirect("/playlist" . $owner . "_" . $playlist->getId()); } else { $this->template->audios = iterator_to_array($this->audios->getByUser($this->user->identity)); } @@ -295,7 +325,7 @@ final class AudioPresenter extends OpenVKPresenter $this->template->audios = iterator_to_array($playlist->getAudios()); } - if ($_SERVER["REQUEST_METHOD"] === "POST") { + /*if ($_SERVER["REQUEST_METHOD"] === "POST") { if (!$this->template->canEdit) { $this->flashFail("err", tr("error"), tr("forbidden")); } @@ -341,7 +371,7 @@ final class AudioPresenter extends OpenVKPresenter $this->flash("succ", tr("changes_saved")); $this->redirect("/playlist" . $playlist->getOwner()->getId() . "_" . $playlist->getId()); - } + }*/ } function renderAction(int $audio_id): void @@ -391,7 +421,7 @@ final class AudioPresenter extends OpenVKPresenter $name = $this->postParam("name"); $lyrics = $this->postParam("lyrics"); $genre = empty($this->postParam("genre")) ? "undefined" : $this->postParam("genre"); - $nsfw = ($this->postParam("nsfw") ?? "off") === "on"; + $nsfw = (int)($this->postParam("explicit") ?? 0) === 1; if(empty($performer) || empty($name) || iconv_strlen($performer . $name) > 128) # FQN of audio must not be more than 128 chars $this->flashFail("err", tr("error"), tr("error_insufficient_info"), null, true); @@ -399,6 +429,7 @@ final class AudioPresenter extends OpenVKPresenter $audio->setPerformer($performer); $audio->setLyrics(empty($lyrics) ? NULL : $lyrics); $audio->setGenre($genre); + $audio->setExplicit($nsfw); $audio->save(); $this->returnJson(["success" => true, "new_info" => [ @@ -420,6 +451,6 @@ final class AudioPresenter extends OpenVKPresenter function renderPlaylists(int $owner) { - $this->assertUserLoggedIn(); + $this->renderList($owner, "playlists"); } } \ No newline at end of file diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index d3a46fd5..27d626cc 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -3,7 +3,7 @@ namespace openvk\Web\Presenters; use openvk\Web\Models\Entities\{Club, Photo, Post}; use Nette\InvalidStateException; use openvk\Web\Models\Entities\Notifications\ClubModeratorNotification; -use openvk\Web\Models\Repositories\{Clubs, Users, Albums, Managers, Topics}; +use openvk\Web\Models\Repositories\{Clubs, Users, Albums, Managers, Topics, Audios}; use Chandler\Security\Authenticator; final class GroupPresenter extends OpenVKPresenter @@ -31,6 +31,8 @@ final class GroupPresenter extends OpenVKPresenter $this->template->albumsCount = (new Albums)->getClubAlbumsCount($club); $this->template->topics = (new Topics)->getLastTopics($club, 3); $this->template->topicsCount = (new Topics)->getClubTopicsCount($club); + $this->template->audios = (new Audios)->getByClub($club, 1, 3); + $this->template->audiosCount = (new Audios)->getClubCollectionSize($club); } $this->template->club = $club; diff --git a/Web/Presenters/ReportPresenter.php b/Web/Presenters/ReportPresenter.php index a87154c8..0c4cbd83 100644 --- a/Web/Presenters/ReportPresenter.php +++ b/Web/Presenters/ReportPresenter.php @@ -23,7 +23,7 @@ final class ReportPresenter extends OpenVKPresenter if ($_SERVER["REQUEST_METHOD"] === "POST") $this->assertNoCSRF(); - $act = in_array($this->queryParam("act"), ["post", "photo", "video", "group", "comment", "note", "app", "user"]) ? $this->queryParam("act") : NULL; + $act = in_array($this->queryParam("act"), ["post", "photo", "video", "group", "comment", "note", "app", "user", "audio"]) ? $this->queryParam("act") : NULL; if (!$this->queryParam("orig")) { $this->template->reports = $this->reports->getReports(0, (int)($this->queryParam("p") ?? 1), $act, $_SERVER["REQUEST_METHOD"] !== "POST"); @@ -88,7 +88,7 @@ final class ReportPresenter extends OpenVKPresenter if(!$id) exit(json_encode([ "error" => tr("error_segmentation") ])); - if(in_array($this->queryParam("type"), ["post", "photo", "video", "group", "comment", "note", "app", "user"])) { + if(in_array($this->queryParam("type"), ["post", "photo", "video", "group", "comment", "note", "app", "user", "audio"])) { if (count(iterator_to_array($this->reports->getDuplicates($this->queryParam("type"), $id, NULL, $this->user->id))) <= 0) { $report = new Report; $report->setUser_id($this->user->id); diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index e568d4c5..ee12559f 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -432,6 +432,7 @@ final class UserPresenter extends OpenVKPresenter "friends.add", "wall.write", "messages.write", + "audios.read", ]; foreach($settings as $setting) { $input = $this->postParam(str_replace(".", "_", $setting)); diff --git a/Web/Presenters/templates/Audio/List.xml b/Web/Presenters/templates/Audio/List.xml index 9e002b32..129791a7 100644 --- a/Web/Presenters/templates/Audio/List.xml +++ b/Web/Presenters/templates/Audio/List.xml @@ -23,54 +23,20 @@ » {_audio_popular} + +
+ {_audios} + » + {_audio_popular} +
{/block} {block content} {* ref: https://archive.li/P32em *} -
-
-
-
- -
-
-
-
-
- -
-
- {_track_unknown} — - {_track_noname} - - 00:00 -
- -
-
  -
-
-
-
- -
-
-
  -
-
-
-
- -
-
-
-
-
-
-
- + + {include "bigplayer.xml"}
-
+
{include "../components/nothing.xml"} @@ -92,6 +58,38 @@
+ +
+
+
+ {include "../components/error.xml", description => $ownerId > 0 ? ($ownerId == $thisUser->getId() ? tr("no_playlists_thisuser") : tr("no_playlists_user")) : tr("no_playlists_club")} +
+ + + +
+ {include "../components/paginator.xml", conf => (object) [ + "page" => $page, + "count" => $playlistsCount, + "amount" => sizeof($playlists), + "perPage" => $perPage ?? OPENVK_DEFAULT_PER_PAGE, + "atBottom" => true, + ]} +
+
+
{include "tabs.xml"}
{/block} \ No newline at end of file diff --git a/Web/Presenters/templates/Audio/NewPlaylist.xml b/Web/Presenters/templates/Audio/NewPlaylist.xml index 4c600406..06208bfb 100644 --- a/Web/Presenters/templates/Audio/NewPlaylist.xml +++ b/Web/Presenters/templates/Audio/NewPlaylist.xml @@ -1,81 +1,46 @@ {extends "../@layout.xml"} {block title} - Создать плейлист + {_new_playlist} {/block} {block header} - {include title} + {if !$_GET["owner"]} + {$thisUser->getCanonicalName()} + » + {_audios} + {else} + {$club->getCanonicalName()} + » + {_audios} + {/if} + » + {_new_playlist} {/block} {block content} - {include "tabs.xml", mode => "list"} -
-
- +

- + й йбй бй дй д яюдюяд ю бяб бля лбябл бялб я бля бляб ля я не сделал.... {/if} -
- создан {$playlist->getCreationTime()} - {if $playlist->getEditTime()} - · - обновлен {$playlist->getEditTime()} - {/if} -
-

-
-
- {include "../components/nothing.xml"} -
-
- {include "player.xml", - audio => $audio, - canAdd => $edit && !$playlist->hasAudio($audio), - canRemove => $edit && $playlist->hasAudio($audio), - addOnClick => "addToPlaylist({$audio->getId()})", - deleteOnClick => "removeFromPlaylist({$audio->getId()})" - } -
- -
- {script "js/node_modules/umbrellajs/umbrella.min.js"} - {script "js/node_modules/dashjs/dist/dash.all.min.js"} - - {include "player.js.xml", audios => $audios} -
-
- {if $edit} -

-
- - - - {/if} - {if $edit}{/if} - {/block} diff --git a/Web/Presenters/templates/Audio/Upload.xml b/Web/Presenters/templates/Audio/Upload.xml index a0d47601..d1628d55 100644 --- a/Web/Presenters/templates/Audio/Upload.xml +++ b/Web/Presenters/templates/Audio/Upload.xml @@ -145,7 +145,7 @@ perf_.value = document.querySelector("#lastStep input[name=performer]").value genre_.value = document.querySelector("#lastStep select[name=genre]").value lyrics_.value = document.querySelector("#lastStep textarea[name=lyrics]").value - explicit_.value = document.querySelector("#lastStep input[name=explicit]").value + explicit_.value = document.querySelector("#lastStep input[name=explicit]").checked ? "on" : "off" document.querySelector("#audio_upload > form").submit(); }) diff --git a/Web/Presenters/templates/Audio/bigplayer.xml b/Web/Presenters/templates/Audio/bigplayer.xml new file mode 100644 index 00000000..28d85e69 --- /dev/null +++ b/Web/Presenters/templates/Audio/bigplayer.xml @@ -0,0 +1,41 @@ +
+
+
+
+ +
+
+
+
+
+ +
+
+ {_track_unknown} — + {_track_noname} + + 00:00 +
+ +
+
  +
+
+
+
+ +
+
+
  +
+
+
+
+ +
+
+
+
+
+
+
diff --git a/Web/Presenters/templates/Audio/player.xml b/Web/Presenters/templates/Audio/player.xml index 3edaaacc..1b0e5b4e 100644 --- a/Web/Presenters/templates/Audio/player.xml +++ b/Web/Presenters/templates/Audio/player.xml @@ -3,6 +3,7 @@ {php $id = $audio->getId() . rand(0, 1000)} {php $isWithdrawn = $audio->isWithdrawn()} +{php $editable = $audio->canBeModifiedBy($thisUser)}
diff --git a/Web/Presenters/templates/Audio/tabs.xml b/Web/Presenters/templates/Audio/tabs.xml index 71c37f00..23bed54b 100644 --- a/Web/Presenters/templates/Audio/tabs.xml +++ b/Web/Presenters/templates/Audio/tabs.xml @@ -1,8 +1,15 @@
+ +
+
+ {_audios} +
+
+
+ {tr("audios_count", $audiosCount)} +
+ {_all_title} +
+
+
+
+ {include "../Audio/player.xml", audio => $audio} +
+
+
+
{presenter "openvk!Wall->wallEmbedded", -$club->getId()} diff --git a/Web/Presenters/templates/Report/Tabs.xml b/Web/Presenters/templates/Report/Tabs.xml index e878ccb3..6003f202 100644 --- a/Web/Presenters/templates/Report/Tabs.xml +++ b/Web/Presenters/templates/Report/Tabs.xml @@ -46,6 +46,9 @@
Пользователи
+
+ {_audios} +