Merge pull request #5 from HB9HIL/custom_logo

[Rebranding Part 1] Theme Mode
This commit is contained in:
HB9HIL
2024-01-17 14:58:35 +01:00
committed by GitHub
13 changed files with 95 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 173;
$config['migration_version'] = 174;
/*
|--------------------------------------------------------------------------

View File

@@ -58,6 +58,8 @@ class Dashboard extends CI_Controller {
$data['current_active'] = $this->stations->find_active();
$data['themesWithoutMode'] = $this->setup_model->checkThemesWithoutMode();
$setup_required = false;
if($setup_required) {

View File

@@ -38,6 +38,7 @@ class Themes extends CI_Controller {
$this->form_validation->set_rules('name', 'Theme Name', 'required');
$this->form_validation->set_rules('foldername', 'Folder Name', 'required');
$this->form_validation->set_rules('theme_mode', 'Theme Mode', 'required');
if ($this->form_validation->run() == FALSE)
{
@@ -64,6 +65,7 @@ class Themes extends CI_Controller {
$this->form_validation->set_rules('name', 'Theme Name', 'required');
$this->form_validation->set_rules('foldername', 'Folder Name', 'required');
$this->form_validation->set_rules('theme_mode', 'Theme Mode', 'required');
if ($this->form_validation->run() == FALSE)
{
@@ -75,7 +77,7 @@ class Themes extends CI_Controller {
{
$this->Themes_model->edit($item_id_clean);
$data['notice'] = "Theme ".$this->security->xss_clean($this->input->post('name', true))." Updated";
$this->session->set_flashdata("success", "Theme '".$this->security->xss_clean($this->input->post('name', true))."' updated");
redirect('themes');
}

View File

@@ -0,0 +1,34 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_add_theme_mode extends CI_Migration {
public function up() {
$fields = array(
'theme_mode VARCHAR(20) AFTER foldername',
);
if (!$this->db->field_exists('theme_mode', 'themes')) {
$this->dbforge->add_column('themes', $fields);
}
$this->db->query("UPDATE themes SET theme_mode = 'light' WHERE foldername = 'cosmo'");
$this->db->query("UPDATE themes SET theme_mode = 'light' WHERE foldername = 'cosmo_wide'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'cyborg'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'cyborg_wide'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'darkly'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'darkly_wide'");
$this->db->query("UPDATE themes SET theme_mode = 'light' WHERE foldername = 'default'");
$this->db->query("UPDATE themes SET theme_mode = 'light' WHERE foldername = 'default_wide'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'superhero'");
$this->db->query("UPDATE themes SET theme_mode = 'dark' WHERE foldername = 'superhero_wide'");
}
public function down(){
if ($this->db->field_exists('theme_mode', 'themes')) {
$this->dbforge->drop_column('themes', 'theme_mode');
}
}
}

View File

@@ -3,7 +3,7 @@
class Setup_model extends CI_Model {
function getCountryCount() {
$sql = 'select count(*) as count from dxcc_entities';
$sql = 'SELECT count(*) as count FROM dxcc_entities';
$query = $this->db->query($sql);
return $query->row()->count;
@@ -11,7 +11,7 @@ class Setup_model extends CI_Model {
function getLogbookCount() {
$userid = xss_clean($this->session->userdata('user_id'));
$sql = 'select count(*) as count from station_logbooks where user_id =' . $userid;
$sql = 'SELECT count(*) as count FROM station_logbooks WHERE user_id =' . $userid;
$query = $this->db->query($sql);
return $query->row()->count;
@@ -19,7 +19,14 @@ class Setup_model extends CI_Model {
function getLocationCount() {
$userid = xss_clean($this->session->userdata('user_id'));
$sql = 'select count(*) as count from station_profile where user_id =' . $userid;
$sql = 'SELECT count(*) as count FROM station_profile WHERE user_id =' . $userid;
$query = $this->db->query($sql);
return $query->row()->count;
}
function checkThemesWithoutMode() {
$sql = "SELECT COUNT(*) AS count FROM themes WHERE theme_mode IS NULL OR theme_mode = ''";
$query = $this->db->query($sql);
return $query->row()->count;

View File

@@ -21,6 +21,7 @@ class Themes_model extends CI_Model {
$data = array(
'name' => xss_clean($this->input->post('name', true)),
'foldername' => xss_clean($this->input->post('foldername', true)),
'theme_mode' => xss_clean($this->input->post('theme_mode', true)),
);
$this->db->insert('themes', $data);
@@ -42,6 +43,7 @@ class Themes_model extends CI_Model {
$data = array(
'name' => xss_clean($this->input->post('name', true)),
'foldername' => xss_clean($this->input->post('foldername', true)),
'theme_mode' => xss_clean($this->input->post('theme_mode', true)),
);
$this->db->where('id', $id);

View File

@@ -65,7 +65,7 @@
<?php } ?>
</select>
<label class="visually-hidden" for="inlineFormInputName2"><?php echo lang('adif_file_label') ?></label>
<input class="file-input mb-2 me-sm-2" type="file" name="userfile" id="userfile" size="20" />
<input class="form-control mb-2 me-sm-2 w-auto" type="file" name="userfile" id="userfile" size="20" />
<div class="mb-3 row">
<div class="col-md-10">

View File

@@ -93,6 +93,12 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) {
</div>
<?php } ?>
<?php if($themesWithoutMode != 0) { ?>
<div class="alert alert-danger" role="alert">
You have themes without defined theme mode. Please ask the admin to edit the themes.
</div>
<?php } ?>
<?php if ($this->session->userdata('user_id')) { ?>
<?php
$current_date = date('Y-m-d H:i:s');

View File

@@ -2982,6 +2982,7 @@ function viewEqsl(picture, callsign) {
data: {
'name': form.name.value,
'foldername': form.foldername.value,
'theme_mode': form.theme_mode.value,
},
success: function(html) {
location.reload();

View File

@@ -1,4 +1,4 @@
<div class="container settings">
<div class="container settings mb-4">
<div class="row">
<!-- Nav Start -->

View File

@@ -32,6 +32,15 @@
<small id="foldernameInputHelp" class="form-text text-muted">This is the name of the folder where your CSS-files are placed under assets/css.</small>
</div>
<div class="mb-3">
<label for="themeModeInput">Theme Mode</label>
<select class="form-select" id="themeModeInput" name="theme_mode">
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
<small id="themeModeInputHelp" class="form-text text-muted">This defines wherever the theme is a light or a dark one. On this basis the Logo is chosen.</small>
</div>
<button type="button" onclick="addTheme(this.form);" class="btn btn-primary"><i class="fas fa-plus-square"></i> Add theme</button>
</form>
</div>

View File

@@ -39,6 +39,15 @@
<small id="foldernameInputHelp" class="form-text text-muted">This is the name of the folder where your CSS-files are placed under assets/css.</small>
</div>
<div class="mb-3">
<label for="themeModeInput">Theme Mode</label>
<select class="form-select" id="themeModeInput" name="theme_mode">
<option value="light" <?php if ($theme->theme_mode == 'light') { echo " selected =\"selected\""; } ?>>Light</option>
<option value="dark" <?php if ($theme->theme_mode == 'dark') { echo " selected =\"selected\""; } ?>>Dark</option>
</select>
<small id="themeModeInputHelp" class="form-text text-muted">This defines wherever the theme is a light or a dark one. On this basis the Logo is chosen.</small>
</div>
<button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-plus-square"></i> Update Theme</button>
</form>

View File

@@ -1,10 +1,17 @@
<div class="container">
<br>
<?php if($this->session->flashdata('message')) { ?>
<?php if($this->session->flashdata('danger')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
<div class="alert alert-danger">
<p><?php echo $this->session->flashdata('danger'); ?></p>
</div>
<?php } ?>
<?php if($this->session->flashdata('success')) { ?>
<!-- Display Message -->
<div class="alert alert-success">
<p><?php echo $this->session->flashdata('success'); ?></p>
</div>
<?php } ?>
@@ -24,6 +31,7 @@
<tr>
<th scope="col">Name</th>
<th scope="col">Foldername</th>
<th scope="col">Theme Mode</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
@@ -33,6 +41,11 @@
<tr>
<td><?php echo $theme->name;?></td>
<td><?php echo $theme->foldername;?></td>
<td><?php if($theme->theme_mode != "") {
echo $theme->theme_mode;
} else {
echo "<span class=\"text-danger\">Theme-Mode undefined! Please edit</span>";
} ?></td>
<td>
<a href="<?php echo site_url('themes/edit')."/".$theme->id; ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i> Edit</a>
</td>