Skip to content

Commit

Permalink
MDL-29474 admin index/plugins/environment pages: all ouptut code -> r…
Browse files Browse the repository at this point in the history
…enderer.
  • Loading branch information
timhunt committed Oct 20, 2011
1 parent 99e1a8d commit cc35956
Show file tree
Hide file tree
Showing 7 changed files with 607 additions and 409 deletions.
3 changes: 2 additions & 1 deletion admin/cli/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
$newversion = "$release ($version)";

// test environment first
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
$errors = environment_get_errors($environment_results);
cli_heading(get_string('environment', 'admin'));
foreach ($errors as $error) {
Expand Down
75 changes: 25 additions & 50 deletions admin/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,15 @@
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/componentlib.class.php');

admin_externalpage_setup('environment');

// Parameters
$action = optional_param('action', '', PARAM_ACTION);
$version = optional_param('version', '', PARAM_FILE); //


// Get some strings
$stradmin = get_string('administration');
$stradminhelpenvironment = get_string("adminhelpenvironment");
$strenvironment = get_string('environment', 'admin');
$strerror = get_string('error');
$strmoodleversion = get_string('moodleversion');
$strupdate = get_string('updatecomponent', 'admin');
$strupwards = get_string('upwards', 'admin');
$strmisc = get_string('miscellaneous');

// Print the header stuff
echo $OUTPUT->header();

// Print the component download link
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&amp;sesskey='.sesskey().'">'.$strupdate.'</a></div>';

echo $OUTPUT->heading($strenvironment);
$extraurlparams = array();
if ($version) {
$extraurlparams['version'] = $version;
}
admin_externalpage_setup('environment', '', $extraurlparams);

// Handle the 'updatecomponent' action
if ($action == 'updatecomponent' && confirm_sesskey()) {
Expand All @@ -68,28 +53,27 @@
case COMPONENT_ERROR:
if ($cd->get_error() == 'remotedownloaderror') {
$a = new stdClass();
$a->url = 'http://download.moodle.org/environment/environment.zip';
$a->dest= $CFG->dataroot.'/';
echo $OUTPUT->box(get_string($cd->get_error(), 'error', $a), 'errorbox');
$a->url = 'http://download.moodle.org/environment/environment.zip';
$a->dest = $CFG->dataroot . '/';
print_error($cd->get_error(), 'error', $PAGE->url, $a);
die();

} else {
echo $OUTPUT->box(get_string($cd->get_error(), 'error'), 'errorbox');
print_error($cd->get_error(), 'error', $PAGE->url);
die();
}
break;

case COMPONENT_UPTODATE:
echo $OUTPUT->box(get_string($cd->get_error(), 'error'));
break;
redirect($PAGE->url, get_string($cd->get_error(), 'error'));
die;

case COMPONENT_INSTALLED:
echo $OUTPUT->box(get_string('componentinstalled', 'admin'));
break;
redirect($PAGE->url, get_string('componentinstalled', 'admin'));
die;
}
}
}

// Start of main box
echo $OUTPUT->box_start();

echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";

// Get current Moodle version
$current_version = $CFG->release;

Expand All @@ -111,24 +95,15 @@
}
}
// Add 'upwards' to the last element
$versions[$env_version] = $env_version.' '.$strupwards;
$versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
} else {
$versions = array('error' => $strerror);
$versions = array('error' => get_string('error'));
}
}

// Print form and popup menu
echo '<div style="text-align:center"> ';
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
$select->label = $strmoodleversion;
echo $OUTPUT->render($select);
echo '</div>';

// End of main box
echo $OUTPUT->box_end();

// Gather and show results
$status = check_moodle_environment($version, $environment_results);
// Get the results of the environment check.
list($envstatus, $environment_results) = check_moodle_environment($version);

// Print footer
echo $OUTPUT->footer();
// Display the page.
$output = $PAGE->get_renderer('core', 'admin');
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
Loading

0 comments on commit cc35956

Please sign in to comment.