Skip to content

Commit f26126a

Browse files
committed
v1.1.0
- ACP template - Revised Twig - Switch from radio to toggle button - Added preview image in attachments upload - Generate template var in listener - Added JavaScript - Added CSS - Fixed missing language variable in ACP controller
1 parent 5198fe9 commit f26126a

File tree

12 files changed

+250
-24
lines changed

12 files changed

+250
-24
lines changed

.editorconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EditorConfig is awesome: https://EditorConfig.org
22

3-
# phpBB - Editor Vorgaben - https://www.phpbb.de/community/viewtopic.php?f=140&t=244063
3+
# phpBB - Editor Vorgaben v1.1 - https://www.phpbb.de/kb/viewarticle?a=93
44
# 2020 LukeWCS, phpBB.de
55

66
root = true
@@ -15,7 +15,7 @@ indent_style = tab
1515
indent_size = 4
1616
trim_trailing_whitespace = true
1717

18-
[*.{html,txt,md,yml}]
18+
[*.{txt,md,yml}]
1919
trim_trailing_whitespace = false
2020

2121
[*.yml]

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This extension can change the image size and/or the image file size. It rotate i
2121
## Screenshots
2222
- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_acp_en.jpg)
2323
- [UCP - Edit avatar](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_ucp_en.jpg)
24+
- [Post - upload attachments](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_upload_en.jpg)
2425

2526
## Requirements
2627
- phpBB 3.2.4 or higher
@@ -45,6 +46,11 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio
4546

4647
## Changelog
4748

49+
### v1.1.0 (06-02-2023)
50+
- Added preview image in attachments upload
51+
- Changed in ACP from radio to toggle button
52+
- Fixed missing language variable in ACP controller
53+
4854
### v1.0.1 (22-10-2022)
4955
- Code changes
5056

imcger/imgupload/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This extension can change the image size and/or the image file size. It rotate i
2121
## Screenshots
2222
- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_acp_en.jpg)
2323
- [UCP - Edit avatar](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_ucp_en.jpg)
24+
- [Post - upload attachments](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/imgupload/en/imgupload_upload_en.jpg)
2425

2526
## Requirements
2627
- phpBB 3.2.4 or higher
@@ -45,6 +46,11 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio
4546

4647
## Changelog
4748

49+
### v1.1.0 (06-02-2023)
50+
- Added preview image in attachments upload
51+
- Changed in ACP from radio to toggle button
52+
- Fixed missing language variable in ACP controller
53+
4854
### v1.0.1 (22-10-2022)
4955
- Code changes
5056

imcger/imgupload/adm/style/acp_imgupload_body.html

+12-8
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,42 @@ <h1>{{ lang('ACP_IMCGER_IMGUPLOAD_TITLE') }}</h1>
2525
<dt><label for="imcger_imgupload_max_width">{{ lang('ACP_IMCGER_MAX_SIZE') ~ lang('COLON') }}</label><br/><span>{{ lang('ACP_IMCGER_MAX_SIZE_DESC') }}</span></dt>
2626
<dd><input type="number" id="imcger_imgupload_max_width" min="0" max="9999999999" step="any" maxlength="10" name="imcger_imgupload_max_width" value="{{ IMCGER_MAX_WIDTH }}"> x <input type="number" id="imcger_imgupload_max_height" min="0" max="9999999999" step="any" maxlength="10" name="imcger_imgupload_max_height" value="{{ IMCGER_MAX_HEIGHT }}"> px</dd>
2727
</dl>
28-
28+
2929
<dl>
3030
<dt><label for="imcger_imgupload_max_filesize">{{ lang('ACP_IMCGER_MAX_FILESIZE') ~ lang('COLON') }}</label><br/><span>{{ lang('ACP_IMCGER_MAX_FILESIZE_DESC') }}</span></dt>
3131
<dd><input type="number" id="imcger_imgupload_max_filesize" min="0" max="9999999999" step="any" name="imcger_imgupload_max_filesize" value="{{ IMCGER_MAX_FILESIZE }}"/> <select name="size_select"><option value="b" {% if IMCGER_UNIT == 'b' %} selected="selected"{% endif %}>Bytes</option><option value="kb" {% if IMCGER_UNIT == 'kb' %} selected="selected"{% endif %}>KiB</option><option value="mb" {% if IMCGER_UNIT == 'mb' %} selected="selected"{% endif %}>MiB</option></select></dd>
3232
</dl>
3333

