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_monocolor
21
 * @copyright  Copyright © 2021 onwards, Marcin Czaja | RoseaThemes, rosea.io - Rosea Themes
22
 * @license    Commercial https://themeforest.net/licenses
23
 */
24
 
25
namespace theme_monocolor\util;
26
 
27
use theme_config;
28
use stdClass;
29
 
30
/**
31
 * Helper to load a theme configuration.
32
 *
33
 * @package    theme_monocolor
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('monocolor');
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
        ];
134
 
135
        foreach ($elements as $setting) {
136
            $templatecontext[$setting] = $this->$setting;
137
        }
138
 
139
        $elementshtml = [
140
            'stringmycourses',
141
            'seometadesc',
142
            'customalerthtml',
143
            'customstcontent',
144
            'customsmcontent',
145
            'customsfcontent',
146
            'customlogotxt',
147
            'topbarcustomhtml',
148
            'customnavitems',
149
            'sdarkmode',
150
            'slightmode',
151
            'stopbaradditionalbtn',
152
            'dashboardblock1',
153
            'dashboardblock2',
154
            'mycoursesblock1',
155
            'mycoursesblock2',
156
            'footerblock1',
157
            'footerblock2',
158
            'footerblock3',
159
            'footercopy',
160
            'block5slidesperrow',
161
            'customalertcontent',
162
            'website',
163
            'customsocialicon'
164
        ];
165
 
166
        foreach ($elementshtml as $setting) {
167
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
168
        }
169
 
170
        return $templatecontext;
171
    }
172
 
173
    public function course_settings() {
174
        $templatecontext = [];
175
 
176
        $elements = [
177
            'coursetablayout',
178
            'cccteacherslist'
179
        ];
180
 
181
        foreach ($elements as $setting) {
182
            $templatecontext[$setting] = $this->$setting;
183
        }
184
 
185
        $elementshtml = [
186
            'titlecoursetab1',
187
            'titlecoursetab2',
188
            'titlecoursetab3',
189
            'titlecoursetab4',
190
            'titlecoursetab5',
191
            'coursetab1content',
192
            'coursetab2content',
193
            'coursetab3content',
194
            'coursetab4content',
195
            'coursetab5content'
196
        ];
197
 
198
        foreach ($elementshtml as $setting) {
199
            $templatecontext[$setting] = format_text(($this->$setting), FORMAT_HTML, array('noclean' => true));
200
        }
201
 
202
        return $templatecontext;
203
    }
204
 
205
}