diff --git a/app/Helpers/ConfigHelper.php b/app/Helpers/ConfigHelper.php index db9ec7d..9c0d7bd 100644 --- a/app/Helpers/ConfigHelper.php +++ b/app/Helpers/ConfigHelper.php @@ -16,6 +16,39 @@ class ConfigHelper ]; } + public function allowedThemeNames() + { + $results = []; + + $directoryIterator = new \FilesystemIterator(dirname(dirname(__DIR__)) . '/resources/views/themes', \FilesystemIterator::SKIP_DOTS); + + /** @var \SplFileInfo $fileInfo */ + foreach ($directoryIterator as $fileInfo) + { + if (!$fileInfo->isDir() || strtolower($fileInfo->getFilename()) == 'base') + { + continue; + } + + $themeName = strtolower($fileInfo->getFilename()); + $themeDisplayName = $themeName; + + $themeInfoFilename = sprintf('%s/theme.json', $fileInfo->getPathname()); + if (file_exists($themeInfoFilename)) + { + $themeInfo = json_decode(file_get_contents($themeInfoFilename)); + if ($themeInfo !== false && isset($themeInfo->name)) + { + $themeDisplayName = $themeInfo->name; + } + } + + $results[$themeName] = $themeDisplayName; + } + + return $results; + } + public function defaults() { return array( diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 56966ed..d6b1c6d 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -29,7 +29,8 @@ class DefaultController extends Controller { $updateKeys = [ 'app_name', - 'date_format' + 'date_format', + 'theme' ]; foreach ($updateKeys as $key) @@ -58,10 +59,13 @@ class DefaultController extends Controller $dateFormatsLookup[$dateFormat] = date($dateFormat); } + $themeNamesLookup = UserConfig::allowedThemeNames(); + return Theme::render('admin.settings', [ 'config' => $config, 'date_formats' => $dateFormatsLookup, - 'success' => $request->session()->get('success') + 'success' => $request->session()->get('success'), + 'theme_names' => $themeNamesLookup ]); } } \ No newline at end of file diff --git a/public/themes/bootstrap3-light/theme.css b/public/themes/bootstrap3-light/theme.css new file mode 100644 index 0000000..78dc393 --- /dev/null +++ b/public/themes/bootstrap3-light/theme.css @@ -0,0 +1 @@ +@import url('../bootstrap3/theme.css'); \ No newline at end of file diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index 14a2232..590450b 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -32,6 +32,15 @@ + +
+
+
+ {!! Form::label('theme', 'Theme:', ['class' => 'control-label']) !!} + {!! Form::select('theme', $theme_names, old('theme'), ['class' => 'form-control']) !!} +
+
+