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