Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Mustache helper to load a theme configuration.
19
 *
20
 * @package    theme_universe
21
 * @copyright  Copyright © 2021 onwards, Marcin Czaja | RoseaThemes, rosea.io - Rosea Themes
22
 * @license    Commercial https://themeforest.net/licenses
23
 */
24
 
25
namespace theme_universe\util;
26
 
27
use theme_config;
28
use stdClass;
29
 
30
/**
31
 * Helper to load a theme configuration.
32
 *
33
 * @package    theme_universe
34
 * @copyright Copyright © 2018 onwards, Marcin Czaja | RoseaThemes, rosea.io - Rosea Themes
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class theme_settings {
38
    /**
39
     * @var \stdClass $theme The theme object.
40
     */
41
    protected $theme;
42
    /**
43
     * @var array $files Theme file settings.
44
     */
45
    protected $files = [
46
        'customlogo',
47
        'customdmlogo',
48
        'customsidebarlogo',
49
        'customsidebardmlogo',
50
        'seomanifestjson',
51
        'favicon16',
52
        'favicon32',
53
        'faviconsafaritab',
54
        'seoappletouchicon',
55
        'footerbgimg',
56
        'loginbg',
57
        'fontfiles'
58
    ];
59
 
60
    /**
61
     * Class constructor
62
     */
63
    public function __construct() {
64
        $this->theme = theme_config::load('universe');
65
    }
66
 
67
    /**
68
     * Magic method to get theme settings
69
     *
70
     * @param string $name
71
     *
72
     * @return false|string|null
73
     */
74
    public function __get(string $name) {
75
        if (in_array($name, $this->files)) {
76
            return $this->theme->setting_file_url($name, $name);
77
        }
78
 
79
        if (empty($this->theme->settings->$name)) {
80
            return false;
81
        }
82
 
83
        return $this->theme->settings->$name;
84
    }
85
 
86
    public function global_settings() {
87
        $templatecontext = [];
88
 
89
        $elements = [
90
            'googlefonturl',
91
            'customlogo',
92
            'customdmlogo',
93
            'customsidebarlogo',
94
            'customsidebardmlogo',
95
            'seomanifestjson',
96
            'seoappletouchicon',
97
            'seothemecolor',
98
            'favicon16',
99
            'favicon32',
100
            'faviconsafaritab',
101
            'faviconsafaritabcolor',
102
            'footerbgimg',
103
            'loginbg',
104
            'themeauthor',
105
            'displaycustomalert',
106
            'closecustomalert',
107
            'topbarlogoareaon',
108
            'customlogoandname',
109
            'logoandname',
110
            'fontfiles',
111
            'customsignupoutside',
112
            'topbaradditionalbtn',
113
            'topbaradditionalbtnurl',
114
            'istab2active',
115
            'darkmodefirst',
116
            'customalertid',
117
            'customalert',
118
            'darkmodetheme',
119
            'footercustomcss',
120
            'showfooterbuttons',
121
            'showbasicinfolist',
122
            'footerblock1hr',
123
            'footerblock2hr',
124
            'showsociallist',
125
            'facebook',
126
            'twitter',
127
            'linkedin',
128
            'youtube',
129
            'instagram',
130
            'mobile',
131
            'mail',
132
            'cwebsiteurl',
133
            'navbarlogobox',
134
            'footerfw',
135
            'courseimagefw'
136
        ];
137
 
138
        foreach ($elements as $setting) {
139
            $templatecontext[$setting] = $this->$setting;
140
        }
141
 
142
        $elementshtml = [
143
            'stringmycourses',
144
            'seometadesc',
145
            'customalerthtml',
146
            'customstcontent',
147
            'customsmcontent',
148
            'customsfcontent',
149
            'customlogotxt',
150
            'topbarcustomhtml',
151
            'customnavitems',
152
            'sdarkmode',
153
            'slightmode',
154
            'stopbaradditionalbtn',
155
            'dashboardblock1',
156
            'dashboardblock2',
157
            'mycoursesblock1',
158
            'mycoursesblock2',
159
            'footerblock1',
160
            'footerblock2',
161
            'footerblock3',
162
            'footercopy',
163
            'block5slidesperrow',
164
            'customalertcontent',
165
            'website',
166
            'customsocialicon'
167
        ];
168
 
169
        foreach ($elementshtml as $setting) {
170
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
171
        }
172
 
173
        return $templatecontext;
174
    }
175
 
176
    public function course_settings() {
177
        $templatecontext = [];
178
 
179
        $elements = [
180
            'coursetablayout',
181
            'cccteacherslist'
182
        ];
183
 
184
        foreach ($elements as $setting) {
185
            $templatecontext[$setting] = $this->$setting;
186
        }
187
 
188
        $elementshtml = [
189
            'titlecoursetab1',
190
            'titlecoursetab2',
191
            'titlecoursetab3',
192
            'titlecoursetab4',
193
            'titlecoursetab5',
194
            'coursetab1content',
195
            'coursetab2content',
196
            'coursetab3content',
197
            'coursetab4content',
198
            'coursetab5content'
199
        ];
200
 
201
        foreach ($elementshtml as $setting) {
202
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
203
        }
204
 
205
        return $templatecontext;
206
    }
207
 
208
}