publication MDL-24608 display a waiting page when uploading a backup

This commit is contained in:
jerome mouneyrac 2010-10-15 08:56:06 +00:00
parent f6fa64f07a
commit 60cc2f788e
3 changed files with 52 additions and 5 deletions

View File

@ -98,6 +98,13 @@ $backupfile = $backupfile['backup_destination'];
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_registeredhub($huburl);
//display the sending file page
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('sendingcourse', 'hub'), 3, 'main');
$renderer = $PAGE->get_renderer('core', 'publish');
echo $renderer->sendingbackupinfo($backupfile);
flush();
//send backup file to the hub
$curl = new curl();
$params = array();
@ -110,8 +117,7 @@ $curl->post($huburl . "/local/hub/webservice/upload.php", $params);
//delete the temp backup file from user_tohub aera
$backupfile->delete();
//redirect to the index publication page
redirect(new moodle_url('/course/publish/index.php',
array('sesskey' => sesskey(), 'id' => $id,
'published' => true, 'huburl' => $huburl, 'hubname' => $hubname)));
?>
//Output sending success
echo $renderer->sentbackupinfo($id, $huburl, $hubname);
echo $OUTPUT->footer();

View File

@ -158,4 +158,40 @@ class core_publish_renderer extends plugin_renderer_base {
$formcontinue, $formcancel);
}
/**
* Display waiting information about backup size during uploading backup process
* @param object $backupfile the backup stored_file
* @return $html string
*/
public function sendingbackupinfo($backupfile) {
$html = html_writer::tag('div', get_string('sending', 'hub'),
array('class' => 'textinfo'));
$sizeinfo = new stdClass();
$sizeinfo->total = $backupfile->get_filesize() / 1000000;
$sizeinfo->modem = (int) ($backupfile->get_filesize() / 5000);
$sizeinfo->dsl = (int) $sizeinfo->total;
$html .= html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo),
array('class' => 'textinfo'));
return $html;
}
/**
* Display upload successfull message and a button to the publish index page
* @param int $id the course id
* @param string $huburl the hub url where the course is published
* @param string $hubname the hub name where the course is published
* @return $html string
*/
public function sentbackupinfo($id, $huburl, $hubname) {
$html = html_writer::tag('div', get_string('sent', 'hub'),
array('class' => 'textinfo'));
$publishindexurl = new moodle_url('/course/publish/index.php',
array('sesskey' => sesskey(), 'id' => $id,
'published' => true, 'huburl' => $huburl, 'hubname' => $hubname));
$continue = $this->output->render(
new single_button($publishindexurl, get_string('continue', 'hub')));
$html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue'));
return $html;
}
}

View File

@ -52,6 +52,7 @@ $string['contactemail'] = 'Contact email';
$string['contactname'] = 'Contact name';
$string['contactphone'] = 'Phone';
$string['contactphone_help'] = 'Phone numbers are displayed to the Hub administrator only and are not shown publicly.';
$string['continue'] = 'Continue';
$string['contributornames'] = 'Other contributors';
$string['contributornames_help'] = 'You can use this field to list the names of anyone else who contributed to this course.';
$string['coursemap'] = 'Course map';
@ -183,8 +184,12 @@ $string['selecthub'] = 'Select hub';
$string['selecthubinfo'] = 'A community hub is a server that lists courses. You can only publish your courses on hubs that this Moodle site is registered with. If the hub you want is not listed below, please contact your site administrator.';
$string['selecthubforadvertise'] = 'Select hub for advertising';
$string['selecthubforsharing'] = 'Select hub for uploading';
$string['sending'] = 'Do not refresh your browser ! The site is sending the course backup...';
$string['sendingcourse'] = 'Sending course';
$string['sendingsize'] = 'Sending the backup ({$a->total}Mb) should take approximately between {$a->dsl}s and {$a->modem}s, depending on the site/hub connection...';
$string['sendfollowinginfo'] = 'More information';
$string['sendfollowinginfo_help'] = 'The following information will be sent to contribute to overall statistics only. It will not be made public on any site listing.';
$string['sent'] = '...finished';
$string['settings'] = 'Settings';
$string['settingsupdated'] = 'Settings have been updated.';
$string['share'] = 'Share this course for people to download';