Skip to content

Commit cdf1ba3

Browse files
committed
v1.3.0
- Fixed SQL query for images ext. - Minore code change - Added check system requirements - Added support for External Links Open in New Window - Added support for Fancybox 5 - Removed deprecated method for user language - ACP module - Added controller - Changed from radio to toggle button - Revised Twig code
1 parent 1795bba commit cdf1ba3

32 files changed

+1086
-502
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
11
# phpBB-Fancybox
22

33
## Description
4-
5-
This phpBB extension adds the fancybox attribute to all images in the posts.
6-
The attached image files get the alternate text of the image as caption. With the other images, the link is displayed.
7-
It will turn on a fancybox for displaying the large image of thumbnails. It defaults as a gallery showing all the attached images on the page. [Fancybox 3](https://fancyapps.com/fancybox)
4+
This phpBB extension adds the image viewer Fancybox 3, 4 or 5 to your forum. It adds Fancybox attribute to all images in the posts.
5+
The attached image files get the alternate text or the file comment as caption. For other external images, the link is displayed.
6+
It displays all attached images on the page as one gallery. Fancybox v3 is part of this package. It is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
7+
[Fancybox ](https://fancyapps.com/fancybox)
88

99
## Requirements
1010
- php 5.4.7 or higher
1111
- phpBB 3.2.0 or higher
12-
- Fancybox v3.5.7 or Fancybox v4.0
12+
- Fancybox v3.5.7 or higher
1313

1414
## Installation
15-
1615
Copy the extension to `phpBB3/ext/imcger/fancybox`
1716

1817
Fancybox v3 is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) license for all open source applications.
19-
A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
18+
A commercial license is required for all commercial applications.
2019

21-
If you use Fancybox v4 you need a Fancyapps license. More infos [Fancyapps](https://fancyapps.com).
20+
If you use Fancybox v4 or v5 you need a Fancyapps license. More infos [Fancyapps](https://fancyapps.com).
2221
Buy a license and copy the `fancybox.css` and `fancybox.umd.js` to `phpBB3/ext/imcger/fancybox/styles/all/template/fancybox`.
2322

2423
Go to "ACP" > "Customise" > "Extensions Manager" and enable the "Fancybox" extension.
2524

2625
## Importent
27-
28-
When you use the extension `phpBB-External-Links` please update it to version v1.2.2 or higher.
26+
When you use the extension "External Links" (`imcger/externallinks`) please update it to version v1.2.2 or higher.
2927

3028
## Settings
31-
3229
From the ACP, you can customize the toolbar and the transition effect during image change.
3330
Go to "ACP" > "Extensions" > "Fancybox settings" and customize "Fancybox".
3431

32+
## Compatible with
33+
- phpBB.de \- External Image as Link (`phpbbde/externalimgaslink`)
34+
- External Link In New Window (`martin/externallinkinnewwindow`)
35+
- External Links Open in New Window (`rmcgirr83/elonw`)
36+
- External Links (`imcger/externallinks`)
37+
3538
## Changelog
3639

40+
### v1.3.0 (21-03-2023)
41+
- ACP added controller
42+
- ACP changed from radio button to toggel
43+
- ACP revised Twig code
44+
- Minore code change
45+
- Added check system requirements
46+
- Added support for `External Links Open in New Window`
47+
- Added support for `Fancybox 5`
48+
- Removed deprecated method for user language
49+
3750
### v1.2.5 (07-10-2022)
3851
- Code change
3952

@@ -85,6 +98,6 @@ Go to "ACP" > "Extensions" > "Fancybox settings" and customize "Fancybox".
8598
Is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) license for all open source applications.
8699
A commercial license is required for commercial use. [Fancybox 3](https://fancyapps.com/fancybox)
87100

88-
**Fancybox v4**
101+
**Fancybox v4 or higher**
89102
You need a Fancybox license for none commercial use and commercial use.
90103
[Fancyapps](https://fancyapps.com)

imcger/fancybox/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
11
# phpBB-Fancybox
22

33
## Description
4-
5-
This phpBB extension adds the fancybox attribute to all images in the posts.
6-
The attached image files get the alternate text of the image as caption. With the other images, the link is displayed.
7-
It will turn on a fancybox for displaying the large image of thumbnails. It defaults as a gallery showing all the attached images on the page. [Fancybox 3](https://fancyapps.com/fancybox)
4+
This phpBB extension adds the image viewer Fancybox 3, 4 or 5 to your forum. It adds Fancybox attribute to all images in the posts.
5+
The attached image files get the alternate text or the file comment as caption. For other external images, the link is displayed.
6+
It displays all attached images on the page as one gallery. Fancybox v3 is part of this package. It is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
7+
[Fancybox ](https://fancyapps.com/fancybox)
88

99
## Requirements
1010
- php 5.4.7 or higher
1111
- phpBB 3.2.0 or higher
12-
- Fancybox v3.5.7 or Fancybox v4.0
12+
- Fancybox v3.5.7 or higher
1313

1414
## Installation
15-
1615
Copy the extension to `phpBB3/ext/imcger/fancybox`
1716

1817
Fancybox v3 is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) license for all open source applications.
19-
A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
18+
A commercial license is required for all commercial applications.
2019

21-
If you use Fancybox v4 you need a Fancyapps license. More infos [Fancyapps](https://fancyapps.com).
20+
If you use Fancybox v4 or v5 you need a Fancyapps license. More infos [Fancyapps](https://fancyapps.com).
2221
Buy a license and copy the `fancybox.css` and `fancybox.umd.js` to `phpBB3/ext/imcger/fancybox/styles/all/template/fancybox`.
2322

2423
Go to "ACP" > "Customise" > "Extensions Manager" and enable the "Fancybox" extension.
2524

2625
## Importent
27-
28-
When you use the extension `phpBB-External-Links` please update it to version v1.2.2 or higher.
26+
When you use the extension "External Links" (`imcger/externallinks`) please update it to version v1.2.2 or higher.
2927

3028
## Settings
31-
3229
From the ACP, you can customize the toolbar and the transition effect during image change.
3330
Go to "ACP" > "Extensions" > "Fancybox settings" and customize "Fancybox".
3431

32+
## Compatible with
33+
- phpBB.de \- External Image as Link (`phpbbde/externalimgaslink`)
34+
- External Link In New Window (`martin/externallinkinnewwindow`)
35+
- External Links Open in New Window (`rmcgirr83/elonw`)
36+
- External Links (`imcger/externallinks`)
37+
3538
## Changelog
3639

40+
### v1.3.0 (21-03-2023)
41+
- ACP added controller
42+
- ACP changed from radio button to toggel
43+
- ACP revised Twig code
44+
- Minore code change
45+
- Added check system requirements
46+
- Added support for `External Links Open in New Window`
47+
- Added support for `Fancybox 5`
48+
- Removed deprecated method for user language
49+
3750
### v1.2.5 (07-10-2022)
3851
- Code change
3952

@@ -85,6 +98,6 @@ Go to "ACP" > "Extensions" > "Fancybox settings" and customize "Fancybox".
8598
Is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) license for all open source applications.
8699
A commercial license is required for commercial use. [Fancybox 3](https://fancyapps.com/fancybox)
87100

88-
**Fancybox v4**
101+
**Fancybox v4 or higher**
89102
You need a Fancybox license for none commercial use and commercial use.
90103
[Fancyapps](https://fancyapps.com)
Lines changed: 24 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
*
4-
* Implements the image viewer Fancybox in phpBB.
5-
* An extension for the phpBB Forum Software package.
6-
*
7-
* @copyright (c) 2022, Thorsten Ahlers
8-
* @license GNU General Public License, version 2 (GPL-2.0)
9-
*
10-
*/
3+
*
4+
* Implements the image viewer Fancybox in phpBB.
5+
* An extension for the phpBB Forum Software package.
6+
*
7+
* @copyright (c) 2022, Thorsten Ahlers
8+
* @license GNU General Public License, version 2 (GPL-2.0)
9+
*
10+
*/
1111

1212
namespace imcger\fancybox\acp;
1313

@@ -22,92 +22,29 @@ class main_module
2222

2323
public function main($id, $mode)
2424
{
25-
global $config, $request, $template, $user;
26-
27-
$user->add_lang_ext('imcger/fancybox', 'common');
28-
$this->tpl_name = 'acp_fancybox_body';
29-
$this->page_title = $user->lang('ACP_FANCYBOX_TITLE');
30-
add_form_key('imcger/fancybox');
31-
32-
if ($request->is_set_post('submit'))
33-
{
34-
if (!check_form_key('imcger/fancybox'))
35-
{
36-
trigger_error('FORM_INVALID', E_USER_WARNING);
37-
}
38-
39-
$config->set('imcger_fancybox_version', $request->variable('imcger_fancybox_version', 0));
40-
$config->set('imcger_fancybox_image_borderwidth', $request->variable('imcger_fancybox_image_borderwidth', 0));
41-
$config->set('imcger_fancybox_image_bordercolor', $request->variable('imcger_fancybox_image_bordercolor', 'ffffff'));
42-
$config->set('imcger_fancybox_transitionEffect', $request->variable('imcger_fancybox_transitionEffect', 'slide'));
43-
$config->set('imcger_fancybox_toolbar_button_zoom', $request->variable('imcger_fancybox_toolbar_button_zoom', 1));
44-
$config->set('imcger_fancybox_toolbar_button_share', $request->variable('imcger_fancybox_toolbar_button_share', 0));
45-
$config->set('imcger_fancybox_toolbar_button_slshow', $request->variable('imcger_fancybox_toolbar_button_slshow', 1));
46-
$config->set('imcger_fancybox_toolbar_button_fullscr', $request->variable('imcger_fancybox_toolbar_button_fullscr', 1));
47-
$config->set('imcger_fancybox_toolbar_button_download', $request->variable('imcger_fancybox_toolbar_button_download', 0));
48-
$config->set('imcger_fancybox_toolbar_button_thumbs', $request->variable('imcger_fancybox_toolbar_button_thumbs', 0));
49-
50-
trigger_error($user->lang('ACP_FANCYBOX_SETTING_SAVED') . adm_back_link($this->u_action));
51-
}
25+
global $phpbb_container;
5226

53-
/*
54-
Prüfen welche Fancybox Version installiert ist.
55-
*/
56-
$path = '../ext/imcger/fancybox/styles/all/template/fancybox/';
57-
$fancybox_v3_css = $path . 'jquery.fancybox.min.css';
58-
$fancybox_v3_js = $path . 'jquery.fancybox.min.js';
59-
$fancybox_v4_css = $path . 'fancybox.css';
60-
$fancybox_v4_js = $path . 'fancybox.umd.js';
61-
$is_fancybox3 = false;
62-
$is_fancybox4 = false;
27+
// Add ACP lang file
28+
$language = $phpbb_container->get('language');
6329

64-
if (file_exists($fancybox_v3_css) && file_exists($fancybox_v3_js))
30+
switch ($mode)
6531
{
66-
$is_fancybox3 = '3';
67-
68-
$handle = @fopen($fancybox_v3_js, "r");
69-
70-
while (($buffer = fgets($handle, 100)) !== false)
71-
{
72-
if (($pos = strpos($buffer, "v3", 0)) !== false)
73-
{
74-
$is_fancybox3 = substr($buffer, ($pos + 1));
75-
break;
76-
}
77-
}
32+
case 'settings':
33+
// Get an instance of the admin controller
34+
$admin_controller = $phpbb_container->get('imcger.fancybox.admin.controller');
7835

79-
fclose($handle);
80-
}
36+
// Make the $u_action url available in the admin controller
37+
$admin_controller->set_page_url($this->u_action);
8138

82-
if (file_exists($fancybox_v4_css) && file_exists($fancybox_v4_js))
83-
{
84-
$is_fancybox4 = '4';
39+
// Load a template from adm/style for our ACP page
40+
$this->tpl_name = 'acp_fancybox_body';
8541

86-
$handle = @fopen($fancybox_v4_js, "r");
87-
$buffer = fgets($handle, 100);
88-
fclose($handle);
42+
// Set the page title for our ACP page
43+
$this->page_title = $language->lang('ACP_FANCYBOX_TITLE');
8944

90-
$pos = strpos($buffer, "v4", 0);
91-
if ($pos !== false)
92-
{
93-
$is_fancybox4 = substr($buffer, ($pos + 1));
94-
}
45+
// Load the display options handle in the admin controller
46+
$admin_controller->display_options();
47+
break;
9548
}
96-
97-
$template->assign_vars(array(
98-
'U_ACTION' => $this->u_action,
99-
'IMCGER_FANCYBOX_IS_VERSION_3' => $is_fancybox3,
100-
'IMCGER_FANCYBOX_IS_VERSION_4' => $is_fancybox4,
101-
'IMCGER_FANCYBOX_VERSION' => $config['imcger_fancybox_version'],
102-
'IMCGER_FANCYBOX_TRANSITIONEFFECT' => $config['imcger_fancybox_transitionEffect'],
103-
'IMCGER_FANCYBOX_IMAGES_BORDERWIDTH' => $config['imcger_fancybox_image_borderwidth'],
104-
'IMCGER_FANCYBOX_IMAGES_BORDERCOLOR' => $config['imcger_fancybox_image_bordercolor'],
105-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_ZOOM' => $config['imcger_fancybox_toolbar_button_zoom'],
106-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_SHARE' => $config['imcger_fancybox_toolbar_button_share'],
107-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_SLSHOW' => $config['imcger_fancybox_toolbar_button_slshow'],
108-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_FULLSCR' => $config['imcger_fancybox_toolbar_button_fullscr'],
109-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_DOWNLOAD' => $config['imcger_fancybox_toolbar_button_download'],
110-
'IMCGER_FANCYBOX_TOOLBAR_BUTTON_THUMBS' => $config['imcger_fancybox_toolbar_button_thumbs'],
111-
));
11249
}
11350
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
ACP Fancybox
3+
---------------------------- */
4+
5+
.imcger-copyright {
6+
margin-top: 1em;
7+
text-align: center;
8+
font-size: .75em;
9+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
*
3+
* Implements the image viewer Fancybox in phpBB.
4+
* An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2022, Thorsten Ahlers
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
const imcgerFancybox = {
11+
fancybox3Transitioneffect: '',
12+
fancybox5Transitioneffect: '',
13+
formSelectBox: document.getElementById('imcger_fancybox_transitionEffect'),
14+
15+
// Customize settings dialog for FancyBox version 3, 4 or 5
16+
setVersion: function (FancyboxVersion) {
17+
if (FancyboxVersion == 3) {
18+
document.getElementById('FancyboxSettingsEffect').style.display = 'block';
19+
document.getElementById('FancyboxToolbarButtonShare').style.display = 'block';
20+
document.getElementById('FancyboxToolbarButtonRotate').style.display = 'none';
21+
this.setElementVisible('.fancybox5', 'none');
22+
this.setElementVisible('.fancybox3', 'initial');
23+
24+
if (!this.fancybox3Transitioneffect) {
25+
this.formSelectBox.selectedIndex = 1;
26+
this.fancybox3Transitioneffect = this.formSelectBox.value;
27+
} else {
28+
this.formSelectBox.value = this.fancybox3Transitioneffect;
29+
}
30+
} else if (FancyboxVersion == 4) {
31+
document.getElementById('FancyboxSettingsEffect').style.display = 'none';
32+
document.getElementById('FancyboxToolbarButtonShare').style.display = 'none';
33+
document.getElementById('FancyboxToolbarButtonRotate').style.display = 'none';
34+
} else if (FancyboxVersion == 5) {
35+
document.getElementById('FancyboxSettingsEffect').style.display = 'block';
36+
document.getElementById('FancyboxToolbarButtonShare').style.display = 'none';
37+
document.getElementById('FancyboxToolbarButtonRotate').style.display = 'block';
38+
this.setElementVisible('.fancybox3', 'none');
39+
this.setElementVisible('.fancybox5', 'initial');
40+
41+
if (!this.fancybox5Transitioneffect) {
42+
this.formSelectBox.selectedIndex = 1;
43+
this.fancybox5Transitioneffect = this.formSelectBox.value;
44+
} else {
45+
this.formSelectBox.value = this.fancybox5Transitioneffect;
46+
}
47+
}
48+
},
49+
// Make option in select box visible for Fancybox version
50+
setElementVisible: function (fancyboxVersion, displayStatus) {
51+
let elementArray = document.querySelectorAll(fancyboxVersion);
52+
53+
elementArray.forEach(function (element) {
54+
element.style.display = displayStatus;
55+
});
56+
},
57+
// Store the SelectBox value for Fancybox version
58+
changeSelectBox: function () {
59+
if (document.getElementById('imcger_fancybox_version_3').checked) {
60+
this.fancybox3Transitioneffect = this.formSelectBox.value;
61+
}
62+
63+
if (document.getElementById('imcger_fancybox_version_5').checked) {
64+
this.fancybox5Transitioneffect = this.formSelectBox.value;
65+
}
66+
},
67+
// Initialise the form
68+
init: function () {
69+
let radioButton;
70+
71+
if (!document.querySelector('input[name="imcger_fancybox_version"]:checked')) {
72+
document.getElementsByName('imcger_fancybox_version')[0].click();
73+
}
74+
75+
radioButton = document.querySelector('input[name="imcger_fancybox_version"]:checked').value;
76+
77+
if (radioButton == 3) {
78+
this.fancybox3Transitioneffect = this.formSelectBox.value;
79+
}
80+
81+
if (radioButton == 5) {
82+
this.fancybox5Transitioneffect = this.formSelectBox.value;
83+
}
84+
85+
this.setVersion(radioButton);
86+
87+
this.formSelectBox.addEventListener('change', (event) => {
88+
this.changeSelectBox();
89+
});
90+
},
91+
}
92+
93+
// When loading the page, customize the settings dialog for FancyBox version.
94+
imcgerFancybox.init();

0 commit comments

Comments
 (0)