1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Used to convert a bootswatch file from https://bootswatch.com/ to a Moodle preset. 19 * 20 * @package theme_boost 21 * @subpackage cli 22 * @copyright 2016 Damyon Wiese 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 define('CLI_SCRIPT', true); 27 28 require(__DIR__.'/../../../config.php'); 29 require_once($CFG->libdir.'/clilib.php'); 30 31 $usage = " 32 Utility to convert a Bootswatch theme to a Moodle preset compatible with Bootstrap 4. 33 34 Download _variables.scss and _bootswatch.scss files from https://bootswatch.com/ 35 Run this script. It will generate a new file 'preset.scss' which can be used as 36 a Moodle preset. 37 38 Usage: 39 # php import-bootswatch.php [--help|-h] 40 # php import-bootswatch.php --variables=<path> --bootswatch=<path> --preset=<path> 41 42 Options: 43 -h --help Print this help. 44 --variables=<path> Path to the input variables file, defaults to _variables.scss 45 --bootswatch=<path> Path to the input bootswatch file, defauls to _bootswatch.scss 46 --preset=<path> Path to the output preset file, defaults to preset.scss 47 "; 48 49 list($options, $unrecognised) = cli_get_params([ 50 'help' => false, 51 'variables' => '_variables.scss', 52 'bootswatch' => '_bootswatch.scss', 53 'preset' => 'preset.scss', 54 ], [ 55 'h' => 'help', 56 ]); 57 58 if ($unrecognised) { 59 $unrecognised = implode(PHP_EOL.' ', $unrecognised); 60 cli_error(get_string('cliunknowoption', 'core_admin', $unrecognised)); 61 } 62 63 if ($options['help']) { 64 cli_writeln($usage); 65 exit(2); 66 } 67 68 if (is_readable($options['variables'])) { 69 $sourcevariables = file_get_contents($options['variables']); 70 } else { 71 cli_writeln($usage); 72 cli_error('Error reading the variables file: '.$options['variables']); 73 } 74 75 76 if (is_readable($options['bootswatch'])) { 77 $sourcebootswatch = file_get_contents($options['bootswatch']); 78 } else { 79 cli_writeln($usage); 80 cli_error('Error reading the bootswatch file: '.$options['bootswatch']); 81 } 82 83 // Write the preset file. 84 $out = fopen($options['preset'], 'w'); 85 86 if (!$out) { 87 cli_error('Error writing to the preset file'); 88 } 89 90 fwrite($out, $sourcevariables); 91 92 fwrite($out, ' 93 // Import FontAwesome. 94 @import "fontawesome"; 95 96 // Import All of Bootstrap 97 @import "bootstrap"; 98 99 // Import Core moodle CSS 100 @import "moodle"; 101 '); 102 103 // Add the bootswatch file. 104 fwrite($out, $sourcebootswatch); 105 106 fclose($out);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body