1 | <?php |
||
22 | class wizard |
||
23 | { |
||
24 | /** @var string The default BBvideo site */ |
||
25 | const BBVIDEO_DEFAULT = 'youtube.com'; |
||
26 | |||
27 | /** @var helper */ |
||
28 | protected $helper; |
||
29 | |||
30 | /** @var request */ |
||
31 | protected $request; |
||
32 | |||
33 | /** @var template */ |
||
34 | protected $template; |
||
35 | |||
36 | /** @var user */ |
||
37 | protected $user; |
||
38 | |||
39 | /** @var string */ |
||
40 | protected $ext_root_path; |
||
41 | |||
42 | /** |
||
43 | * Constructor |
||
44 | * |
||
45 | * @param helper $helper Controller helper object |
||
46 | * @param request $request Request object |
||
47 | * @param template $template Template object |
||
48 | * @param user $user User object |
||
49 | * @param string $ext_root_path Path to abbc3 extension root |
||
50 | * @access public |
||
51 | */ |
||
52 | 11 | public function __construct(helper $helper, request $request, template $template, user $user, $ext_root_path) |
|
60 | |||
61 | /** |
||
62 | * BBCode wizard controller accessed with the URL /wizard/bbcode/{mode} |
||
63 | * (where {mode} is a placeholder for a string of the bbcode tag name) |
||
64 | * intended to be accessed via AJAX only |
||
65 | * |
||
66 | * @param string $mode Mode taken from the URL |
||
67 | * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
||
68 | * @throws \phpbb\exception\http_exception An http exception |
||
69 | * @access public |
||
70 | */ |
||
71 | 8 | public function bbcode_wizard($mode) |
|
72 | { |
||
73 | // Only allow AJAX requests |
||
74 | 8 | if ($this->request->is_ajax()) |
|
75 | 8 | { |
|
76 | switch ($mode) |
||
77 | { |
||
78 | 4 | case 'bbvideo': |
|
79 | 1 | $this->generate_bbvideo_wizard(); |
|
80 | 1 | return $this->helper->render('abbc3_bbvideo_wizard.html'); |
|
81 | // no break here |
||
82 | |||
83 | 3 | case 'url': |
|
84 | 1 | return $this->helper->render('abbc3_url_wizard.html'); |
|
85 | // no break here |
||
86 | } |
||
87 | 2 | } |
|
88 | |||
89 | 6 | throw new \phpbb\exception\http_exception(404, 'GENERAL_ERROR'); |
|
90 | } |
||
91 | |||
92 | /** |
||
93 | * Set template variables for the BBvideo wizard |
||
94 | * |
||
95 | * @return null |
||
96 | * @access protected |
||
97 | */ |
||
98 | 1 | protected function generate_bbvideo_wizard() |
|
120 | |||
121 | /** |
||
122 | * Return decoded JSON data from a JSON file (stored in assets/) |
||
123 | * |
||
124 | * @param string $json_file The name of the JSON file to get |
||
125 | * @return array JSON data |
||
126 | * @throws \phpbb\exception\runtime_exception |
||
127 | * @access protected |
||
128 | */ |
||
129 | 4 | protected function load_json_data($json_file) |
|
150 | } |
||
151 |