kopia lustrzana https://github.com/magicbug/Cloudlog
commit
313ff76cd4
|
@ -21,7 +21,8 @@ $config['migration_enabled'] = TRUE;
|
|||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 74;
|
||||
|
||||
$config['migration_version'] = 75;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -14,8 +14,8 @@ class Options extends CI_Controller {
|
|||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Default /options view just gives some text to explain the options area
|
||||
function index() {
|
||||
|
||||
|
@ -23,14 +23,14 @@ class Options extends CI_Controller {
|
|||
//echo $this->config->item('option_theme');
|
||||
|
||||
//echo $this->optionslib->get_option('theme');
|
||||
|
||||
|
||||
$data['page_title'] = "Cloudlog Options";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('options/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
|
||||
// function used to display the /appearance url
|
||||
function appearance() {
|
||||
|
||||
|
@ -41,6 +41,10 @@ class Options extends CI_Controller {
|
|||
$data['page_title'] = "Cloudlog Options";
|
||||
$data['sub_heading'] = "Appearance";
|
||||
|
||||
$this->load->model('Themes_model');
|
||||
|
||||
$data['themes'] = $this->Themes_model->getThemes();
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('options/appearance');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
@ -101,10 +105,10 @@ class Options extends CI_Controller {
|
|||
|
||||
// function used to display the /radio url
|
||||
function radio() {
|
||||
|
||||
|
||||
$data['page_title'] = "Cloudlog Options";
|
||||
$data['sub_heading'] = "Radio Settings";
|
||||
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('options/radios');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
/*
|
||||
This controller will contain features for contesting
|
||||
*/
|
||||
|
||||
class Themes extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->lang->load('contesting');
|
||||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('Themes_model');
|
||||
|
||||
$data['themes'] = $this->Themes_model->getThemes();
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = "Themes";
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('themes/index.php');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$this->load->model('Themes_model');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('name', 'Theme Name', 'required');
|
||||
$this->form_validation->set_rules('foldername', 'Folder Name', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
$data['page_title'] = "Create Theme";
|
||||
$this->load->view('themes/add', $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Themes_model->add();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->load->model('Themes_model');
|
||||
|
||||
$item_id_clean = $this->security->xss_clean($id);
|
||||
|
||||
$data['theme'] = $this->Themes_model->theme($item_id_clean);
|
||||
|
||||
$data['page_title'] = "Edit Theme";
|
||||
|
||||
$this->form_validation->set_rules('name', 'Theme Name', 'required');
|
||||
$this->form_validation->set_rules('foldername', 'Folder Name', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('themes/edit');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Themes_model->edit($item_id_clean);
|
||||
|
||||
$data['notice'] = "Theme ".$this->security->xss_clean($this->input->post('name', true))." Updated";
|
||||
|
||||
redirect('themes');
|
||||
}
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$id = $this->input->post('id');
|
||||
$this->load->model('Themes_model');
|
||||
$this->Themes_model->delete($id);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_Theme_table extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
// create themes table
|
||||
$this->db->query("create table themes (id integer not null auto_increment, name varchar(256) not null, foldername varchar(256) not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Blue','blue');");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Cosmo','cosmo');");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Default','default');");
|
||||
$this->db->query("INSERT INTO themes (name, foldername) values ('Superhero (Dark)','superhero');");
|
||||
}
|
||||
|
||||
public function down(){
|
||||
$this->db->query("");
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
class Themes_model extends CI_Model {
|
||||
function __construct()
|
||||
{
|
||||
// Call the Model constructor
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
// FUNCTION: array getThemes()
|
||||
// Returns a list of themes
|
||||
function getThemes() {
|
||||
$result = $this->db->query('SELECT * FROM themes order by name');
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
// Delete Theme
|
||||
$this->db->delete('themes', array('id' => $clean_id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
$data = array(
|
||||
'name' => xss_clean($this->input->post('name', true)),
|
||||
'foldername' => xss_clean($this->input->post('foldername', true)),
|
||||
);
|
||||
|
||||
$this->db->insert('themes', $data);
|
||||
}
|
||||
|
||||
|
||||
function theme($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
$sql = "SELECT * FROM themes where id =" . $clean_id;
|
||||
|
||||
$data = $this->db->query($sql);
|
||||
|
||||
return ($data->row());
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$data = array(
|
||||
'name' => xss_clean($this->input->post('name', true)),
|
||||
'foldername' => xss_clean($this->input->post('foldername', true)),
|
||||
);
|
||||
|
||||
$this->db->where('id', $id);
|
||||
$this->db->update('themes', $data);
|
||||
}
|
||||
}
|
|
@ -371,6 +371,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) {
|
||||
|
|
|
@ -2024,6 +2024,72 @@ function deleteQsl(id) {
|
|||
<script src="<?php echo base_url() ;?>assets/js/sections/contestingnames.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "themes") { ?>
|
||||
<script>
|
||||
function deleteTheme(id, name) {
|
||||
BootstrapDialog.confirm({
|
||||
title: 'DANGER',
|
||||
message: 'Warning! Are you sure you want to delete the following theme: ' + name + '?' ,
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-danger',
|
||||
callback: function(result) {
|
||||
if(result) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/themes/delete',
|
||||
type: 'post',
|
||||
data: {'id': id
|
||||
},
|
||||
success: function(data) {
|
||||
$(".theme_" + id).parent("tr:first").remove(); // removes mode from table
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addThemeDialog() {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/themes/add',
|
||||
type: 'post',
|
||||
success: function(html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Create Theme',
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
cssClass: 'create-theme-dialog',
|
||||
nl2br: false,
|
||||
message: html,
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addTheme(form) {
|
||||
if (form.name.value != '') {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/themes/add',
|
||||
type: 'post',
|
||||
data: {
|
||||
'name': form.name.value,
|
||||
'foldername': form.foldername.value,
|
||||
},
|
||||
success: function(html) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "dxatlas") { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||
|
|
|
@ -140,6 +140,10 @@
|
|||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('themes');?>" title="Manage Themes"><i class="fas fa-cog"></i> Themes</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('backup');?>" title="Backup Cloudlog content"><i class="fas fa-save"></i> Backup</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
|
|
@ -47,12 +47,15 @@
|
|||
<div class="form-group">
|
||||
<label for="themeSelect">Theme</label>
|
||||
<select class="custom-select" id="themeSelect" name="theme" aria-describedby="themeHelp" required>
|
||||
<option value='default' <?php if($this->optionslib->get_option('theme') == "default") { echo "selected=\"selected\""; } ?>>Default</option>
|
||||
<option value='blue' <?php if($this->optionslib->get_option('theme')== "blue") { echo "selected=\"selected\""; } ?>>Blue</option>
|
||||
<option value='cosmo' <?php if($this->optionslib->get_option('theme') == "cosmo") { echo "selected=\"selected\""; } ?>>Cosmo</option>
|
||||
<option value='cyborg' <?php if($this->optionslib->get_option('theme') == "cyborg") { echo "selected=\"selected\""; } ?>>Cyborg (Dark)</option>
|
||||
<option value='darkly' <?php if($this->optionslib->get_option('theme') == "darkly") { echo "selected=\"selected\""; } ?>> Darkly (Dark)</option>
|
||||
<option value='superhero' <?php if($this->optionslib->get_option('theme') == "superhero") { echo "selected=\"selected\""; } ?>>Superhero (Dark)</option>
|
||||
<?php
|
||||
foreach ($themes as $theme) {
|
||||
echo '<option value="' . $theme->foldername . '"';
|
||||
if ($this->optionslib->get_option('theme') == $theme->foldername) {
|
||||
echo 'selected="selected"';
|
||||
}
|
||||
echo '>' . $theme->name . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<small id="themeHelp" class="form-text text-muted">Global Theme Choice, this is used when users arent logged in.</small>
|
||||
</div>
|
||||
|
@ -74,4 +77,4 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
<div class="container" id="create_mode">
|
||||
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
<p><?php echo $this->session->flashdata('message'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($this->session->flashdata('notice')) { ?>
|
||||
<div id="message" >
|
||||
<?php echo $this->session->flashdata('notice'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php $this->load->helper('form'); ?>
|
||||
|
||||
<?php echo validation_errors(); ?>
|
||||
|
||||
<form method="post" name="create_profile">
|
||||
<div class="form-group">
|
||||
<label for="nameInput">Theme Name</label>
|
||||
<input type="text" class="form-control" name="name" id="nameInput" aria-describedby="nameInputHelp" required>
|
||||
<small id="nameInputHelp" class="form-text text-muted">This is the name that is used to display the theme in the theme list.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="foldernameInput">Folder Name</label>
|
||||
<input type="text" class="form-control" name="foldername" id="foldernameInput" aria-describedby="foldernameInputHelp">
|
||||
<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>
|
||||
|
||||
<button onclick="addTheme(this.form);" class="btn btn-primary"><i class="fas fa-plus-square"></i> Add theme</button>
|
||||
|
||||
</form>
|
||||
</div>
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
<div class="container">
|
||||
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
<p><?php echo $this->session->flashdata('message'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<?php echo $page_title; ?>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"></h5>
|
||||
<p class="card-text"></p>
|
||||
<?php if($this->session->flashdata('notice')) { ?>
|
||||
<div id="message" >
|
||||
<?php echo $this->session->flashdata('notice'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php $this->load->helper('form'); ?>
|
||||
|
||||
<?php echo validation_errors(); ?>
|
||||
|
||||
<form method="post" action="<?php echo site_url('themes/edit/'); ?><?php echo $theme->id; ?>" name="edit_theme">
|
||||
<div class="form-group">
|
||||
<label for="themenameInput">Theme Name</label>
|
||||
<input type="text" class="form-control" name="name" id="nameInput" aria-describedby="themenameInputHelp" value="<?php if(set_value('name') != "") { echo set_value('name'); } else { echo $theme->name; } ?>" required>
|
||||
<small id="themenameInputHelp" class="form-text text-muted">This is the name that is used to display the theme in the theme list.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="foldernameInput">Folder Name</label>
|
||||
<input type="text" class="form-control" name="foldername" id="foldernameInput" aria-describedby="foldernameInputHelp" value="<?php if(set_value('foldername') != "") { echo set_value('foldername'); } else { echo $theme->foldername; } ?>">
|
||||
<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>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-plus-square"></i> Update Theme</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,51 @@
|
|||
<div class="container">
|
||||
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
<p><?php echo $this->session->flashdata('message'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Themes list
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
Using the theme list, you can control which Themes are shown in the account settings. Deleting a theme here, does not delete the css theme folder.
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table style="width:100%" class="contesttable table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Foldername</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($themes as $theme) { ?>
|
||||
<tr>
|
||||
<td><?php echo $theme->name;?></td>
|
||||
<td><?php echo $theme->foldername;?></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>
|
||||
<td class='theme_<?php echo $theme->id ?>'>
|
||||
<a href="javascript:deleteTheme('<?php echo $theme->id; ?>', '<?php echo $theme->name; ?>');" class="btn btn-danger btn-sm" ><i class="fas fa-trash-alt"></i> Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
<table>
|
||||
</div>
|
||||
<br/>
|
||||
<p><button onclick="addThemeDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Add a Theme</button></p>
|
||||
</div>
|
||||
</div>
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Ładowanie…
Reference in New Issue