Skip to content

Commit 57c3945

Browse files
authored
Merge pull request #31 from Crizz0/issue/30
Update code for >= 3.3
2 parents 8a4f9c4 + a11423e commit 57c3945

6 files changed

Lines changed: 44 additions & 22 deletions

File tree

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
# phpBB 3.1/3.2 Extension - phpBB.de External Images as Link
1+
# phpBB 3.2 & 3.3 Extension - phpBB.de External Images as Link
22

33
Images which are not from the own board are displayed as link not as image.
44

55
Author: Christian Schnegelberger, Oliver Schramm
66

77
URL: https://www.phpbb.de
88

9-
Version: 1.2.0
9+
## New settings
10+
This extension add a new setting to: "ACP > Tab: General > Post settings > Permitted images".
11+
12+
You choose between allowed images "Only images from
13+
this domain" and "Only from secure websites and this domain". The last option will allow to include
14+
"https://" image urls.
1015

1116
## Install instructions:
1217
1. Download the extension

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"authors": [
1010
{
1111
"name": "Christian Schnegelberger",
12-
"email": "blackhawk87@phpbb.de",
12+
"email": "crizzo@phpbb.de",
1313
"homepage": "https://www.phpbb.de",
1414
"role": "Developer"
1515
},
@@ -24,13 +24,13 @@
2424
"php": ">=5.4.7"
2525
},
2626
"require-dev": {
27-
"phpbb/epv": "~0.0.8",
28-
"phpbb/translation-validator": "~1.4.0"
27+
"phpbb/epv": "^0.0.11",
28+
"phpbb/translation-validator": "^1.5.2"
2929
},
3030
"extra": {
3131
"display-name": "phpBB.de - External Image as Link",
3232
"soft-require": {
33-
"phpbb/phpbb": ">=3.2.2"
33+
"phpbb/phpbb": ">=3.2.4"
3434
}
3535
}
3636
}

config/services.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ services:
22
phpbbde.externalimgaslink.helper:
33
class: phpbbde\externalimgaslink\helper
44
arguments:
5-
- '@user'
5+
- '@language'
66

77
phpbbde.externalimgaslink.listener:
88
class: phpbbde\externalimgaslink\event\listener
99
arguments:
1010
- '@config'
1111
- '@phpbbde.externalimgaslink.helper'
12+
- '@language'
1213
- '@template'
1314
- '@user'
1415
tags:

event/listener.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class listener implements EventSubscriberInterface
3030
/** @var helper */
3131
protected $helper;
3232

33+
/* @var \phpbb\language\language */
34+
protected $language;
35+
3336
/** @var template */
3437
protected $template;
3538

@@ -39,19 +42,24 @@ class listener implements EventSubscriberInterface
3942
/**
4043
* Constructor
4144
*
42-
* @param config $config
43-
* @param helper $helper
44-
* @param template $template
45-
* @param user $user
45+
* @param \phpbb\config\config $config
46+
* @param helper $helper
47+
* @param \phpbb\language\language $language
48+
* @param \phpbb\template\template $template
49+
* @param \phpbb\user $user
4650
*/
47-
public function __construct(config $config, helper $helper, template $template, user $user)
51+
public function __construct(
52+
\phpbb\config\config $config,
53+
helper $helper,
54+
\phpbb\language\language $language,
55+
\phpbb\template\template $template,
56+
\phpbb\user $user)
4857
{
4958
$this->config = $config;
5059
$this->helper = $helper;
60+
$this->language = $language;
5161
$this->template = $template;
5262
$this->user = $user;
53-
54-
$this->user->add_lang_ext('phpbbde/externalimgaslink', 'extimgaslink');
5563
}
5664

5765
/**
@@ -64,7 +72,6 @@ static public function getSubscribedEvents()
6472
return array(
6573
'core.acp_board_config_edit_add' => 'acp_add_config',
6674
'core.bbcode_cache_init_end' => 'modify_case_img',
67-
// 3.2 TextFormatter events (will only trigger in >=3.2)
6875
'core.text_formatter_s9e_configure_after' => 'configure_textformatter',
6976
'core.text_formatter_s9e_renderer_setup' => 'setup_textformatter_renderer',
7077
);
@@ -78,6 +85,8 @@ static public function getSubscribedEvents()
7885
*/
7986
public function acp_add_config($event)
8087
{
88+
$this->language->add_lang('extimgaslink', 'phpbbde/externalimgaslink');
89+
8190
if ($event['mode'] !== 'post')
8291
{
8392
return;
@@ -165,7 +174,7 @@ public function modify_case_img($event)
165174

166175
$bbcode_cache[$bbcode_id]['preg'] += array(
167176
// every other external image will be replaced
168-
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', $this->user->lang('EXTIMGLINK'), $bbcode->bbcode_tpl('url', $bbcode_id, true)),
177+
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', $this->language->lang('EXTIMGLINK'), $bbcode->bbcode_tpl('url', $bbcode_id, true)),
169178
);
170179

171180
$event['bbcode_cache'] = $bbcode_cache;

helper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111

1212
class helper
1313
{
14-
/** @var \phpbb\user */
15-
protected $user;
14+
/* @var \phpbb\language\language */
15+
protected $language;
1616

1717
/**
1818
* Constructor
1919
*
20-
* @param \phpbb\user $user
20+
* @param \phpbb\language\language $language
2121
*/
22-
public function __construct(\phpbb\user $user)
22+
public function __construct(\phpbb\language\language $language)
2323
{
24-
$this->user = $user;
24+
$this->language = $language;
2525
}
2626

2727
/**
@@ -57,7 +57,7 @@ public function extimgaslink_config_select($selected_type)
5757
foreach ($types as $key => $value)
5858
{
5959
$selected = ($selected_type === $key) ? ' selected="selected"' : '';
60-
$options .= '<option value="' . $key . '"' . $selected . '>' . $this->user->lang('EXTIMGASLINK_' . $value) . '</option>';
60+
$options .= '<option value="' . $key . '"' . $selected . '>' . $this->language->lang('EXTIMGASLINK_' . $value) . '</option>';
6161
}
6262

6363
return $options;

migrations/add_filter_config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
class add_filter_config extends \phpbb\db\migration\migration
1515
{
16+
static public function depends_on()
17+
{
18+
return array(
19+
'\phpbb\db\migration\data\v32x\v324',
20+
);
21+
}
22+
1623
public function update_data()
1724
{
1825
return array(

0 commit comments

Comments
 (0)