From cff1faa1f4eea9f703bfb946abea222b2c6822cf Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:04:18 -0700 Subject: [PATCH 1/9] Remove jQuery remnants --- adm/style/acp_topic_prefixes.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/adm/style/acp_topic_prefixes.js b/adm/style/acp_topic_prefixes.js index 90ba33c..9e45853 100644 --- a/adm/style/acp_topic_prefixes.js +++ b/adm/style/acp_topic_prefixes.js @@ -1,9 +1,8 @@ -(function($) { - +(function() { 'use strict'; - $('#select_forum').on('change', function() { - $(this).closest('form').trigger('submit'); + document.getElementById('select_forum').addEventListener('change', function() { + this.closest('form').submit(); }); phpbb.addAjaxCallback('tp_toggle', function(res) { @@ -15,5 +14,4 @@ icon.classList.toggle('fa-toggle-on'); icon.classList.toggle('fa-toggle-off'); }); - -})(jQuery); +})(); From d1848ce35901578cd1a6d35752a0af00a5ddd9b7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:05:34 -0700 Subject: [PATCH 2/9] Define toggle icon in css for phpBB 3/4 compatibility fix --- adm/style/acp_topic_prefixes.css | 12 ++++++++++++ adm/style/acp_topic_prefixes.html | 3 ++- adm/style/acp_topic_prefixes.js | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 adm/style/acp_topic_prefixes.css diff --git a/adm/style/acp_topic_prefixes.css b/adm/style/acp_topic_prefixes.css new file mode 100644 index 0000000..3c73b32 --- /dev/null +++ b/adm/style/acp_topic_prefixes.css @@ -0,0 +1,12 @@ +.tp-toggle-on, +.tp-toggle-off { + font-weight: 900; +} + +.tp-toggle-on:before { + content: "\f205"; +} + +.tp-toggle-off:before { + content: "\f204"; +} diff --git a/adm/style/acp_topic_prefixes.html b/adm/style/acp_topic_prefixes.html index 1523b45..497f191 100644 --- a/adm/style/acp_topic_prefixes.html +++ b/adm/style/acp_topic_prefixes.html @@ -34,7 +34,7 @@

{{ lang('TOPIC_PREFIXES') }}

{{ prefix.PREFIX_TAG }} - + @@ -68,4 +68,5 @@

{{ lang('TOPIC_PREFIXES') }}

{% endif %} {% INCLUDEJS '@phpbb_topicprefixes/acp_topic_prefixes.js' %} +{% INCLUDECSS '@phpbb_topicprefixes/acp_topic_prefixes.css' %} {% include 'overall_footer.html' %} diff --git a/adm/style/acp_topic_prefixes.js b/adm/style/acp_topic_prefixes.js index 9e45853..5958e7c 100644 --- a/adm/style/acp_topic_prefixes.js +++ b/adm/style/acp_topic_prefixes.js @@ -11,7 +11,7 @@ } const icon = this.querySelector('i'); - icon.classList.toggle('fa-toggle-on'); - icon.classList.toggle('fa-toggle-off'); + icon.classList.toggle('tp-toggle-on'); + icon.classList.toggle('tp-toggle-off'); }); })(); From c8cb64d3a256aa38fac1f09bf48c81a943fe1950 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:05:49 -0700 Subject: [PATCH 3/9] Remove no longer needed phpbb4 constraints --- composer.json | 4 ++-- ext.php | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index ab836e4..58c71b7 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php": ">=5.4", - "composer/installers": "~1.0" + "composer/installers": "^1.0 || ^2.0" }, "require-dev": { "phing/phing": "~2.4" @@ -27,7 +27,7 @@ "extra": { "display-name": "phpBB Topic Prefixes", "soft-require": { - "phpbb/phpbb": ">=3.2.0,<4.0.0@dev" + "phpbb/phpbb": ">=3.2.0" }, "version-check": { "host": "www.phpbb.com", diff --git a/ext.php b/ext.php index 955cff4..9ca695e 100644 --- a/ext.php +++ b/ext.php @@ -31,8 +31,6 @@ class ext extends \phpbb\extension\base */ public function is_enableable() { - return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=') - && phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '<') - && PHP_VERSION_ID >= 50400; + return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=') && PHP_VERSION_ID >= 50400; } } From 7934e65fff4f356ec718408610dd73ebbfdb6e05 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:12:03 -0700 Subject: [PATCH 4/9] Increment version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 58c71b7..b08e4bd 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "phpbb-extension", "description": "An official phpBB extension for topic prefixes.", "homepage": "https://www.phpbb.com/customise/db/extension/topicprefixes/", - "version": "1.0.1", + "version": "1.0.2-dev", "license": "GPL-2.0-only", "authors": [ { From 47fbff41d8651057e9fd45c50a009ce96660e070 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:30:52 -0700 Subject: [PATCH 5/9] Extract a common json_responses --- controller/admin_controller.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/controller/admin_controller.php b/controller/admin_controller.php index c02b29e..255983d 100644 --- a/controller/admin_controller.php +++ b/controller/admin_controller.php @@ -10,6 +10,7 @@ namespace phpbb\topicprefixes\controller; +use phpbb\json_response; use phpbb\language\language; use phpbb\log\log; use phpbb\request\request; @@ -188,8 +189,7 @@ public function edit_prefix($prefix_id) if ($this->request->is_ajax()) { - $json_response = new \phpbb\json_response; - $json_response->send(['success' => true]); + $this->send_json_response(true); } } @@ -251,8 +251,7 @@ public function move_prefix($prefix_id, $direction, $amount = 1) if ($this->request->is_ajax()) { - $json_response = new \phpbb\json_response; - $json_response->send(['success' => true]); + $this->send_json_response(true); } } @@ -334,4 +333,18 @@ protected function get_forum_info($forum_id) return $acp_forums->get_forum_info($forum_id); } + + /** + * Send a JSON response + * + * @param bool $content The content of the JSON response (true|false) + * @access protected + */ + protected function send_json_response(bool $content): void + { + $json_response = new json_response; + $json_response->send([ + 'success' => (bool) $content, + ]); + } } From e40e072ab3502ceab32d51d4fc362f490e34f8db Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:48:49 -0700 Subject: [PATCH 6/9] Eliminate XHTML --- adm/style/acp_topic_prefixes.html | 8 ++++---- language/en/info_acp_topic_prefixes.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adm/style/acp_topic_prefixes.html b/adm/style/acp_topic_prefixes.html index 497f191..9677ca3 100644 --- a/adm/style/acp_topic_prefixes.html +++ b/adm/style/acp_topic_prefixes.html @@ -56,10 +56,10 @@

