XBackBone/bin/theme
2019-09-04 21:43:43 +02:00

36 lines
No EOL
1.1 KiB
PHP

#!/usr/bin/env php
<?php
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
if (php_sapi_name() !== 'cli') {
die();
}
require __DIR__ . '/../vendor/autoload.php';
chdir(__DIR__ . '/../');
$json = json_decode(file_get_contents('https://bootswatch.com/api/4.json'));
if (!isset($argv[1])) {
echo 'Usage: php bin\\theme <theme-name|"default">' . PHP_EOL;
echo 'Here a list of available Bootswatch themes:' . PHP_EOL;
}
if (isset($argv[1]) && strtolower($argv[1]) === 'default') {
file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents('https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css'));
echo "Reverted to default theme." . PHP_EOL;
} else {
foreach ($json->themes as $theme) {
if (isset($argv[1]) && strtolower($argv[1]) === strtolower($theme->name)) {
file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents($theme->cssMin));
echo "Installed theme {$theme->name}." . PHP_EOL;
break;
}
if (!isset($argv[1])) {
echo " - {$theme->name} ({$theme->description})[Preview: {$theme->preview}]" . PHP_EOL;
}
}
}
exit(0);