Changed theme chooser to select

pull/624/head
TimZ99 2018-08-28 16:51:09 +02:00
parent 737a70fad4
commit 5b70457484
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
4 changed files with 28 additions and 4 deletions

View File

@ -73,7 +73,7 @@ $router = new psm\Router();
$db = $router->getService('db');
// check if we have a valid theme, error if we don't
if (!file_exists(PSM_PATH_SRC.'templates/'.PSM_THEME)) {
if (!file_exists(PSM_PATH_SRC.'templates'.DIRECTORY_SEPARATOR.PSM_THEME)) {
trigger_error("Selected theme '".PSM_THEME."' does not exist in templates folder. Please check your config.php for your PSM_THEME, set back to 'default' if unsure.", E_USER_ERROR);
}

View File

@ -142,6 +142,26 @@ function psm_get_sms_gateways() {
return $sms_gateways;
}
/**
* Retrieve a list with available templates
*
* @todo Add check to see if template is compatible.
*
* @param bool $with_path
*
* @return array
*/
function psm_get_templates($with_path = false) {
$template_list = glob(PSM_PATH_SRC.'templates/*', GLOB_ONLYDIR);
if($with_path){
return $template_list;
}
foreach ($template_list as $template) {
$templates[] = basename($template);
}
return $templates;
}
/**
* Get a setting from the config.
*

View File

@ -130,7 +130,7 @@ class InstallController extends AbstractController {
'db_pass' => '',
'db_prefix' => 'psm_',
'base_url' => $this->getBaseUrl(),
'theme' => 'default',
'themes' => psm_get_templates(),
);
$changed = false;

View File

@ -54,11 +54,15 @@
<input type="text" id="prefix" name="db_prefix" value="{{ db_prefix }}" />
</div>
</div>
<p>Please enter a visual theme:</p>
<p>Please choose a theme:</p>
<div class="control-group">
<label class="control-label" for="theme">Theme</label>
<div class="controls">
<input type="text" id="theme" name="theme" value="{{ theme }}" placeholder="default" />
<select id="theme" name="theme">
{% for theme in themes %}
<option value="{{ theme }}">{{ theme }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="control-group">