예제 #1
0
 */
define('CLI_SCRIPT', true);
define('CACHE_DISABLE_ALL', true);
require dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php';
require_once $CFG->libdir . '/clilib.php';
require_once $CFG->dirroot . '/theme/bootswatch/lib.php';
// now get cli options
list($options, $unrecognized) = cli_get_params(array('all' => false, 'custom' => false, 'help' => false), array('h' => 'help'));
if ($options['help']) {
    $help = "Command line Bootswatch Swatch generation.\n\nThis script generates the bootswatch files for the Moodle bootswatch theme from the original upstream bootswatch project.\n\nOptions:\n--all            Generate all default bootswatch files (default)\n--custom         name of your custom bootswatch\n-h, --help            Print out this help\n\nExample:\n\$/usr/bin/php gen_swatchfiles.php --all\n";
    echo $help;
    die;
}
$all = $options['all'];
$custom = $options['custom'];
$defaultswatches = theme_bootswatch_get_swatches();
$swatchpath = $CFG->dirroot . '/theme/bootswatch/less/';
$pixpath = $CFG->dirroot . '/theme/bootswatch/pix/';
if ($custom) {
    echo "Not implemented yet";
}
if ($all) {
    foreach ($defaultswatches as $swatch) {
        if (file_exists($swatchpath . 'bootswatch/' . $swatch)) {
            // Generate the Swatch files
            $swatchfile = $swatchpath . $swatch . '.less';
            $content = '@import "../../bootstrap/less/moodle.less";' . "\n";
            $content .= '@import "bootswatch/' . $swatch . '/variables.less";' . "\n";
            $content .= '@import "bootswatch/' . $swatch . '/bootswatch.less";' . "\n";
            $content .= '@import "glyphicons.less";' . "\n";
            $fh = fopen($swatchfile, 'w');
예제 #2
0
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Theme Bootswatch version file.
 *
 * @package    theme_bootswatch
 * @copyright  2014 Bas Brands
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/theme/bootswatch/lib.php';
if ($ADMIN->fulltree) {
    // Selected Bootswatch
    $options = theme_bootswatch_get_swatches();
    $name = 'theme_bootswatch/bootswatch';
    $title = get_string('bootswatch', 'theme_bootswatch');
    $description = get_string('bootswatchdesc', 'theme_bootswatch');
    $description .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('bootswatch', 'theme')));
    $default = '0';
    $setting = new admin_setting_configselect($name, $title, $description, $default, $options);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $settings->add($setting);
    // Logo file setting.
    $name = 'theme_bootswatch/logo';
    $title = get_string('logo', 'theme_bootswatch');
    $description = get_string('logodesc', 'theme_bootswatch');
    $setting = new admin_setting_configstoredfile($name, $title, $description, 'logo');
    $setting->set_updatedcallback('theme_reset_all_caches');
    $settings->add($setting);