Added a theme selector to the new config page

This commit is contained in:
Andy Heathershaw 2016-09-05 15:36:46 +01:00
parent 00ab249476
commit a386d1b893
4 changed files with 49 additions and 2 deletions

View File

@ -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(

View File

@ -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
]);
}
}

View File

@ -0,0 +1 @@
@import url('../bootstrap3/theme.css');

View File

@ -32,6 +32,15 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
<div class="form-group">
{!! Form::label('theme', 'Theme:', ['class' => 'control-label']) !!}
{!! Form::select('theme', $theme_names, old('theme'), ['class' => 'form-control']) !!}
</div>
</div>
</div>
</div>
</div>
</div>