Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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',
1441 ariadna 115
            'disabletab1',
1 efrain 116
            'darkmodefirst',
117
            'customalertid',
118
            'customalert',
1441 ariadna 119
            'customalertid',
1 efrain 120
            'darkmodetheme',
121
            'footercustomcss',
122
            'showfooterbuttons',
123
            'showbasicinfolist',
124
            'footerblock1hr',
125
            'footerblock2hr',
126
            'showsociallist',
127
            'facebook',
128
            'twitter',
129
            'linkedin',
130
            'youtube',
131
            'instagram',
132
            'mobile',
133
            'mail',
134
            'cwebsiteurl',
135
            'navbarlogobox',
136
            'footerfw',
1441 ariadna 137
            'courseimagefw',
138
            'showcoursefilter',
139
            'showcatbtnlabel',
140
            'showlangfilter',
141
            'showteachersfilter',
142
            'showfilter1',
143
            'showfilter2',
144
            'showfilter3',
145
            'showfilter4',
146
            'showfilter5',
147
            'showfilter6',
148
            'customfilter1',
149
            'customfilter2',
150
            'customfilter3',
151
            'customfilter4',
152
            'customfilter5',
153
            'customfilter6'
1 efrain 154
        ];
155
 
156
        foreach ($elements as $setting) {
157
            $templatecontext[$setting] = $this->$setting;
158
        }
159
 
160
        $elementshtml = [
161
            'stringmycourses',
162
            'seometadesc',
163
            'customalerthtml',
164
            'customstcontent',
165
            'customsmcontent',
166
            'customsfcontent',
167
            'customlogotxt',
168
            'topbarcustomhtml',
169
            'customnavitems',
170
            'sdarkmode',
171
            'slightmode',
172
            'stopbaradditionalbtn',
173
            'dashboardblock1',
174
            'dashboardblock2',
175
            'mycoursesblock1',
176
            'mycoursesblock2',
177
            'footerblock1',
178
            'footerblock2',
179
            'footerblock3',
180
            'footercopy',
181
            'block5slidesperrow',
182
            'customalertcontent',
183
            'website',
184
            'customsocialicon'
185
        ];
186
 
187
        foreach ($elementshtml as $setting) {
188
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
189
        }
190
 
191
        return $templatecontext;
192
    }
193
 
194
    public function course_settings() {
195
        $templatecontext = [];
196
 
197
        $elements = [
198
            'coursetablayout',
1441 ariadna 199
            'cccteacherslist',
200
            'coursecoverstyle'
1 efrain 201
        ];
202
 
203
        foreach ($elements as $setting) {
204
            $templatecontext[$setting] = $this->$setting;
205
        }
206
 
207
        $elementshtml = [
208
            'titlecoursetab1',
209
            'titlecoursetab2',
210
            'titlecoursetab3',
211
            'titlecoursetab4',
212
            'titlecoursetab5',
213
            'coursetab1content',
214
            'coursetab2content',
215
            'coursetab3content',
216
            'coursetab4content',
217
            'coursetab5content'
218
        ];
219
 
220
        foreach ($elementshtml as $setting) {
221
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
222
        }
223
 
224
        return $templatecontext;
225
    }
226
 
227
}