From 5a2496ecd28dc292cece29c51e6d3cb3c19eeebf Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 23 Jan 2024 21:20:44 +0100 Subject: [PATCH] new functions to get logo --- application/libraries/OptionsLib.php | 16 ++++++++++++++++ application/models/Themes_model.php | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/application/libraries/OptionsLib.php b/application/libraries/OptionsLib.php index c595bbb3e..84535483c 100644 --- a/application/libraries/OptionsLib.php +++ b/application/libraries/OptionsLib.php @@ -118,4 +118,20 @@ class OptionsLib { } } + + function get_logo($logo_location) { + + $CI =& get_instance(); + + // get the theme with the get_theme() function above + $theme = $this->get_theme(); + + // load the themes model and fetch the logo name from it + $CI->load->model('Themes_model'); + + $logo = $CI->Themes_model->get_logo_from_theme($theme, $logo_location); + + return $logo; + } + } diff --git a/application/models/Themes_model.php b/application/models/Themes_model.php index 307c814bb..bfb8cb6f7 100644 --- a/application/models/Themes_model.php +++ b/application/models/Themes_model.php @@ -49,4 +49,23 @@ class Themes_model extends CI_Model { $this->db->where('id', $id); $this->db->update('themes', $data); } + + function get_logo_from_theme($theme, $logo_location) { + $clean_theme = $this->security->xss_clean($theme); + $clean_location = $this->security->xss_clean($logo_location); + + $sql = "SELECT " . $clean_location . " FROM themes WHERE foldername = '" . $clean_theme . "'"; + + $query = $this->db->query($sql); + + if ($query) { + $result = $query->row(); + $value = isset($result->$clean_location) ? $result->$clean_location : null; + + return ($value !== null) ? (string) $value : null; + } else { + return null; + } + } + }