3434
<dl>
35-
<dt><label for="imcger_imgupload_del_exif">{{ lang('ACP_IMCGER_DEL_EXIF') }} {{ lang('COLON') }}</label><br><span>{{ lang('ACP_IMCGER_DEL_EXIF_DESC') }}</span></dt>
35+
<dt><label for="imcger_imgupload_del_exif">{{ lang('ACP_IMCGER_DEL_EXIF') ~ lang('COLON') }}</label><br><span>{{ lang('ACP_IMCGER_DEL_EXIF_DESC') }}</span></dt>
3636
<dd>
37-
<label><input type="radio" class="radio" id="imcger_imgupload_del_exif" name="imcger_imgupload_del_exif" value='1'{% if IMCGER_DEL_EXIF %} checked="checked"{% endif %}> {{ lang('YES') }}</label>
38-
<label><input type="radio" class="radio" name="imcger_imgupload_del_exif" value='0'{% if not IMCGER_DEL_EXIF %} checked="checked"{% endif %}> {{ lang('NO') }}</label>
37+
{{ _self.switch('imcger_imgupload_del_exif', IMCGER_DEL_EXIF) }}
3938
</dd>
4039
</dl>
4140
</fieldset>
4241

4342
<fieldset>
4443
<legend>{{ lang('ACP_IMCGER_SETTINGS_AVATAR') }}</legend>
4544
<dl>
46-
<dt><label for="imcger_imgupload_avatar_resize">{{ lang('ACP_IMCGER_AVATAR_RESIZE') }} {{ lang('COLON') }}</label><br><span>{{ lang('ACP_IMCGER_AVATAR_RESIZE_DESC') }}</span>
45+
<dt><label for="imcger_imgupload_avatar_resize">{{ lang('ACP_IMCGER_AVATAR_RESIZE') ~ lang('COLON') }}</label><br><span>{{ lang('ACP_IMCGER_AVATAR_RESIZE_DESC') }}</span>
4746
{% if IMCGER_AVATAR_FILESIZE_ISSET %}<br><span style="color: red">{{ lang('ACP_IMCGER_AVATAR_FILESIZE_ISSET') }}</span>{% endif %}</dt>
4847
<dd>
49-
<label><input type="radio" class="radio" id="imcger_imgupload_avatar_resize" name="imcger_imgupload_avatar_resize" value='1'{% if IMCGER_AVATAR_RESIZE %} checked="checked"{% endif %}> {{ lang('YES') }}</label>
50-
<label><input type="radio" class="radio" name="imcger_imgupload_avatar_resize" value='0'{% if not IMCGER_AVATAR_RESIZE %} checked="checked"{% endif %}> {{ lang('NO') }}</label>
48+
{{ _self.switch('imcger_imgupload_avatar_resize', IMCGER_AVATAR_RESIZE) }}
5149
</dd>
5250
</dl>
5351
</fieldset>
5452

5553
<fieldset class="submit-buttons">
5654
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}">
57-
{{ S_FORM_TOKEN }}
5855
</fieldset>
5956

57+
{{ S_FORM_TOKEN }}
6058
</form>
6159

