Skip to content

Commit 8dd1cb8

Browse files
committed
v1.0.1
- Changed PHP min. to 8.0. - Changed to constructor property promotion. - Changed class names from *_info, *_module and *_listener. - ctwc_data_table removed to store data in a row of config_text.
1 parent fb040c4 commit 8dd1cb8

20 files changed

Lines changed: 178 additions & 217 deletions

imcger/currenttime/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ A world clock can be displayed above the navigation bar. This is freely configur
2121
- [ACP User permissions](https://raw.githubusercontent.com/IMC-GER/images/refs/heads/main/screenshots/currenttime/CTWC_ACP_permissions.jpg)
2222

2323
## Requirements
24-
- php >= 7.4
24+
- php >= 8.0, <= 8.4
2525
- phpBB >= 3.3.0, < 4.0.0@dev
2626

2727
## Supported Style
2828
- Prosilver
2929
- Prosilver based styles
30+
31+
## Changelog
32+
### v1.0.1
33+
- Changed to constructor property promotion.
34+
- Changed class names from *_info, *_module and *_listener.
35+
- ctwc_data_table removed to store data in a row of config_text.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
namespace imcger\currenttime\acp;
1212

13-
class acp_info {
13+
class acp_ctwc_info {
1414

1515
public function module(): array
1616
{
1717
return [
18-
'filename' => '\imcger\currenttime\acp\acp_module',
18+
'filename' => '\imcger\currenttime\acp\acp_ctwc_module',
1919
'title' => 'ACP_CT_MODULE_WORLDCLOCK',
2020
'modes' => [
2121
'settings' => [

imcger/currenttime/acp/acp_module.php renamed to imcger/currenttime/acp/acp_ctwc_module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace imcger\currenttime\acp;
1212

13-
class acp_module
13+
class acp_ctwc_module
1414
{
1515
public string $u_action;
1616
public string $tpl_name;

imcger/currenttime/composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Displays the current time on all pages, the user's local time and a world clock. The times are updated continuously.",
55
"homepage": "https://github.com/IMC-GER/phpBB-Current-Time",
6-
"version": "1.0.0",
7-
"time": "2025-06-15",
6+
"version": "1.0.1",
7+
"time": "2025-10-12",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{
@@ -14,14 +14,14 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.4,<8.5.0@dev",
17+
"php": ">=8.0,<8.5.0@dev",
1818
"composer/installers": "~1.0",
19-
"phpbb/phpbb": ">=3.3.0,<4.0.0@dev"
19+
"phpbb/phpbb": ">=3.3.1,<4.0.0@dev"
2020
},
2121
"extra": {
2222
"display-name": "Current Time / World Clock",
2323
"soft-require": {
24-
"phpbb/phpbb": ">=3.3.0,<4.0.0@dev"
24+
"phpbb/phpbb": ">=3.3.1,<4.0.0@dev"
2525
}
2626
}
2727
}

imcger/currenttime/config/services.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
parameters:
2-
imcger.currenttime.table.ctwc_data: '%core.table_prefix%ctwc_data'
3-
41
services:
52
imcger.currenttime.ctwc_helper:
63
class: imcger\currenttime\controller\ctwc_helper
@@ -29,12 +26,12 @@ services:
2926
- '@language'
3027
- '@imcger.currenttime.ctwc_helper'
3128
- '@ext.manager'
32-
- '%imcger.currenttime.table.ctwc_data%'
29+
- '@config_text'
3330
- '%core.root_path%'
3431
- '%core.php_ext%'
3532

3633
imcger.currenttime.listener:
37-
class: imcger\currenttime\event\main_listener
34+
class: imcger\currenttime\event\ctwc_main_listener
3835
arguments:
3936
- '@auth'
4037
- '@user'
@@ -46,7 +43,7 @@ services:
4643
- { name: event.listener }
4744

4845
imcger.currenttime.acp.listener:
49-
class: imcger\currenttime\event\acp_listener
46+
class: imcger\currenttime\event\ctwc_acp_listener
5047
arguments:
5148
- '@user'
5249
- '@config'
@@ -57,7 +54,7 @@ services:
5754
- { name: event.listener }
5855

5956
imcger.currenttime.ucp.listener:
60-
class: 'imcger\currenttime\event\ucp_listener'
57+
class: 'imcger\currenttime\event\ctwc_ucp_listener'
6158
arguments:
6259
- '@auth'
6360
- '@config'
@@ -67,7 +64,7 @@ services:
6764
- '@request'
6865
- '@dbal.conn'
6966
- '@imcger.currenttime.ctwc_helper'
70-
- '%imcger.currenttime.table.ctwc_data%'
67+
- '@config_text'
7168
tags:
7269
- { name: event.listener }
7370

imcger/currenttime/controller/ctwc_controller.php

Lines changed: 14 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,24 @@
1212

1313
class ctwc_controller
1414
{
15-
protected object $db;
16-
protected object $request;
17-
protected object $user;
18-
protected object $template;
19-
protected object $language;
20-
protected object $ctwc_helper;
21-
protected object $ext_manager;
22-
protected string $ctwc_data_table;
23-
protected string $phpbb_root_path;
24-
protected string $phpEx;
2515
protected string $u_action;
2616
protected string $modul;
2717

28-
/**
29-
* Constructor
30-
*/
3118
public function __construct
3219
(
33-
\phpbb\db\driver\driver_interface $db,
34-
\phpbb\request\request $request,
35-
\phpbb\user $user,
36-
\phpbb\template\template $template,
37-
\phpbb\language\language $language,
38-
\imcger\currenttime\controller\ctwc_helper $ctwc_helper,
39-
\phpbb\extension\manager $ext_manager,
40-
$ctwc_data_table,
41-
$phpbb_root_path,
42-
$phpEx
20+
protected \phpbb\db\driver\driver_interface $db,
21+
protected \phpbb\request\request $request,
22+
protected \phpbb\user $user,
23+
protected \phpbb\template\template $template,
24+
protected \phpbb\language\language $language,
25+
protected \imcger\currenttime\controller\ctwc_helper $ctwc_helper,
26+
protected \phpbb\extension\manager $ext_manager,
27+
protected \phpbb\config\db_text $config_text,
28+
protected $phpbb_root_path,
29+
protected $phpEx,
4330
)
4431
{
45-
$this->db = $db;
46-
$this->request = $request;
47-
$this->user = $user;
48-
$this->template = $template;
49-
$this->language = $language;
50-
$this->ctwc_helper = $ctwc_helper;
51-
$this->ext_manager = $ext_manager;
52-
$this->ctwc_data_table = $ctwc_data_table;
53-
$this->phpbb_root_path = $phpbb_root_path;
54-
$this->phpEx = $phpEx;
55-
$this->modul = '';
32+
$this->modul = '';
5633
}
5734

5835
/**
@@ -90,28 +67,10 @@ public function display_options(string $modul): void
9067
$user_setting[7] = $this->request->variable('ctwc_wclock_lines', 0);
9168

9269
$user_data_str = json_encode($user_setting, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
93-
$user_data_str = $this->db->sql_escape($user_data_str);
9470

9571
if ($this->modul == 'acp')
9672
{
97-
// save default data
98-
$sql = 'SELECT data_content FROM ' . $this->ctwc_data_table . ' WHERE data_id = "default"';
99-
$result = $this->db->sql_query_limit($sql, 1);
100-
101-
if ($this->db->sql_fetchrow($result))
102-
{
103-
$sql = 'UPDATE ' . $this->ctwc_data_table . '
104-
SET data_content=\'' . $user_data_str . '\'
105-
WHERE data_id = "default"';
106-
}
107-
else
108-
{
109-
$sql = 'INSERT INTO ' . $this->ctwc_data_table . ' ' .
110-
$this->db->sql_build_array('INSERT', ['data_id' => 'default', 'data_content' => $user_data_str]);
111-
}
112-
$this->db->sql_freeresult($result);
113-
114-
$this->db->sql_query($sql);
73+
$this->config_text->set(\imcger\currenttime\ext::CTWC_DATA, $user_data_str);
11574

11675
// overwrite settings for all user
11776
if ($this->request->variable('ctwc_reset_default', 0))
@@ -150,11 +109,8 @@ protected function set_template_vars(?array $user_setting = null): void
150109
{
151110
if (!isset($user_setting) && $this->modul == 'acp')
152111
{
153-
$sql = 'SELECT data_content FROM ' . $this->ctwc_data_table . ' WHERE data_id = "default"';
154-
$result = $this->db->sql_query_limit($sql, 1);
155-
156-
$user_setting = json_decode((string) $this->db->sql_fetchfield('data_content'), true);
157-
$this->db->sql_freeresult($result);
112+
$ctwc_data = $this->config_text->get(\imcger\currenttime\ext::CTWC_DATA);
113+
$user_setting = json_decode($ctwc_data);
158114
}
159115
else if (!isset($user_setting) && $this->modul == 'ucp')
160116
{

imcger/currenttime/controller/ctwc_general_settings.php

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,18 @@
1212

1313
class ctwc_general_settings
1414
{
15-
protected object $config;
16-
protected object $request;
17-
protected object $user;
18-
protected object $template;
19-
protected object $language;
20-
protected object $ext_manager;
2115
protected string $u_action;
2216

23-
/**
24-
* Constructor
25-
*/
2617
public function __construct
2718
(
28-
\phpbb\config\config $config,
29-
\phpbb\request\request $request,
30-
\phpbb\user $user,
31-
\phpbb\template\template $template,
32-
\phpbb\language\language $language,
33-
\phpbb\extension\manager $ext_manager
19+
protected \phpbb\config\config $config,
20+
protected \phpbb\request\request $request,
21+
protected \phpbb\user $user,
22+
protected \phpbb\template\template $template,
23+
protected \phpbb\language\language $language,
24+
protected \phpbb\extension\manager $ext_manager,
3425
)
3526
{
36-
$this->config = $config;
37-
$this->request = $request;
38-
$this->user = $user;
39-
$this->template = $template;
40-
$this->language = $language;
41-
$this->ext_manager = $ext_manager;
4227
}
4328

4429
/**

imcger/currenttime/controller/ctwc_helper.php

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,13 @@
1212

1313
class ctwc_helper
1414
{
15-
protected object $user;
16-
protected object $template;
17-
protected object $language;
18-
19-
/**
20-
* Constructor
21-
*/
2215
public function __construct
2316
(
24-
\phpbb\user $user,
25-
\phpbb\template\template $template,
26-
\phpbb\language\language $language
17+
protected \phpbb\user $user,
18+
protected \phpbb\template\template $template,
19+
protected \phpbb\language\language $language,
2720
)
2821
{
29-
$this->user = $user;
30-
$this->template = $template;
31-
$this->language = $language;
3222
}
3323

3424
/**
@@ -105,11 +95,8 @@ public function timezone_select(string $prefix = '', string $default = ''): void
10595

10696
/*
10797
* Creates an array of variables for the SelectBox macro
108-
*
109-
* The variable $cfg_value is a union type array|string
110-
* Not specified for reasons of compatibility with php 7
11198
*/
112-
public function select_struct($cfg_value, array $options): array
99+
public function select_struct(array|string $cfg_value, array $options): array
113100
{
114101
$options_tpl = [];
115102

imcger/currenttime/event/acp_listener.php renamed to imcger/currenttime/event/ctwc_acp_listener.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,17 @@
1212

1313
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1414

15-
/**
16-
* ACP listener
17-
*/
18-
class acp_listener implements EventSubscriberInterface
15+
class ctwc_acp_listener implements EventSubscriberInterface
1916
{
20-
protected object $user;
21-
protected object $config;
22-
protected object $template;
23-
protected object $request;
24-
protected object $ctwc_helper;
25-
26-
/**
27-
* Constructor
28-
*/
2917
public function __construct
3018
(
31-
\phpbb\user $user,
32-
\phpbb\config\config $config,
33-
\phpbb\template\template $template,
34-
\phpbb\request\request $request,
35-
\imcger\currenttime\controller\ctwc_helper $ctwc_helper
19+
protected \phpbb\user $user,
20+
protected \phpbb\config\config $config,
21+
protected \phpbb\template\template $template,
22+
protected \phpbb\request\request $request,
23+
protected \imcger\currenttime\controller\ctwc_helper $ctwc_helper,
3624
)
3725
{
38-
$this->user = $user;
39-
$this->config = $config;
40-
$this->template = $template;
41-
$this->request = $request;
42-
$this->ctwc_helper = $ctwc_helper;
4326
}
4427

4528
/**

imcger/currenttime/event/main_listener.php renamed to imcger/currenttime/event/ctwc_main_listener.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,18 @@
1212

1313
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1414

15-
/**
16-
* Main listener
17-
*/
18-
class main_listener implements EventSubscriberInterface
15+
class ctwc_main_listener implements EventSubscriberInterface
1916
{
20-
protected object $auth;
21-
protected object $user;
22-
protected object $config;
23-
protected object $template;
24-
protected object $language;
25-
protected object $ctwc_helper;
26-
27-
28-
/**
29-
* Constructor
30-
*/
3117
public function __construct
3218
(
33-
\phpbb\auth\auth $auth,
34-
\phpbb\user $user,
35-
\phpbb\config\config $config,
36-
\phpbb\template\template $template,
37-
\phpbb\language\language $language,
38-
\imcger\currenttime\controller\ctwc_helper $ctwc_helper
19+
protected \phpbb\auth\auth $auth,
20+
protected \phpbb\user $user,
21+
protected \phpbb\config\config $config,
22+
protected \phpbb\template\template $template,
23+
protected \phpbb\language\language $language,
24+
protected \imcger\currenttime\controller\ctwc_helper $ctwc_helper
3925
)
4026
{
41-
$this->auth = $auth;
42-
$this->user = $user;
43-
$this->config = $config;
44-
$this->template = $template;
45-
$this->language = $language;
46-
$this->ctwc_helper = $ctwc_helper;
4727
}
4828

4929
/**
@@ -190,7 +170,7 @@ public function memberlist_prepare_profile_data(object $event): void
190170
return;
191171
}
192172

193-
$dateTime = new \DateTime('now', $dateTimeZone);
173+
$dateTime = new \DateTime('now', $dateTimeZone);
194174

195175
$dateformat = $this->user->data['user_dateformat'];
196176
$dateformat = $this->ctwc_helper->generate_datetime_str('ct', $dateformat);

0 commit comments

Comments
 (0)