Proyectos de Subversion Moodle

Rev

Rev 543 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
534 ariadna 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
 * A front page layout for the universe theme.
19
 *
20
 * @package   theme_universe
21
 * @copyright 2023 Marcin Czaja (https://rosea.io)
22
 * @license   Commercial https://themeforest.net/licenses
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->libdir . '/behat/lib.php');
28
 
29
$draweropenright = false;
30
$extraclasses = [];
31
// Moodle 4. - Add block button in editing mode.
32
$addblockbutton = $OUTPUT->addblockbutton();
33
if (isloggedin()) {
34
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
35
} else {
36
    $blockdraweropen = false;
37
}
38
 
39
if (defined('BEHAT_SITE_RUNNING')) {
40
    $blockdraweropen = true;
41
}
42
 
43
$extraclasses = ['uses-drawers'];
44
// End.
45
 
46
// Dark mode.
47
if (isloggedin()) {
48
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
49
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
50
 
51
    if (theme_universe_get_setting('darkmodetheme') == '1') {
52
        $darkmodeon = get_user_preferences('darkmode-on');
53
        if ($darkmodeon) {
54
            $extraclasses[] = 'theme-dark';
55
        }
56
    } else {
57
        $darkmodeon = false;
58
    }
59
} else {
60
    $navdraweropen = false;
61
}
62
 
63
if (theme_universe_get_setting('darkmodefirst') == '1') {
64
    $extraclasses[] = 'theme-dark';
65
    $darkmodetheme = false;
66
    $darkmodeon = true;
67
}
68
 
69
$siteurl = $CFG->wwwroot;
70
 
71
$blockshtml = $OUTPUT->blocks('side-pre');
72
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
73
if (!$hasblocks) {
74
    $blockdraweropen = false;
75
}
76
 
77
if ($draweropenright && $hasblocks) {
78
    $extraclasses[] = 'drawer-open-right';
79
}
80
 
81
// Start - Simple Content Builder.
82
$ruiscb = '';
83
$total = 23;
84
for ($i = 0; $i <= $total; $i++) {
85
    ${"block" . $i} = theme_universe_get_setting("block" . $i);
86
}
87
 
88
$array = array();
89
 
90
for ($i = 0; $i <= $total; $i++) {
91
    if (theme_universe_get_setting("displayblock" . $i) == '1') {
92
        $array[$i] = ${"block" . $i};
93
    }
94
    $array[0] = $block0;
95
}
96
 
97
asort($array);
98
foreach ($array as $key => $value) {
99
    $ruiscb .= $OUTPUT->theme_part('block' . $key);
100
}
101
// End - Simple Content Builder.
102
 
103
// Moodle 4.
104
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
105
 
106
$secondarynavigation = false;
107
$overflow = '';
108
if ($PAGE->has_secondary_navigation()) {
109
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
110
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
111
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
112
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
113
    if (!is_null($overflowdata)) {
114
        $overflow = $overflowdata->export_for_template($OUTPUT);
115
    }
116
}
117
 
118
$primary = new core\navigation\output\primary($PAGE);
119
$renderer = $PAGE->get_renderer('core');
120
$primarymenu = $primary->export_for_template($renderer);
121
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
122
// If the settings menu will be included in the header then don't add it here.
123
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
124
 
125
$header = $PAGE->activityheader;
126
$headercontent = $header->export_for_template($renderer);
127
 
128
if (!isloggedin() || isguestuser()) {
129
    $isnotloggedin = true;
130
} else {
131
    $isnotloggedin = false;
132
}
133
 
134
// Check if guest user.
135
if (isguestuser()) {
136
    $extraclasses[] = 'moodle-guest-user';
137
}
138
 
139
if (theme_universe_get_setting('backtotop') == '1') {
140
    $extraclasses[] = 'back-to-top-on';
141
}
142
 
543 ariadna 143
// RUI.
144
$iscoursepage = false;
145
 
146
if ($PAGE->pagetype == 'site-index') {
147
    $isfrontpage = true;
148
} else {
149
    $isfrontpage = false;
150
}
151
 
534 ariadna 152
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
153
 
154
$templatecontext = [
155
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
156
    'output' => $OUTPUT,
157
    'bodyattributes' => $bodyattributes,
158
    'darkmodeon' => !empty($darkmodeon),
159
    'darkmodetheme' => !empty($darkmodetheme),
160
    'siteurl' => $siteurl,
161
    'sidepreblocks' => $blockshtml,
162
    'hasblocks' => $hasblocks,
163
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
164
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
165
    'ruiscb' => $ruiscb,
166
    'navdraweropen' => $navdraweropen,
167
    'draweropenright' => $draweropenright,
168
    'isnotloggedin' => $isnotloggedin,
169
    'isfrontpage' => $isfrontpage,
170
    // Moodle 4.
171
    'blockdraweropen' => $blockdraweropen,
172
    'primarymoremenu' => $primarymenu['moremenu'],
173
    'secondarymoremenu' => $secondarynavigation ?: false,
174
    'forceblockdraweropen' => $forceblockdraweropen,
175
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
176
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
177
    'overflow' => $overflow,
178
    'headercontent' => $headercontent,
179
    'addblockbutton' => $addblockbutton
180
];
181
 
182
// Get and use the course page information banners HTML code, if any course page hints are configured.
183
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
184
if ($coursepageinformationbannershtml) {
185
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
186
}
187
// End.
188
 
189
// Load theme settings.
190
$themesettings = new \theme_universe\util\theme_settings();
191
 
192
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
193
 
544 ariadna 194
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
534 ariadna 195
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 196
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
534 ariadna 197
}
198
 
199
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-frontpage', $templatecontext);