[Custom CSS Theme Support] Added support for fetching list of themes from database.

pull/1127/head
Andreas 2021-08-09 13:13:41 +02:00
rodzic bad229dd09
commit a512a984aa
4 zmienionych plików z 32 dodań i 12 usunięć

Wyświetl plik

@ -42,6 +42,9 @@ class User extends CI_Controller {
$this->form_validation->set_rules('user_locator', 'Locator', 'required');
$this->form_validation->set_rules('user_timezone', 'Timezone', 'required');
// Get themes list
$data['themes'] = $this->user_model->getThemes();
// Get timezones
$data['timezones'] = $this->user_model->timezones();
@ -158,6 +161,9 @@ class User extends CI_Controller {
$this->form_validation->set_rules('user_locator', 'Locator', 'required|xss_clean');
$this->form_validation->set_rules('user_timezone', 'Timezone', 'required');
// Get themes list
$data['themes'] = $this->user_model->getThemes();
// Get timezones
$data['timezones'] = $this->user_model->timezones();

Wyświetl plik

@ -370,6 +370,14 @@ class User_Model extends CI_Model {
return $ts;
}
// FUNCTION: array getThemes()
// Returns a list of themes
function getThemes() {
$result = $this->db->query('SELECT * FROM themes order by name');
return $result->result();
}
// FUNCTION: bool _auth($password, $hash)
// Checks a password against the stored hash
private function _auth($password, $hash) {

Wyświetl plik

@ -111,12 +111,15 @@
<div class="form-group">
<label for="user_stylesheet">Theme</label>
<select class="custom-select" id="user_stylesheet" name="user_stylesheet" required>
<option value='default' selected="selected">Default</option>
<option value='blue'>Blue</option>
<option value='cosmo'>Cosmo</option>
<option value='cyborg'>Cyborg (Dark)</option>
<option value='darkly'>Darkly (Dark)</option>
<option value='superhero'>Superhero (Dark)</option>
<?php
foreach ($themes as $theme) {
echo '<option value="' . $theme->foldername . '"';
if( $theme->foldername == 'default') {
echo 'selected="selected"';
}
echo '>' . $theme->name . '</option>';
}
?>
</select>
</div>

Wyświetl plik

@ -94,12 +94,15 @@
<div class="form-group">
<label>Stylesheet</label>
<select class="custom-select" id="user_stylesheet" name="user_stylesheet" required>
<option value='default' <?php if($user_stylesheet == "default") { echo "selected=\"selected\""; } ?>>Default</option>
<option value='blue' <?php if($user_stylesheet == "blue") { echo "selected=\"selected\""; } ?>>Blue</option>
<option value='cosmo' <?php if($user_stylesheet == "cosmo") { echo "selected=\"selected\""; } ?>>Cosmo</option>
<option value='cyborg' <?php if($user_stylesheet == "cyborg") { echo "selected=\"selected\""; } ?>>Cyborg (Dark)</option>
<option value='darkly' <?php if($user_stylesheet == "darkly") { echo "selected=\"selected\""; } ?>> Darkly (Dark)</option>
<option value='superhero' <?php if($user_stylesheet == "superhero") { echo "selected=\"selected\""; } ?>>Superhero (Dark)</option>
<?php
foreach ($themes as $theme) {
echo '<option value="' . $theme->foldername . '"';
if( $user_stylesheet == $theme->foldername) {
echo 'selected="selected"';
}
echo '>' . $theme->name . '</option>';
}
?>
</select>
</div>
</div>