6260
{% INCLUDE 'overall_footer.html' %}
61+
62+
{% INCLUDECSS '@imcger_imgupload/acp_toggle.css' %}
63+
64+
{% macro switch(name, checked = false) -%}
65+
<input type="checkbox" class="toggle" name="{{ name }}" value="1"{{ checked ? ' checked' }}>
66+
{%- endmacro %}
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
phpBB ACP Toggles - A CSS class that makes it easy to display checkboxes as toggles.
3+
Source : https://danklammer.com/articles/simple-css-toggle-switch/
4+
Revision by: Kirk (customization and optimization), LukeWCS (optimization)
5+
*/
6+
7+
.toggle {
8+
-webkit-appearance: none;
9+
-moz-appearance: none;
10+
appearance: none;
11+
width: 38px;
12+
height: 17px;
13+
position: relative;
14+
border-radius: 50px;
15+
cursor: pointer;
16+
font-family: FontAwesome;
17+
transition: background-color 0.3s;
18+
}
19+
20+
.toggle:before {
21+
position: absolute;
22+
width: 14px;
23+
height: 13px;
24+
background-color: #ffffff;
25+
top: 2px;
26+
border-radius: 50%;
27+
display: flex;
28+
justify-content: center;
29+
align-items: center;
30+
left: 22px;
31+
content: "\f00d";
32+
transition: 0.3s;
33+
}
34+
35+
.toggle,
36+
.toggle:hover,
37+
.toggle:focus {
38+
background-color: #cccccc;
39+
border: none;
40+
color: #000000;
41+
}
42+
43+
.toggle:checked {
44+
background-color: #3b87ab;
45+
}
46+
47+
.toggle:checked:before {
48+
left: 2px;
49+
content: "\f00c";
50+
}
51+
52+
.toggle:disabled {
53+
background-color: #cccccc;
54+
}
55+
56+
.toggle:disabled:before {
57+
color: #cccccc;
58+
}

imcger/imgupload/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Using ImageMagick php librarie for resize image attachments and creating thumbnails.",
55
"homepage": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
6-
"version": "1.0.1",
7-
"time": "2022-10-22",
6+
"version": "1.1.0",
7+
"time": "2023-02-06",
88
"license": "GPL-2.0-only",
99
"authors": [{
1010
"name": "Thorsten Ahlers",

imcger/imgupload/config/services.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ services:
66
- '@template'
77
- '@language'
88
- '@request'
9+
910
imcger.imgupload.listener:
1011
class: imcger\imgupload\event\main_listener
1112
arguments:
1213
- '@config'
1314
- '@language'
1415
- '@upload_imagesize'
16+
- '@dbal.conn'
17+
- '@template'
1518
tags:
1619
- { name: event.listener }

imcger/imgupload/controller/admin_controller.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function display_options()
6868
{
6969
if (!check_form_key('imcger/imgupload'))
7070
{
71-
trigger_error('FORM_INVALID' . adm_back_link($this->u_action), E_USER_WARNING);
71+
trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
7272
}
7373

7474
// Store the variable to the db
@@ -87,8 +87,8 @@ public function display_options()
8787
'IMCGER_MAX_HEIGHT' => $this->config['imcger_imgupload_max_height'],
8888
'IMCGER_MAX_FILESIZE' => $filesize['value'],
8989
'IMCGER_UNIT' => $filesize['si_identifier'],
90-
'IMCGER_DEL_EXIF' => $this->config['img_strip_metadata'],
91-
'IMCGER_AVATAR_RESIZE' => $this->config['imcger_imgupload_avatar_resize'],
90+
'IMCGER_DEL_EXIF' => (bool) $this->config['img_strip_metadata'],
91+
'IMCGER_AVATAR_RESIZE' => (bool) $this->config['imcger_imgupload_avatar_resize'],
9292
'IMCGER_AVATAR_FILESIZE_ISSET' => (bool) $this->config['avatar_filesize'],
9393
]);
9494
}
@@ -110,8 +110,8 @@ protected function set_variable()
110110
$this->config->set('imcger_imgupload_max_width', $this->request->variable('imcger_imgupload_max_width', 0));
111111
$this->config->set('imcger_imgupload_max_height', $this->request->variable('imcger_imgupload_max_height', 0));
112112
$this->config->set('imcger_imgupload_max_filesize', $max_filesize);
113-
$this->config->set('img_strip_metadata', $this->request->variable('imcger_imgupload_del_exif', 0));
114-
$this->config->set('imcger_imgupload_avatar_resize', $this->request->variable('imcger_imgupload_avatar_resize', 1));
113+
$this->config->set('img_strip_metadata', (bool) $this->request->variable('imcger_imgupload_del_exif', 0));
114+
$this->config->set('imcger_imgupload_avatar_resize', (bool) $this->request->variable('imcger_imgupload_avatar_resize', 0));
115115
}
116116

