. /** * Moodle Component Library * * @package tool_componentlibrary * @copyright 2021 Bas Brands * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('CLI_SCRIPT', 1); require_once(__DIR__ . '/../../../../config.php'); require_once($CFG->libdir.'/clilib.php'); require_once($CFG->dirroot . '/lib/filelib.php'); list($options, $unrecognized) = cli_get_params(array( 'help' => false, ), array('h' => 'help')); if ($options['help']) { $help = <<themedesignermode = true; $output = $PAGE->get_renderer('core'); $isfontawesome = \core\output\icon_system::instance(\core\output\icon_system::FONTAWESOME); $isstandard = \core\output\icon_system::instance(\core\output\icon_system::STANDARD); $map = $isfontawesome->get_icon_name_map(); $icons = []; foreach ($map as $name => $icon) { $parts = explode(':', $name); if ($parts[0] === 'theme') { continue; } $imageicon = new image_icon($parts[1], $name, $parts[0], []); $i = new \stdClass(); $i->name = $name; $i->icon = $icon; if ($imageicon) { $i->standardicon = str_replace($CFG->wwwroot, 'MOODLESITE', $isstandard->render_pix_icon($output, $imageicon)); } $icons[] = $i; } $jsonfile = $CFG->dirroot . '/admin/tool/componentlibrary/hugo/site/data/fontawesomeicons.json'; if (($fh = @fopen($jsonfile, 'w')) !== false) { fwrite($fh, json_encode($icons)); fclose($fh); exit(0); } else { echo 'Could not write to ' . $jsonfile; exit(1); }