Skip to content

Commit 9431652

Browse files
committed
Merge branch 'dev'
2 parents 58e6e3b + 3cdf559 commit 9431652

19 files changed

Lines changed: 244 additions & 454 deletions

imcger/recenttopicsng/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Based on NV Recent Topics for phpBB 3.0, by Joas Schilling ([nickvergessen](http
99

1010
### Requirements
1111
* phpBB 3.3.5 - 3.3.x
12-
* PHP 7.1.3 - 8.4.x
12+
* PHP 7.4.0 - 8.4.x
1313

1414
### Supported Style
1515
* Prosilver

imcger/recenttopicsng/acp/acp_rtng_info.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@
1313

1414
namespace imcger\recenttopicsng\acp;
1515

16-
/**
17-
* Class acp_rtng_info
18-
*
19-
* @package imcger\recenttopicsng\acp
20-
*/
2116
class acp_rtng_info
2217
{
23-
/**
24-
* @return array
25-
*/
26-
public function module()
18+
public function module(): array
2719
{
2820
return [
2921
'filename' => '\imcger\recenttopicsng\acp\acp_rtng_module',

imcger/recenttopicsng/acp/acp_rtng_module.php

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,26 @@
1313

1414
namespace imcger\recenttopicsng\acp;
1515

16-
/**
17-
* Class acp_rtng_module
18-
*
19-
* @package imcger\recenttopicsng\acp
20-
*/
2116
class acp_rtng_module
2217
{
23-
public $page_title;
24-
public $tpl_name;
25-
public $u_action;
18+
public string $page_title;
19+
public string $tpl_name;
20+
public string $u_action;
2621

27-
/**
28-
* @param $id
29-
* @param $mode
30-
* @throws \Exception
31-
*
32-
*/
33-
public function main($id, $mode)
22+
public function main(string $id, string $mode): void
3423
{
3524
global $phpbb_container;
3625

37-
// Add ACP lang file
3826
$language = $phpbb_container->get('language');
3927

4028
switch ($mode)
4129
{
4230
case 'settings':
43-
// Get an instance of the admin controller
44-
$admin_controller = $phpbb_container->get('imcger.recenttopicsng.admin.controller');
45-
46-
// Make the $u_action url available in the admin controller
47-
$admin_controller->set_page_url($this->u_action);
48-
49-
// Load a template from adm/style for our ACP page
50-
$this->tpl_name = 'acp_rtng';
51-
52-
// Set the page title for our ACP page
31+
$this->tpl_name = 'acp_rtng';
5332
$this->page_title = $language->lang('RTNG_NAME');
5433

55-
// Load the display options handle in the admin controller
34+
$admin_controller = $phpbb_container->get('imcger.recenttopicsng.admin.controller');
35+
$admin_controller->set_page_url($this->u_action);
5636
$admin_controller->display_options();
5737
break;
5838
}

imcger/recenttopicsng/adm/style/acp_rtng.css

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
/* ACP ConfirmBox (JS) */
1+
/* LukeWCSphpBBConfirmBox */
22

3-
div[id$="_confirmbox"] {
3+
div.lukewcs_confirmbox {
44
max-width: 450px;
55
border: 2px solid skyblue;
6-
margin: .75em .5em;
7-
padding: .25em .5em;
6+
margin: 0.75em 0.5em;
7+
padding: 0.25em 0.5em;
88
border-radius: 5px;
99
-webkit-box-shadow: 2px 2px 10px 1px rgba(121, 162, 179, 0.5);
1010
box-shadow: 2px 2px 10px 1px rgba(121, 162, 179, 0.5);
1111
}
1212

13-
div[id$="_confirmbox"] h2 {
14-
margin: 0 0 .25em 0;
13+
div.lukewcs_confirmbox h2 {
14+
margin: 0 0 0.25em 0;
1515
}
1616

17-
div[id$="_confirmbox"] p:nth-of-type(2) {
17+
div.lukewcs_confirmbox p:last-of-type {
1818
text-align: center;
1919
margin: 0;
2020
padding: 0 4px 4px 4px;
2121
}
2222

23-
div[id$="_confirmbox"] input[type="button"] {
23+
div.lukewcs_confirmbox input[type="button"] {
2424
padding: 3px 4px;
2525
}
2626

27-
input[type="submit"]:disabled,
28-
input[type="button"]:disabled,
29-
input[class*="confirmbox_active"]:disabled {
30-
opacity: .5;
27+
input:is([type="submit"], [type="button"]):disabled,
28+
input.lukewcs_confirmbox_active {
29+
opacity: 0.5;
3130
cursor: not-allowed;
3231
}
3332

imcger/recenttopicsng/adm/style/acp_rtng.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ <h1>{{ lang('RTNG_NAME') }}</h1>
129129
{% INCLUDEJS '@imcger_recenttopicsng/acp_rtng.js' %}
130130

131131
{% macro confirmbox(name, message, default = false) -%}
132-
<div id="{{ name }}_confirmbox" data-default="{{ default }}" style="display: none;">
132+
<div class="lukewcs_confirmbox" data-name="{{ name }}" data-default="{{ default }}" style="display: none;">
133133
<h2>{{ lang('CONFIRM') }}</h2>
134134
<p>{{ message }}</p>
135135
<p>
136-
<input type="button" class="button1" name="{{ name }}_confirm_yes" value="{{ lang('YES') }}">&nbsp;
137-
<input type="button" class="button2" name="{{ name }}_confirm_no" value="{{ lang('NO') }}">
136+
<input type="button" class="button1" name="lukewcs_confirmbox_yes" value="{{ lang('YES') }}">&nbsp;
137+
<input type="button" class="button2" name="lukewcs_confirmbox_no" value="{{ lang('NO') }}">
138138
</p>
139139
</div>
140140
{%- endmacro %}

imcger/recenttopicsng/adm/style/acp_rtng.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var RecentTopicsNG = {};
1818

1919
class LukeWCSphpBBConfirmBox {
2020
/*
21-
* phpBB ConfirmBox class for checkboxes and yes/no radio buttons - v1.4.3
21+
* phpBB ConfirmBox class for checkboxes and yes/no radio buttons - v1.5.1
2222
* @copyright (c) 2023, LukeWCS, https://www.wcsaga.org
2323
* @license GNU General Public License, version 2 (GPL-2.0-only)
2424
*/
@@ -28,31 +28,29 @@ class LukeWCSphpBBConfirmBox {
2828
this.$formObject = this.$submitObject.parents('form');
2929
this.animDuration = animDuration;
3030

31-
this.$formObject.find('div[id$="_confirmbox"]').each(function () {
32-
const elementName = this.id.replace('_confirmbox', '');
33-
34-
$('input[name="' + elementName + '"]') .on('change' , _this.#Show);
35-
$('input[name^="' + elementName + '_confirm_"]') .on('click' , _this.#Button);
31+
this.$formObject.find('div.lukewcs_confirmbox').each(function () {
32+
$('input[name="' + $(this).attr('data-name') + '"]').on('change', _this.#Show);
33+
$(this).find('input[type="button"]') .on('click' , _this.#Button);
3634
});
37-
this.$formObject .on('reset' , _this.HideAll);
35+
this.$formObject .on('reset' , _this.HideAll);
3836
}
3937

4038
#Show = (e) => {
4139
const $elementObject = $('input[name="' + e.target.name + '"]');
42-
const $confirmBoxObject = $('div[id="' + e.target.name + '_confirmbox"]');
40+
const $confirmBoxObject = $('div.lukewcs_confirmbox[data-name="' + e.target.name + '"]');
4341

4442
if ($elementObject.prop('checked') != $confirmBoxObject.attr('data-default')) {
4543
this.#changeBoxState($elementObject, $confirmBoxObject, true);
4644
}
4745
}
4846

4947
#Button = (e) => {
50-
const elementName = e.target.name.replace(/_confirm_.*/, '');
48+
const elementName = $(e.target).parents('div.lukewcs_confirmbox').attr('data-name');
5149
const $elementObject = $('input[name="' + elementName + '"]');
52-
const $confirmBoxObject = $('div[id="' + elementName + '_confirmbox"]');
50+
const $confirmBoxObject = $('div.lukewcs_confirmbox[data-name="' + elementName + '"]');
5351
const elementType = $elementObject.attr('type');
5452

55-
if (e.target.name.endsWith('_confirm_no')) {
53+
if (e.target.name == 'lukewcs_confirmbox_no') {
5654
if (elementType == 'checkbox') {
5755
$elementObject.prop('checked', $confirmBoxObject.attr('data-default'));
5856
} else if (elementType == 'radio') {
@@ -63,17 +61,17 @@ class LukeWCSphpBBConfirmBox {
6361
}
6462

6563
HideAll = () => {
66-
const $elementObject = this.$formObject.find('input.confirmbox_active');
67-
const $confirmBoxObject = this.$formObject.find('div[id$="_confirmbox"]');
64+
const $elementObject = this.$formObject.find('input.lukewcs_confirmbox_active');
65+
const $confirmBoxObject = this.$formObject.find('div.lukewcs_confirmbox');
6866

6967
this.#changeBoxState($elementObject, $confirmBoxObject, false);
7068
}
7169

7270
#changeBoxState = ($elementObject, $confirmBoxObject, showBox) => {
7371
$elementObject .prop('disabled', !!showBox);
74-
$elementObject .toggleClass('confirmbox_active', !!showBox);
72+
$elementObject .toggleClass('lukewcs_confirmbox_active', !!showBox);
7573
$confirmBoxObject [showBox ? 'show' : 'hide'](this.animDuration);
76-
this.$submitObject .prop('disabled', showBox ?? this.$formObject.find('input.confirmbox_active').length);
74+
this.$submitObject .prop('disabled', showBox ?? this.$formObject.find('input.lukewcs_confirmbox_active').length);
7775
}
7876
}
7977

imcger/recenttopicsng/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333
],
3434
"require": {
35-
"php": ">=7.1.3,<8.5.0@dev",
35+
"php": ">=7.4,<8.5.0@dev",
3636
"composer/installers": "~1.0"
3737
},
3838
"extra": {

imcger/recenttopicsng/controller/admin_controller.php

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,16 @@
1515

1616
class admin_controller
1717
{
18-
/** @var \phpbb\config\config */
19-
protected $config;
18+
protected object $config;
19+
protected object $template;
20+
protected object $language;
21+
protected object $request;
22+
protected object $db;
23+
protected object $ext_manager;
24+
protected object $helper;
25+
protected object $ctrl_common;
26+
protected string $u_action;
2027

21-
/** @var \phpbb\template\template */
22-
protected $template;
23-
24-
/** @var \phpbb\template\template */
25-
protected $language;
26-
27-
/** @var \phpbb\request\request */
28-
protected $request;
29-
30-
/** @var string Custom form action */
31-
protected $u_action;
32-
33-
/** @var \phpbb\db\driver\driver_interface */
34-
protected $db;
35-
36-
/** @var \phpbb\extension\manager */
37-
protected $ext_manager;
38-
39-
/** @var \phpbb\controller\helper */
40-
protected $helper;
41-
42-
protected $ctrl_common;
43-
44-
/**
45-
* Constructor
46-
*/
4728
public function __construct
4829
(
4930
\phpbb\config\config $config,
@@ -69,7 +50,7 @@ public function __construct
6950
/**
7051
* Display the options a user can configure for this extension
7152
*/
72-
public function display_options()
53+
public function display_options(): void
7354
{
7455
$this->language->add_lang(['viewforum', 'ucp']);
7556

@@ -98,18 +79,16 @@ public function display_options()
9879

9980
/**
10081
* Set page url
101-
*
102-
* @param string $u_action Custom form action
10382
*/
104-
public function set_page_url($u_action)
83+
public function set_page_url(string $u_action): void
10584
{
10685
$this->u_action = $u_action;
10786
}
10887

10988
/**
11089
* Set template variables
11190
*/
112-
protected function set_template_vars()
91+
protected function set_template_vars(): void
11392
{
11493
$metadata_manager = $this->ext_manager->create_extension_metadata_manager('imcger/recenttopicsng');
11594

@@ -147,7 +126,7 @@ protected function set_template_vars()
147126
/**
148127
* Store vars to config table
149128
*/
150-
protected function set_vars_config()
129+
protected function set_vars_config(): void
151130
{
152131
$this->config->set('rtng_all_topics', $this->request->variable('rtng_all_topics', 0));
153132
$this->config->set('rtng_min_topic_level', $this->request->variable('rtng_min_topic_level', 0));
@@ -172,10 +151,8 @@ protected function set_vars_config()
172151

173152
/**
174153
* Upate settings in user table
175-
*
176-
* @param bool $all_user Store data to all user when true
177154
*/
178-
protected function set_vars_usertable($all_user)
155+
protected function set_vars_usertable(bool $all_user): void
179156
{
180157
$sql_ary = [
181158
'user_rtng_enable' => (int) $this->request->variable('user_rtng_enable', 0),

imcger/recenttopicsng/controller/controller_common.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,11 @@
1313

1414
namespace imcger\recenttopicsng\controller;
1515

16-
/**
17-
* Class controller_common
18-
*
19-
* @package imcger\recenttopicsng\controller
20-
*/
2116
class controller_common
2217
{
23-
/** @var \phpbb\user */
24-
protected $user;
25-
26-
/** @var \phpbb\auth\auth */
27-
protected $auth;
28-
29-
/** @var \phpbb\db\driver\driver_interface */
30-
protected $db;
18+
protected object $user;
19+
protected object $auth;
20+
protected object $db;
3121

3222
public function __construct
3323
(
@@ -41,6 +31,12 @@ public function __construct
4131
$this->db = $db;
4232
}
4333

34+
/*
35+
* Creates an array of variables for the SelectBox macro
36+
*
37+
* The variable $cfg_value is a union type array|string
38+
* Not specified for reasons of compatibility with php 7
39+
*/
4440
public function select_struct($cfg_value, array $options): array
4541
{
4642
$options_tpl = [];

0 commit comments

Comments
 (0)