diff --git a/application/config/migration.php b/application/config/migration.php index 03abdf21..ad5f4c8e 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,8 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 74; + +$config['migration_version'] = 75; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Options.php b/application/controllers/Options.php index 45c7478a..be8b83ef 100644 --- a/application/controllers/Options.php +++ b/application/controllers/Options.php @@ -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'); diff --git a/application/controllers/Themes.php b/application/controllers/Themes.php new file mode 100644 index 00000000..2420e689 --- /dev/null +++ b/application/controllers/Themes.php @@ -0,0 +1,89 @@ +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); + } +} diff --git a/application/controllers/User.php b/application/controllers/User.php index 976ea38e..97059f73 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -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(); diff --git a/application/migrations/071_theme_table.php b/application/migrations/071_theme_table.php new file mode 100644 index 00000000..9bcf6ce8 --- /dev/null +++ b/application/migrations/071_theme_table.php @@ -0,0 +1,21 @@ +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(""); + + } +} diff --git a/application/models/Themes_model.php b/application/models/Themes_model.php new file mode 100644 index 00000000..8f34435c --- /dev/null +++ b/application/models/Themes_model.php @@ -0,0 +1,56 @@ +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); + } +} diff --git a/application/models/User_model.php b/application/models/User_model.php index 8aef15d1..aa68b105 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -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) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index c76b0b80..bcece900 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2024,6 +2024,72 @@ function deleteQsl(id) { +uri->segment(1) == "themes") { ?> + + + uri->segment(1) == "dxatlas") { ?> diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 4c8fa631..4f7ea75b 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -140,6 +140,10 @@ + Themes + + + Backup diff --git a/application/views/options/appearance.php b/application/views/options/appearance.php index 73c6a11f..748fcd21 100644 --- a/application/views/options/appearance.php +++ b/application/views/options/appearance.php @@ -47,12 +47,15 @@
Global Theme Choice, this is used when users arent logged in.
@@ -74,4 +77,4 @@ - \ No newline at end of file + diff --git a/application/views/themes/add.php b/application/views/themes/add.php new file mode 100644 index 00000000..08595ead --- /dev/null +++ b/application/views/themes/add.php @@ -0,0 +1,38 @@ + +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + + session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + + + +
+
+ + + This is the name that is used to display the theme in the theme list. +
+ +
+ + + This is the name of the folder where your CSS-files are placed under assets/css. +
+ + + +
+
diff --git a/application/views/themes/edit.php b/application/views/themes/edit.php new file mode 100644 index 00000000..56b6a90a --- /dev/null +++ b/application/views/themes/edit.php @@ -0,0 +1,50 @@ + +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +
+
+ +
+
+
+

+ session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + + + +
+
+ + name; } ?>" required> + This is the name that is used to display the theme in the theme list. +
+ +
+ + foldername; } ?>"> + This is the name of the folder where your CSS-files are placed under assets/css. +
+ + + +
+
+
+ +
+ +
diff --git a/application/views/themes/index.php b/application/views/themes/index.php new file mode 100644 index 00000000..3780d57d --- /dev/null +++ b/application/views/themes/index.php @@ -0,0 +1,51 @@ +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +

+ +
+
+ Themes list +
+
+

+ 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. +

+
+ + + + + + + + + + + + + + + + + + + + +
NameFoldername
name;?>foldername;?> + id; ?>" class="btn btn-outline-primary btn-sm"> Edit + + Delete +
+ +
+

+ + diff --git a/application/views/user/add.php b/application/views/user/add.php index 7157053f..f6b9f09b 100644 --- a/application/views/user/add.php +++ b/application/views/user/add.php @@ -111,12 +111,15 @@
diff --git a/application/views/user/edit.php b/application/views/user/edit.php index 3b879e71..20f7c379 100644 --- a/application/views/user/edit.php +++ b/application/views/user/edit.php @@ -94,12 +94,15 @@