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
 *
19
 * @package   theme_monocolor
20
 * @copyright 2022 - 2024 Marcin Czaja (https://rosea.io)
21
 * @license   Commercial https://themeforest.net/licenses
22
 */
23
 
24
class theme_email {
25
 
26
    public function get_context() {
27
        global $CFG;
28
 
29
        $context = [];
30
        $context['theme'] = [];
31
        $context['theme']['css'] = $this->get_css('monocolor');
32
        $context['theme']['logo'] = $this->get_logo('monocolor');
33
        $context['theme']['typography'] = $this->get_typography('monocolor');
34
        $context['theme']['footer'] = $this->get_footer('monocolor');
35
 
36
        return $context;
37
    }
38
 
39
    // CSS.
40
    private function get_css('monocolor') {
41
        global $CFG;
42
 
43
        $output = '';
44
        $output = file_get_contents($CFG->httpswwwroot . '/pluginfile.php/1/theme_monocolor/customstyles/email.css');
45
 
46
        return $output;
47
    }
48
 
49
    // Logo.
50
    private function get_logo('monocolor') {
51
        global $CFG;
52
 
53
        $output = [];
54
 
55
        $output['url'] = $this->get_logo_file('monocolor');
56
        $output['height'] = get_config('theme_monocolor', 'email_logo_height');
57
        $output['alt'] = get_config('theme_monocolor', 'email_logo_alt');
58
        $output['href'] = get_config('theme_monocolor', 'email_logo_href');
59
        $output['hashref'] = (!empty($output['href']) ? true : false);
60
 
61
        return $output;
62
    }
63
 
64
    private function get_logo_file('monocolor') {
65
        global $CFG;
66
 
67
        $output = '';
68
 
69
        if (!empty(get_config('theme_monocolor', 'email_logo_file'))) {
70
            $output = $this->http_or_https() . theme_config::load('monocolor')->setting_file_url('email_logo_file', 'email_logo_file');
71
        } else {
72
            $output = $this->http_or_https() . theme_config::load('monocolor')->setting_file_url('customlogo', 'customlogo');
73
        }
74
 
75
        return $output;
76
    }
77
 
78
    // Typography.
79
    private function get_typography('monocolor') {
80
        $output = [];
81
 
82
        if (get_config('theme_monocolor', 'email_typo_enable')) {
83
            $output['fontfamily'] = 'font-family:' . get_config('theme_monocolor', 'email_typo_fontfamily') . ';';
84
 
85
            $output['text']['color'] = 'color:' . get_config('theme_monocolor', 'email_typo_text_color') . ';';
86
            $output['text']['fontsize'] = 'font-size:' . get_config('theme_monocolor', 'email_typo_text_fontsize') . ';';
87
 
88
            $output['link']['color'] = 'color:' . get_config('theme_monocolor', 'email_typo_link_color') . ';';
89
 
90
            $output['footer']['color'] = 'color:' . get_config('theme_monocolor', 'email_typo_footer_color') . ';';
91
            $output['footer']['fontsize'] = 'font-size:' . get_config('theme_monocolor', 'email_typo_footer_fontsize') . ';';
92
        }
93
 
94
        return $output;
95
    }
96
 
97
    // Footer.
98
    private function get_footer('monocolor') {
99
        $output = [];
100
 
101
        $output['text'] = get_config('theme_monocolor', 'email_footer_text');
102
        $output['copyright'] = get_config('theme_monocolor', 'email_footer_copyright');
103
        $output['displaylogo'] = get_config('theme_monocolor', 'email_footer_displaylogo');
104
 
105
        return $output;
106
    }
107
 
108
    // Tools.
109
    private function http_or_https() {
110
        global $CFG;
111
 
112
        $output = 'http:';
113
 
114
        if (strpos($CFG->wwwroot, 'https:') !== false) {
115
            $output = 'https:';
116
        }
117
 
118
        return $output;
119
    }
120
 
121
}