{{ lang('TOPIC_PREFIXES') }}

{{ lang('CREATE_TOPIC_PREFIX') ~ lang('COLON') }} - - - - + + + + {{ S_FORM_TOKEN }} {{ S_HIDDEN_FIELDS }}
diff --git a/language/en/info_acp_topic_prefixes.php b/language/en/info_acp_topic_prefixes.php index 0170944..efc4dba 100644 --- a/language/en/info_acp_topic_prefixes.php +++ b/language/en/info_acp_topic_prefixes.php @@ -26,6 +26,6 @@ 'ACP_MANAGE_PREFIXES' => 'Manage prefixes', // ACP Log messages - 'ACP_LOG_PREFIX_ADDED' => 'Created new topic prefix
» %1$s in forum: %2$s', - 'ACP_LOG_PREFIX_DELETED' => 'Deleted topic prefix
» %1$s in forum: %2$s', + 'ACP_LOG_PREFIX_ADDED' => 'Created new topic prefix
» %1$s in forum: %2$s', + 'ACP_LOG_PREFIX_DELETED' => 'Deleted topic prefix
» %1$s in forum: %2$s', )); From 92ba86f7871909f9350f8c3dd8564d6b8bd2767e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 10:55:30 -0700 Subject: [PATCH 7/9] Update tests --- tests/functional/functional_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/functional_test.php b/tests/functional/functional_test.php index 9546238..cfdf7a1 100644 --- a/tests/functional/functional_test.php +++ b/tests/functional/functional_test.php @@ -79,11 +79,11 @@ public function test_acp_disable_prefix() // Disable the prefix $crawler = self::request('GET', 'adm/index.php?i=\phpbb\topicprefixes\acp\topic_prefixes_module&mode=manage&action=edit&forum_id=' . self::FORUM_ID . "&prefix_id={$prefix}&hash={$hash}&sid={$this->sid}"); - self::assertCount(1, $crawler->filter('tr')->eq(2)->filter('.fa-toggle-off')); + self::assertCount(1, $crawler->filter('tr')->eq(2)->filter('.tp-toggle-off')); // Enable the prefix $crawler = self::request('GET', 'adm/index.php?i=\phpbb\topicprefixes\acp\topic_prefixes_module&mode=manage&action=edit&forum_id=' . self::FORUM_ID . "&prefix_id={$prefix}&hash={$hash}&sid={$this->sid}"); - self::assertCount(1, $crawler->filter('tr')->eq(2)->filter('.fa-toggle-on')); + self::assertCount(1, $crawler->filter('tr')->eq(2)->filter('.tp-toggle-on')); } public function test_acp_delete_prefix() From a9573a9be2542aa6a86d478133e51a9974868a02 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 13:58:30 -0700 Subject: [PATCH 8/9] Maintain compatibility with current constraints --- controller/admin_controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/admin_controller.php b/controller/admin_controller.php index 255983d..d4c1fa5 100644 --- a/controller/admin_controller.php +++ b/controller/admin_controller.php @@ -340,7 +340,7 @@ protected function get_forum_info($forum_id) * @param bool $content The content of the JSON response (true|false) * @access protected */ - protected function send_json_response(bool $content): void + protected function send_json_response($content) { $json_response = new json_response; $json_response->send([ From be9571277abf62ae25262b9f2cf89cbfb712da4e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 10 Oct 2025 14:04:16 -0700 Subject: [PATCH 9/9] Drop Scrutinizer --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b1e0e6d..1d07044 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ This is the repository for the development of the Topic Prefixes phpBB extension [![Build Status](https://github.com/phpbb-extensions/topicprefixes/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb-extensions/topicprefixes/actions) [![codecov](https://codecov.io/gh/phpbb-extensions/topicprefixes/branch/master/graph/badge.svg?token=Dc0GWOeQWj)](https://codecov.io/gh/phpbb-extensions/topicprefixes) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpbb-extensions/topicprefixes/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpbb-extensions/topicprefixes/?branch=master) The phpBB Topic Prefixes extension allows phpBB board administrators to create topic prefix tags that users can easily add to their topic titles. Features include: