Skip to content

Commit

Permalink
add platform issue tags
Browse files Browse the repository at this point in the history
  • Loading branch information
venix12 committed Aug 11, 2024
1 parent a66d151 commit b62fb05
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/Http/Controllers/Forum/TopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
18 changes: 18 additions & 0 deletions app/Models/Forum/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {

Check failure on line 820 in app/Models/Forum/Topic.php

View workflow job for this annotation

GitHub Actions / Lint all

Strict parameter missing in in_array() call.
$tag = "osu!{$tag}";
}

if (!$this->hasIssueTag($tag)) {
$this->topic_title = "[{$tag}] {$this->topic_title}";
}
Expand All @@ -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)) {

Check failure on line 835 in app/Models/Forum/Topic.php

View workflow job for this annotation

GitHub Actions / Lint all

Strict parameter missing in in_array() call.
$tag = "osu!{$tag}";
}

$this->topic_title = preg_replace(
'/ +/',
' ',
Expand All @@ -833,6 +847,10 @@ public function unsetIssueTag($tag)

public function hasIssueTag($tag)
{
if (in_array($tag, static::PLATFORM_ISSUE_TAGS)) {

Check failure on line 850 in app/Models/Forum/Topic.php

View workflow job for this annotation

GitHub Actions / Lint all

Strict parameter missing in in_array() call.
$tag = "osu!{$tag}";
}

return strpos($this->topic_title, "[{$tag}]") !== false;
}

Expand Down
10 changes: 8 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

Expand Down
21 changes: 21 additions & 0 deletions resources/lang/en/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,34 @@
'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',
'to_1' => 'Add "resolved" tag',
'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',
Expand Down
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_lazer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
Copyright (c) ppy Pty Ltd <[email protected]>. 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',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_stable.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
Copyright (c) ppy Pty Ltd <[email protected]>. 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',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_web.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
Copyright (c) ppy Pty Ltd <[email protected]>. 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',
])
2 changes: 1 addition & 1 deletion resources/views/forum/topics/_nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b62fb05

Please sign in to comment.