|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Advanced BBCode Box |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2013 Matt Friedman |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace vse\abbc3\controller; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\cache\driver\driver_interface as cache_driver; |
|
|
|
|
|
|
14
|
|
|
use phpbb\controller\helper; |
|
|
|
|
|
|
15
|
|
|
use phpbb\exception\http_exception; |
|
|
|
|
|
|
16
|
|
|
use phpbb\request\request; |
|
|
|
|
|
|
17
|
|
|
use phpbb\template\template; |
|
|
|
|
|
|
18
|
|
|
use phpbb\textformatter\s9e\factory as textformatter; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* ABBC3 BBCode Wizard class |
|
22
|
|
|
*/ |
|
23
|
|
|
class wizard |
|
24
|
|
|
{ |
|
25
|
|
|
/** @var string The default BBvideo site */ |
|
26
|
|
|
const BBVIDEO_DEFAULT = 'youtube'; |
|
27
|
|
|
|
|
28
|
|
|
/** @var cache_driver */ |
|
29
|
|
|
protected $cache; |
|
30
|
|
|
|
|
31
|
|
|
/** @var helper */ |
|
32
|
|
|
protected $helper; |
|
33
|
|
|
|
|
34
|
|
|
/** @var request */ |
|
35
|
|
|
protected $request; |
|
36
|
|
|
|
|
37
|
|
|
/** @var template */ |
|
38
|
|
|
protected $template; |
|
39
|
|
|
|
|
40
|
|
|
/** @var textformatter */ |
|
41
|
|
|
protected $textformatter; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Constructor |
|
45
|
|
|
* |
|
46
|
|
|
* @param cache_driver $cache Cache driver |
|
47
|
|
|
* @param helper $helper Controller helper object |
|
48
|
|
|
* @param request $request Request object |
|
49
|
|
|
* @param template $template Template object |
|
50
|
|
|
* @param textformatter $textformatter TextFormatter Factory |
|
51
|
|
|
* @access public |
|
52
|
|
|
*/ |
|
53
|
10 |
|
public function __construct(cache_driver $cache, helper $helper, request $request, template $template, textformatter $textformatter) |
|
54
|
|
|
{ |
|
55
|
10 |
|
$this->cache = $cache; |
|
56
|
10 |
|
$this->helper = $helper; |
|
57
|
10 |
|
$this->request = $request; |
|
58
|
10 |
|
$this->template = $template; |
|
59
|
10 |
|
$this->textformatter = $textformatter; |
|
60
|
10 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* BBCode wizard controller accessed with the URL /wizard/bbcode/{mode} |
|
64
|
|
|
* (where {mode} is a placeholder for a string of the bbcode tag name) |
|
65
|
|
|
* intended to be accessed via AJAX only |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $mode Mode taken from the URL |
|
68
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
|
|
|
|
|
69
|
|
|
* @throws http_exception A http exception |
|
70
|
|
|
* @access public |
|
71
|
|
|
*/ |
|
72
|
|
|
public function bbcode_wizard($mode) |
|
73
|
10 |
|
{ |
|
74
|
|
|
// Only allow valid AJAX requests |
|
75
|
|
|
if (!$this->request->is_ajax() || !in_array($mode, ['bbvideo', 'pipes', 'url'])) |
|
76
|
10 |
|
{ |
|
77
|
10 |
|
throw new http_exception(404, 'GENERAL_ERROR'); |
|
78
|
3 |
|
} |
|
79
|
3 |
|
|
|
80
|
1 |
|
if ($mode === 'bbvideo') |
|
81
|
1 |
|
{ |
|
82
|
|
|
$this->template->assign_vars([ |
|
83
|
3 |
|
'ABBC3_BBVIDEO_SITES' => $this->get_bbvideo_sites(), |
|
84
|
|
|
'ABBC3_BBVIDEO_DEFAULT' => self::BBVIDEO_DEFAULT, |
|
85
|
|
|
]); |
|
86
|
7 |
|
} |
|
87
|
|
|
|
|
88
|
|
|
return $this->helper->render("@vse_abbc3/abbc3_{$mode}_wizard.html"); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Set template variables for the BBvideo wizard |
|
93
|
|
|
* |
|
94
|
1 |
|
* @access protected |
|
95
|
|
|
*/ |
|
96
|
1 |
|
protected function get_bbvideo_sites() |
|
97
|
1 |
|
{ |
|
98
|
1 |
|
if (($bbvideo_sites = $this->cache->get('_bbvideo_sites')) !== false) |
|
99
|
1 |
|
{ |
|
100
|
1 |
|
return $bbvideo_sites; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
1 |
|
$bbvideo_sites = []; |
|
104
|
1 |
|
$configurator = $this->textformatter->get_configurator(); |
|
105
|
|
|
foreach ($configurator->MediaEmbed->defaultSites as $siteId => $siteConfig) |
|
106
|
|
|
{ |
|
107
|
1 |
|
// check that siteID is not already a custom bbcode and that it exists in MediaEmbed |
|
108
|
|
|
if (!isset($configurator->BBCodes[$siteId]) && $configurator->tags->exists($siteId)) |
|
109
|
1 |
|
{ |
|
110
|
1 |
|
$bbvideo_sites[$siteId] = [ |
|
111
|
|
|
'name' => $siteConfig['name'], |
|
112
|
1 |
|
'example' => isset($siteConfig['example']) ? current((array) $siteConfig['example']) : '', |
|
113
|
|
|
]; |
|
114
|
1 |
|
} |
|
115
|
1 |
|
} |
|
116
|
1 |
|
|
|
117
|
1 |
|
ksort($bbvideo_sites); |
|
118
|
1 |
|
|
|
119
|
1 |
|
$this->cache->put('_bbvideo_sites', $bbvideo_sites); |
|
120
|
|
|
|
|
121
|
|
|
return $bbvideo_sites; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths