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