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; |
||
0 ignored issues
–
show
|
|||
14 | use phpbb\controller\helper; |
||
0 ignored issues
–
show
The type
phpbb\controller\helper was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | use phpbb\exception\http_exception; |
||
0 ignored issues
–
show
The type
phpbb\exception\http_exception was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
16 | use phpbb\request\request; |
||
0 ignored issues
–
show
The type
phpbb\request\request was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
17 | use phpbb\template\template; |
||
0 ignored issues
–
show
The type
phpbb\template\template was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
18 | use phpbb\textformatter\s9e\factory as textformatter; |
||
0 ignored issues
–
show
The type
phpbb\textformatter\s9e\factory was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
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 |
||
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\Response was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
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 | * Get BBvideo sites |
||
93 | * |
||
94 | 1 | * @access protected |
|
95 | * @return array An array of BBVideo sites containing [id => name, example] |
||
96 | 1 | */ |
|
97 | 1 | protected function get_bbvideo_sites() |
|
98 | 1 | { |
|
99 | 1 | if (($bbvideo_sites = $this->cache->get('_bbvideo_sites')) !== false) |
|
100 | 1 | { |
|
101 | return $bbvideo_sites; |
||
102 | } |
||
103 | 1 | ||
104 | 1 | $bbvideo_sites = []; |
|
105 | $configurator = $this->textformatter->get_configurator(); |
||
106 | foreach ($configurator->MediaEmbed->defaultSites as $siteId => $siteConfig) |
||
107 | 1 | { |
|
108 | // check that siteID is not already a custom bbcode and that it exists in MediaEmbed |
||
109 | 1 | if (!isset($configurator->BBCodes[$siteId]) && $configurator->tags->exists($siteId)) |
|
110 | 1 | { |
|
111 | $bbvideo_sites[$siteId] = [ |
||
112 | 1 | 'name' => $siteConfig['name'], |
|
113 | 'example' => isset($siteConfig['example']) ? current((array) $siteConfig['example']) : '', |
||
114 | 1 | ]; |
|
115 | 1 | } |
|
116 | 1 | } |
|
117 | 1 | ||
118 | 1 | ksort($bbvideo_sites); |
|
119 | 1 | ||
120 | $this->cache->put('_bbvideo_sites', $bbvideo_sites); |
||
121 | |||
122 | return $bbvideo_sites; |
||
123 | } |
||
124 | } |
||
125 |
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