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
 * The administration and management interface for the cache setup and configuration.
19
 *
20
 * This file is part of Moodle's cache API, affectionately called MUC.
21
 *
22
 * @package    core
23
 * @category   cache
24
 * @copyright  2012 Sam Hemelryk
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
 
1441 ariadna 28
use core_cache\factory as cache_factory;
29
use core_cache\helper as cache_helper;
30
 
1 efrain 31
require_once('../config.php');
32
require_once($CFG->dirroot.'/lib/adminlib.php');
33
 
34
// The first time the user visits this page we are going to reparse the definitions.
35
// Just ensures that everything is up to date.
36
// We flag is session so that this only happens once as people are likely to hit
37
// this page several times if making changes.
38
if (empty($SESSION->cacheadminreparsedefinitions)) {
39
    cache_helper::update_definitions();
40
    $SESSION->cacheadminreparsedefinitions = true;
41
}
42
 
43
$action = optional_param('action', null, PARAM_ALPHA);
44
 
45
admin_externalpage_setup('cacheconfig');
46
$adminhelper = cache_factory::instance()->get_administration_display_helper();
47
 
48
$notifications = array();
49
// Empty array to hold any form information returned from actions.
50
$forminfo = [];
51
 
52
$PAGE->set_primary_active_tab('siteadminnode');
53
$PAGE->navbar->add(get_string('cacheconfig', 'cache'), new moodle_url('/cache/admin.php'));
54
 
55
// Handle page actions in admin helper class.
56
if (!empty($action)) {
57
    $forminfo = $adminhelper->perform_cache_actions($action, $forminfo);
58
}
59
 
60
// Add cache store warnings to the list of notifications.
61
// Obviously as these are warnings they are show as failures.
62
foreach (cache_helper::warnings(core_cache\administration_helper::get_store_instance_summaries()) as $warning) {
63
    $notifications[] = array($warning, false);
64
}
65
 
66
// Decide on display mode based on returned forminfo.
67
$mform = array_key_exists('form', $forminfo) ? $forminfo['form'] : null;
68
$title = array_key_exists('title', $forminfo) ? $forminfo['title'] : new lang_string('cacheadmin', 'cache');
69
 
70
$PAGE->set_title($title);
71
$PAGE->set_heading($SITE->fullname);
72
 
73
/** @var \core_cache\output\renderer $renderer */
74
$renderer = $PAGE->get_renderer('core_cache');
75
 
76
echo $renderer->header();
77
echo $renderer->heading($title);
78
echo $renderer->notifications($notifications);
79
 
80
if ($mform instanceof moodleform) {
81
    $mform->display();
82
} else {
83
    // Handle main page definition in admin helper class.
84
    echo $adminhelper->generate_admin_page($renderer);
85
}
86
 
87
echo $renderer->footer();