117117
/**

imcger/imgupload/event/main_listener.php

+43-6
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,43 @@ class main_listener implements EventSubscriberInterface
3131
/** @var \FastImageSize\FastImageSize */
3232
protected $imagesize;
3333

34+
/** @var \phpbb\db\driver\driver_interface */
35+
protected $db;
36+
37+
/** @var \phpbb\template\template */
38+
protected $template;
39+
3440
/**
3541
* Constructor for listener
3642
*
37-
* @param \phpbb\config\config $config phpBB config
38-
* @param \phpbb\language\language $language phpBB language
39-
* @param \FastImageSize\FastImageSize $imagesize FastImageSize object
43+
* @param \phpbb\config\config $config phpBB config
44+
* @param \phpbb\language\language $language phpBB language
45+
* @param \FastImageSize\FastImageSize $imagesize FastImageSize object
46+
* @param \phpbb\db\driver\driver_interface $db phpBB DataBase
47+
* Qparam \phpbb\template\template $template phpBB template
4048
*
4149
* @access public
4250
*/
4351
public function __construct
4452
(
4553
\phpbb\config\config $config,
4654
\phpbb\language\language $language,
47-
\FastImageSize\FastImageSize $imagesize
55+
\FastImageSize\FastImageSize $imagesize,
56+
\phpbb\db\driver\driver_interface $db,
57+
\phpbb\template\template $template
4858
)
4959
{
50-
$this->config = $config;
51-
$this->language = $language;
60+
$this->config = $config;
61+
$this->language = $language;
5262
$this->imagesize = $imagesize;
63+
$this->db = $db;
64+
$this->template = $template;
5365
}
5466

5567
public static function getSubscribedEvents()
5668
{
5769
return [
70+
'core.page_header' => 'set_template_vars',
5871
'core.ucp_display_module_before' => 'new_profil_avatar_text',
5972
'core.thumbnail_create_before' => 'imcger_create_tumbnail',
6073
'core.modify_uploaded_file' => 'imcger_modify_uploaded_file',
@@ -73,6 +86,30 @@ public function new_profil_avatar_text()
7386
}
7487
}
7588

89+
/**
90+
* Set template vars
91+
*
92+
* @return null
93+
* @access public
94+
*/
95+
public function set_template_vars()
96+
{
97+
$allowed_images = '';
98+
99+
$sql = 'SELECT extension FROM ' . EXTENSIONS_TABLE . ' WHERE group_id = 1';
100+
$result = $this->db->sql_query($sql);
101+
102+
while ($row = $this->db->sql_fetchrow($result))
103+
{
104+
$allowed_images .= '"' . $row['extension'] . '", ';
105+
}
106+
$this->db-> sql_freeresult();
107+
108+
$this->template->assign_vars([
109+
'IUL_ALLOWED_IMAGES' => $allowed_images,
110+
]);
111+
}
112+
76113
/**
77114
* Create a thumbnail using IMagick
78115
*

imcger/imgupload/ext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function is_enableable()
4646
}
4747

4848
// php version equal or greater 7.1.0 and less 8.2
49-
if (version_compare(PHP_VERSION, '7.1.0', '<') || version_compare(PHP_VERSION, '8.2', '>='))
49+
if (version_compare(PHP_VERSION, '7.1.0', '<') || version_compare(PHP_VERSION, '8.3', '>='))
5050
{
5151
$error_message += ['error3' => $language->lang('IMCGER_IM_REQUIRE_PHP'),];
5252
}

0 commit comments

Comments
 (0)