Merge pull request #14326 from civicrm/5.14
[civicrm-core.git] / tools / bin / scripts / ckeditorConfigScraper.php
CommitLineData
3b7ceeb2
CW
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');
b7c0a88f 6$matches = $output = [];
3b7ceeb2
CW
7preg_match_all("#name expandable'>([^<]+)</a>\s?:\s?(.*)<span.*'short'>([\s\S]*?)</div>#", $content, $matches);
8foreach ($matches[1] as $i => $name) {
b7c0a88f 9 $output[] = [
3b7ceeb2
CW
10 'id' => $name,
11 'type' => strip_tags($matches[2][$i]),
b7c0a88f 12 'description' => str_replace(["\n", '. ...'], [' ', '.'], $matches[3][$i]),
13 ];
3b7ceeb2
CW
14}
15if ($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}
19print "\nTotal: " . count($output) . "\n";