From b62fb05654e8e73e156e6ee3c5f8ff3a5f962a94 Mon Sep 17 00:00:00 2001 From: Venix <30481900+venix12@users.noreply.github.com> Date: Mon, 12 Aug 2024 00:10:37 +0200 Subject: [PATCH 1/3] add platform issue tags --- .../Controllers/Forum/TopicsController.php | 6 +++++- app/Models/Forum/Topic.php | 18 ++++++++++++++++ app/helpers.php | 10 +++++++-- resources/lang/en/forum.php | 21 +++++++++++++++++++ .../forum/topics/_issue_tag_lazer.blade.php | 7 +++++++ .../forum/topics/_issue_tag_stable.blade.php | 7 +++++++ .../forum/topics/_issue_tag_web.blade.php | 7 +++++++ resources/views/forum/topics/_nav.blade.php | 2 +- 8 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 resources/views/forum/topics/_issue_tag_lazer.blade.php create mode 100644 resources/views/forum/topics/_issue_tag_stable.blade.php create mode 100644 resources/views/forum/topics/_issue_tag_web.blade.php diff --git a/app/Http/Controllers/Forum/TopicsController.php b/app/Http/Controllers/Forum/TopicsController.php index 76dca0b2b6f..502638b28ed 100644 --- a/app/Http/Controllers/Forum/TopicsController.php +++ b/app/Http/Controllers/Forum/TopicsController.php @@ -166,7 +166,11 @@ public function issueTag($id) $state = get_bool(Request::input('state')); $type = 'issue_tag_'.$issueTag; - if ($issueTag === null || !$topic->isIssue() || !in_array($issueTag, $topic::ISSUE_TAGS, true)) { + if ( + $issueTag === null + || !$topic->isIssue() + || !in_array($issueTag, array_merge($topic::ISSUE_TAGS, $topic::PLATFORM_ISSUE_TAGS), true) + ) { abort(422); } diff --git a/app/Models/Forum/Topic.php b/app/Models/Forum/Topic.php index 2ad4fd54c62..3e2b301e39c 100644 --- a/app/Models/Forum/Topic.php +++ b/app/Models/Forum/Topic.php @@ -103,6 +103,12 @@ class Topic extends Model implements AfterCommit 'topic_title' => 100, ]; + const PLATFORM_ISSUE_TAGS = [ + 'lazer', + 'stable', + 'web', + ]; + const VIEW_COUNT_INTERVAL = 86400; // 1 day protected $table = 'phpbb_topics'; @@ -811,6 +817,10 @@ public function setIssueTag($tag) { $this->topic_type = static::typeInt($tag === 'confirmed' ? 'sticky' : 'normal'); + if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + $tag = "osu!{$tag}"; + } + if (!$this->hasIssueTag($tag)) { $this->topic_title = "[{$tag}] {$this->topic_title}"; } @@ -822,6 +832,10 @@ public function unsetIssueTag($tag) { $this->topic_type = static::typeInt($tag === 'resolved' ? 'sticky' : 'normal'); + if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + $tag = "osu!{$tag}"; + } + $this->topic_title = preg_replace( '/ +/', ' ', @@ -833,6 +847,10 @@ public function unsetIssueTag($tag) public function hasIssueTag($tag) { + if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + $tag = "osu!{$tag}"; + } + return strpos($this->topic_title, "[{$tag}]") !== false; } diff --git a/app/helpers.php b/app/helpers.php index f83df76e122..1dbbb1500a1 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1023,12 +1023,18 @@ function issue_icon($issue) return 'fas fa-user'; case 'confirmed': return 'fas fa-exclamation-triangle'; - case 'resolved': - return 'far fa-check-circle'; case 'duplicate': return 'fas fa-copy'; case 'invalid': return 'far fa-times-circle'; + case 'lazer': + return 'fas fa-extra-mode-osu'; + case 'resolved': + return 'far fa-check-circle'; + case 'stable': + return 'fas fa-extra-osu'; + case 'web': + return 'fas fa-globe'; } } diff --git a/resources/lang/en/forum.php b/resources/lang/en/forum.php index cf21ecdb6fb..61bf1789119 100644 --- a/resources/lang/en/forum.php +++ b/resources/lang/en/forum.php @@ -287,6 +287,13 @@ 'to_1_done' => 'Added "invalid" tag', ], + 'issue_tag_lazer' => [ + 'to_0' => 'Remove "osu!lazer" tag', + 'to_0_done' => 'Removed "osu!lazer" tag', + 'to_1' => 'Add "osu!lazer" tag', + 'to_1_done' => 'Added "osu!lazer" tag', + ], + 'issue_tag_resolved' => [ 'to_0' => 'Remove "resolved" tag', 'to_0_done' => 'Removed "resolved" tag', @@ -294,6 +301,20 @@ 'to_1_done' => 'Added "resolved" tag', ], + 'issue_tag_stable' => [ + 'to_0' => 'Remove "osu!stable" tag', + 'to_0_done' => 'Removed "osu!stable" tag', + 'to_1' => 'Add "osu!stable" tag', + 'to_1_done' => 'Added "osu!stable" tag', + ], + + 'issue_tag_web' => [ + 'to_0' => 'Remove "osu!web" tag', + 'to_0_done' => 'Removed "osu!web" tag', + 'to_1' => 'Add "osu!web" tag', + 'to_1_done' => 'Added "osu!web" tag', + ], + 'lock' => [ 'is_locked' => 'This topic is locked and can not be replied to', 'to_0' => 'Unlock topic', diff --git a/resources/views/forum/topics/_issue_tag_lazer.blade.php b/resources/views/forum/topics/_issue_tag_lazer.blade.php new file mode 100644 index 00000000000..1b5221f5bfc --- /dev/null +++ b/resources/views/forum/topics/_issue_tag_lazer.blade.php @@ -0,0 +1,7 @@ +{{-- + Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. + See the LICENCE file in the repository root for full licence text. +--}} +@include('forum.topics._issue_tag', [ + 'issueTag' => 'lazer', +]) diff --git a/resources/views/forum/topics/_issue_tag_stable.blade.php b/resources/views/forum/topics/_issue_tag_stable.blade.php new file mode 100644 index 00000000000..47a298a354d --- /dev/null +++ b/resources/views/forum/topics/_issue_tag_stable.blade.php @@ -0,0 +1,7 @@ +{{-- + Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. + See the LICENCE file in the repository root for full licence text. +--}} +@include('forum.topics._issue_tag', [ + 'issueTag' => 'stable', +]) diff --git a/resources/views/forum/topics/_issue_tag_web.blade.php b/resources/views/forum/topics/_issue_tag_web.blade.php new file mode 100644 index 00000000000..bc69f483be1 --- /dev/null +++ b/resources/views/forum/topics/_issue_tag_web.blade.php @@ -0,0 +1,7 @@ +{{-- + Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. + See the LICENCE file in the repository root for full licence text. +--}} +@include('forum.topics._issue_tag', [ + 'issueTag' => 'web', +]) diff --git a/resources/views/forum/topics/_nav.blade.php b/resources/views/forum/topics/_nav.blade.php index 978436ae0b1..aa0dbe0c68e 100644 --- a/resources/views/forum/topics/_nav.blade.php +++ b/resources/views/forum/topics/_nav.blade.php @@ -10,7 +10,7 @@ @include('forum.topics._moderate_move', compact('topic')) @if ($topic->isIssue()) - @foreach ($topic::ISSUE_TAGS as $type) + @foreach (array_merge($topic::ISSUE_TAGS, $topic::PLATFORM_ISSUE_TAGS) as $type) @include("forum.topics._issue_tag_{$type}") @endforeach @endif From 8a4db7396d709b95b695dc3a6a6f52025116e19e Mon Sep 17 00:00:00 2001 From: Venix <30481900+venix12@users.noreply.github.com> Date: Mon, 12 Aug 2024 00:15:03 +0200 Subject: [PATCH 2/3] in_array strict --- app/Models/Forum/Topic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/Forum/Topic.php b/app/Models/Forum/Topic.php index 3e2b301e39c..764f5f5595e 100644 --- a/app/Models/Forum/Topic.php +++ b/app/Models/Forum/Topic.php @@ -817,7 +817,7 @@ public function setIssueTag($tag) { $this->topic_type = static::typeInt($tag === 'confirmed' ? 'sticky' : 'normal'); - if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) { $tag = "osu!{$tag}"; } @@ -832,7 +832,7 @@ public function unsetIssueTag($tag) { $this->topic_type = static::typeInt($tag === 'resolved' ? 'sticky' : 'normal'); - if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) { $tag = "osu!{$tag}"; } @@ -847,7 +847,7 @@ public function unsetIssueTag($tag) public function hasIssueTag($tag) { - if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) { + if (in_array($tag, static::PLATFORM_ISSUE_TAGS, true)) { $tag = "osu!{$tag}"; } From b3a9cf98d5cc5b679c28c49a1bbec03f54452b92 Mon Sep 17 00:00:00 2001 From: Venix <30481900+venix12@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:37:01 +0200 Subject: [PATCH 3/3] replace icons with text --- app/helpers.php | 15 +++++++++------ resources/views/forum/topics/_issue_tag.blade.php | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index 1dbbb1500a1..588d187bb4d 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1027,14 +1027,8 @@ function issue_icon($issue) return 'fas fa-copy'; case 'invalid': return 'far fa-times-circle'; - case 'lazer': - return 'fas fa-extra-mode-osu'; case 'resolved': return 'far fa-check-circle'; - case 'stable': - return 'fas fa-extra-osu'; - case 'web': - return 'fas fa-globe'; } } @@ -1106,6 +1100,15 @@ function concat_path($paths) return implode('/', array_filter($paths, 'present')); } +function platform_issue_text($issue) +{ + return match ($issue) { + 'lazer' => 'laz', + 'stable' => 'stb', + 'web' => 'web', + }; +} + function proxy_media($url) { if (!present($url)) { diff --git a/resources/views/forum/topics/_issue_tag.blade.php b/resources/views/forum/topics/_issue_tag.blade.php index 4cfdeb216f3..88280e8d7b2 100644 --- a/resources/views/forum/topics/_issue_tag.blade.php +++ b/resources/views/forum/topics/_issue_tag.blade.php @@ -25,6 +25,10 @@ class=" data-method="post" > - + @if (in_array($issueTag, $topic::ISSUE_TAGS, true)) + + @elseif (in_array($issueTag, $topic::PLATFORM_ISSUE_TAGS, true)) + {{ platform_issue_text($issueTag) }} + @endif