Merge pull request #17560 from eileenmcnaughton/import
[civicrm-core.git] / tools / bin / scripts / ckeditorConfigScraper.php
1 <?php
2 /**
3 * Scrape all config options from the CKEditor documentation site.
4 */
5 $content = file_get_contents('http://docs.ckeditor.com/?print=/api/CKEDITOR.config');
6 $matches = $output = [];
7 preg_match_all("#name expandable'>([^<]+)</a>\s?:\s?(.*)<span.*'short'>([\s\S]*?)</div>#", $content, $matches);
8 foreach ($matches[1] as $i => $name) {
9 $output[] = [
10 'id' => $name,
11 'type' => strip_tags($matches[2][$i]),
12 'description' => str_replace(["\n", '. ...'], [' ', '.'], $matches[3][$i]),
13 ];
14 }
15 if ($output) {
16 $location = str_replace('tools/bin/scripts', '', __DIR__);
17 file_put_contents($location . '/js/wysiwyg/ck-options.json', json_encode($output, JSON_PRETTY_PRINT));
18 }
19 print "\nTotal: " . count($output) . "\n";