1 | <?php |
||
19 | class Configurator extends ConfiguratorBase |
||
20 | { |
||
21 | /** |
||
22 | * @var array List of filters that are explicitly allowed in attribute definitions |
||
23 | */ |
||
24 | public $allowedFilters = ['stripslashes', 'urldecode']; |
||
25 | |||
26 | /** |
||
27 | * @var bool Whether to create the MEDIA BBCode |
||
28 | */ |
||
29 | protected $createMediaBBCode = true; |
||
30 | |||
31 | /** |
||
32 | * @var Configurator\Collections\SiteDefinitionCollection Default sites |
||
33 | */ |
||
34 | public $defaultSites; |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | protected $quickMatch = '://'; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | protected $regexp = '/\\bhttps?:\\/\\/[^["\'\\s]+/Si'; |
||
45 | |||
46 | /** |
||
47 | * @var array Configured sites |
||
48 | */ |
||
49 | protected $sites = []; |
||
50 | |||
51 | /** |
||
52 | * @var string Name of the tag used to handle embeddable URLs |
||
53 | */ |
||
54 | protected $tagName = 'MEDIA'; |
||
55 | |||
56 | /** |
||
57 | * @var TemplateBuilder |
||
58 | */ |
||
59 | protected $templateBuilder; |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 24 | protected function setUp() |
|
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | 5 | public function asConfig() |
|
95 | |||
96 | /** |
||
97 | * Add a media site |
||
98 | * |
||
99 | * @param string $siteId Site's ID |
||
100 | * @param array $siteConfig Site's config |
||
101 | * @return Tag Tag created for this site |
||
102 | */ |
||
103 | 20 | public function add($siteId, array $siteConfig = null) |
|
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | 2 | public function finalize() |
|
159 | |||
160 | /** |
||
161 | * Check the safety of given attributes |
||
162 | * |
||
163 | * @param array $attributes |
||
164 | * @return void |
||
165 | */ |
||
166 | 18 | protected function checkAttributeFilters(array $attributes) |
|
183 | |||
184 | /** |
||
185 | * Convert given regexp to a [regexp, map] pair |
||
186 | * |
||
187 | * @param string $regexp Original regexp |
||
188 | * @return array [regexp, [list of captures' names]] |
||
189 | */ |
||
190 | 16 | protected function convertRegexp($regexp) |
|
196 | |||
197 | /** |
||
198 | * Convert a list of regexps |
||
199 | * |
||
200 | * @param string[] $regexps Original list |
||
201 | * @return array[] Converted list |
||
202 | */ |
||
203 | 18 | protected function convertRegexps(array $regexps) |
|
207 | |||
208 | /** |
||
209 | * Convert all regexps in a scraping config |
||
210 | * |
||
211 | * @param array $config Original config |
||
212 | * @return array Converted config |
||
213 | */ |
||
214 | 4 | protected function convertScrapeConfig(array $config) |
|
221 | |||
222 | /** |
||
223 | * Convert all regexps in a list of scraping configs |
||
224 | * |
||
225 | * @param array[] $scrapes Original config |
||
226 | * @return array[] Converted config |
||
227 | */ |
||
228 | 18 | protected function convertScrapes(array $scrapes) |
|
232 | |||
233 | /** |
||
234 | * Create the default MEDIA tag |
||
235 | * |
||
236 | * @return void |
||
237 | */ |
||
238 | 24 | protected function createMediaTag() |
|
258 | |||
259 | /** |
||
260 | * Return the list of named captures from a list of [regexp, map] pairs |
||
261 | * |
||
262 | * @param array[] $regexps List of [regexp, map] pairs |
||
263 | * @return string[] |
||
264 | */ |
||
265 | 17 | protected function getAttributeNamesFromRegexps(array $regexps) |
|
275 | |||
276 | /** |
||
277 | * Get the attributes config for given site config |
||
278 | * |
||
279 | * @param array $siteConfig Site's config |
||
280 | * @return array Map of [attrName => attrConfig] |
||
281 | */ |
||
282 | 17 | protected function getAttributesConfig(array $siteConfig) |
|
299 | |||
300 | /** |
||
301 | * Validate and normalize a site ID |
||
302 | * |
||
303 | * @param string $siteId |
||
304 | * @return string |
||
305 | */ |
||
306 | 20 | protected function normalizeId($siteId) |
|
317 | } |