1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* phpBB Media Embed PlugIn extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2016 phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\mediaembed\migrations; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Migration 1: Install data to the database |
15
|
|
|
*/ |
16
|
|
|
class m1_install_data extends \phpbb\db\migration\container_aware_migration |
17
|
|
|
{ |
18
|
|
|
public function effectively_installed() |
19
|
|
|
{ |
20
|
|
|
return $this->config->offsetExists('media_embed_bbcode'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public static function depends_on() |
24
|
|
|
{ |
25
|
|
|
return ['\phpbb\db\migration\data\v320\v320rc1']; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function update_data() |
29
|
|
|
{ |
30
|
|
|
return [ |
31
|
|
|
['config.add', ['media_embed_bbcode', 1]], |
32
|
|
|
|
33
|
|
|
['module.add', ['acp', 'ACP_CAT_POSTING', [ |
34
|
|
|
'module_langname' => 'ACP_PHPBB_MEDIA_EMBED', |
35
|
|
|
'after' => 'ACP_MESSAGES', |
36
|
|
|
]]], |
37
|
|
|
|
38
|
|
|
['module.add', ['acp', 'ACP_PHPBB_MEDIA_EMBED', [ |
39
|
|
|
'module_basename' => '\phpbb\mediaembed\acp\main_module', |
40
|
|
|
'modes' => ['settings', 'manage'], |
41
|
|
|
]]], |
42
|
|
|
|
43
|
|
|
['config_text.add', ['media_embed_sites', call_user_func([$this, 'media_sites'])]], |
44
|
|
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get a JSON encoded string of an array of all available MediaEmbed |
49
|
|
|
* sites that can be enabled without conflicting with existing BBCodes. |
50
|
|
|
* |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function media_sites() |
54
|
|
|
{ |
55
|
|
|
/** @var \s9e\TextFormatter\Configurator $configurator */ |
56
|
|
|
$configurator = $this->container->get('text_formatter.s9e.factory')->get_configurator(); |
57
|
|
|
$sites = array_filter(array_keys(iterator_to_array($configurator->MediaEmbed->defaultSites)), function ($siteId) use ($configurator) { |
58
|
|
|
return !isset($configurator->BBCodes[$siteId]); |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
return json_encode(array_values($sites)); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|