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: 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..9677ca3 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 }} - + @@ -56,10 +56,10 @@

{{ lang('TOPIC_PREFIXES') }}

{{ lang('CREATE_TOPIC_PREFIX') ~ lang('COLON') }} - - - - + + + + {{ S_FORM_TOKEN }} {{ S_HIDDEN_FIELDS }}
@@ -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 90ba33c..5958e7c 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) { @@ -12,8 +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'); }); - -})(jQuery); +})(); diff --git a/composer.json b/composer.json index 776d0e7..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": [ { @@ -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/controller/admin_controller.php b/controller/admin_controller.php index c02b29e..d4c1fa5 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($content) + { + $json_response = new json_response; + $json_response->send([ + 'success' => (bool) $content, + ]); + } } 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; } } 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', )); 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()