Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions adm/style/acp_topic_prefixes.css
Original file line number Diff line number Diff line change
@@ -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";
}
11 changes: 6 additions & 5 deletions adm/style/acp_topic_prefixes.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>{{ lang('TOPIC_PREFIXES') }}</h1>
<td><strong>{{ prefix.PREFIX_TAG }}</strong></td>
<td>
<a href="{{ prefix.U_EDIT }}" style="text-decoration: none" title="{{ lang('TOPIC_PREFIX_TOGGLE_STATE') }}" data-ajax="tp_toggle">
<i class="icon acp-icon fa-toggle-{{ prefix.PREFIX_ENABLED ? 'on' : 'off' }} fa-fw"></i>
<i class="fa fa-fw tp-toggle-{{ prefix.PREFIX_ENABLED ? 'on' : 'off' }} acp-icon"></i>
</a>
</td>
<td class="actions">
Expand All @@ -56,10 +56,10 @@ <h1>{{ lang('TOPIC_PREFIXES') }}</h1>
<form id="acp_add_topic_prefix" method="post" action="{{ U_ACTION }}">
<fieldset class="quick">
{{ lang('CREATE_TOPIC_PREFIX') ~ lang('COLON') }}
<input type="text" name="prefix_tag" value="" maxlength="200" placeholder="{{ lang('TOPIC_PREFIX_PLACEHOLDER') }}" />
<input class="button2" name="submit" type="submit" value="{{ lang('SUBMIT') }}" />
<input type="hidden" name="action" value="add" />
<input type="hidden" name="forum_id" value="{{ FORUM_ID }}" />
<input type="text" name="prefix_tag" value="" maxlength="200" placeholder="{{ lang('TOPIC_PREFIX_PLACEHOLDER') }}">
<input class="button2" name="submit" type="submit" value="{{ lang('SUBMIT') }}">
<input type="hidden" name="action" value="add">
<input type="hidden" name="forum_id" value="{{ FORUM_ID }}">
{{ S_FORM_TOKEN }}
{{ S_HIDDEN_FIELDS }}
</fieldset>
Expand All @@ -68,4 +68,5 @@ <h1>{{ lang('TOPIC_PREFIXES') }}</h1>
{% endif %}

{% INCLUDEJS '@phpbb_topicprefixes/acp_topic_prefixes.js' %}
{% INCLUDECSS '@phpbb_topicprefixes/acp_topic_prefixes.css' %}
{% include 'overall_footer.html' %}
14 changes: 6 additions & 8 deletions adm/style/acp_topic_prefixes.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
})();
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -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",
Expand Down
21 changes: 17 additions & 4 deletions controller/admin_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace phpbb\topicprefixes\controller;

use phpbb\json_response;
use phpbb\language\language;
use phpbb\log\log;
use phpbb\request\request;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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,
]);
}
}
4 changes: 1 addition & 3 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions language/en/info_acp_topic_prefixes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
'ACP_MANAGE_PREFIXES' => 'Manage prefixes',

// ACP Log messages
'ACP_LOG_PREFIX_ADDED' => '<strong>Created new topic prefix</strong><br />» %1$s in forum: %2$s',
'ACP_LOG_PREFIX_DELETED' => '<strong>Deleted topic prefix</strong><br />» %1$s in forum: %2$s',
'ACP_LOG_PREFIX_ADDED' => '<strong>Created new topic prefix</strong><br>» %1$s in forum: %2$s',
'ACP_LOG_PREFIX_DELETED' => '<strong>Deleted topic prefix</strong><br>» %1$s in forum: %2$s',
));
4 changes: 2 additions & 2 deletions tests/functional/functional_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down