From 3cfbce12a6fa3a1c57e81b2cd70bcea1498ad719 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 2 May 2018 23:22:13 +0800 Subject: [PATCH 1/2] MDL-62312 admin: Move moodleorg_registration_message to admin renderer --- admin/registration/index.php | 2 +- admin/registration/renderer.php | 41 --------------------------------- admin/renderer.php | 9 ++++++++ lib/upgrade.txt | 6 +++++ 4 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 admin/registration/renderer.php diff --git a/admin/registration/index.php b/admin/registration/index.php index dee1ba00416..57d65a3f404 100644 --- a/admin/registration/index.php +++ b/admin/registration/index.php @@ -110,7 +110,7 @@ if (\core\hub\registration::is_registered()) { echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin')); } -$renderer = $PAGE->get_renderer('core', 'register'); +$renderer = $PAGE->get_renderer('core', 'admin'); echo $renderer->moodleorg_registration_message(); $siteregistrationform->display(); diff --git a/admin/registration/renderer.php b/admin/registration/renderer.php deleted file mode 100644 index b7414b4933e..00000000000 --- a/admin/registration/renderer.php +++ /dev/null @@ -1,41 +0,0 @@ -. // -// // -/////////////////////////////////////////////////////////////////////////// - -/** - * Registration renderer. - * @package moodle - * @subpackage registration - * @copyright 2010 Moodle Pty Ltd (http://moodle.com) - * @author Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class core_register_renderer extends plugin_renderer_base { - - /** - * Display message about the benefits of registering on Moodle.org - * - * @return string - */ - public function moodleorg_registration_message() { - return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]); - } -} diff --git a/admin/renderer.php b/admin/renderer.php index dbd77f6122e..f22c6a2e18b 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -2084,4 +2084,13 @@ class core_admin_renderer extends plugin_renderer_base { return $this->warning(get_string('legacylogginginuse')); } } + + /** + * Display message about the benefits of registering on Moodle.org + * + * @return string + */ + public function moodleorg_registration_message() { + return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]); + } } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index c569cf603b0..43592096658 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -24,6 +24,12 @@ information provided here is intended especially for developers. act as a site policy handler. * There is a new is_fulltext_search_supported() DML function. The default implementation returns false. This function is used by 'Simple search' global search engine to determine if the database full-text search capabilities can be used. +* The following have been removed from the list of core subsystems: + - core_register + - core_publish + Following this change, \core_register_renderer has been removed and it's only method + \core_register_renderer::moodleorg_registration_message() has been moved to + \core_admin_renderer::moodleorg_registration_message(). === 3.4 === From 3127fe10b87270ec69a41f85f169ecbfd6d612c5 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 3 May 2018 09:33:15 +0800 Subject: [PATCH 2/2] MDL-62312 course: Move core_publish renderer methods to course renderer --- course/publish/backup.php | 2 +- course/publish/index.php | 2 +- course/publish/metadata.php | 2 +- course/publish/renderer.php | 204 ------------------------------------ course/renderer.php | 174 ++++++++++++++++++++++++++++++ lib/upgrade.txt | 5 +- 6 files changed, 179 insertions(+), 210 deletions(-) delete mode 100644 course/publish/renderer.php diff --git a/course/publish/backup.php b/course/publish/backup.php index 9899b5f0fd1..c50951fa1ea 100644 --- a/course/publish/backup.php +++ b/course/publish/backup.php @@ -92,7 +92,7 @@ $backupfile = $backupfile['backup_destination']; //display the sending file page echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('sendingcourse', 'hub'), 3, 'main'); -$renderer = $PAGE->get_renderer('core', 'publish'); +$renderer = $PAGE->get_renderer('core', 'course'); echo $renderer->sendingbackupinfo($backupfile); if (ob_get_level()) { ob_flush(); diff --git a/course/publish/index.php b/course/publish/index.php index ad7f7d76051..1ce7fee9ceb 100644 --- a/course/publish/index.php +++ b/course/publish/index.php @@ -62,7 +62,7 @@ if (!empty($updatestatusid) && confirm_sesskey()) { } } -$renderer = $PAGE->get_renderer('core', 'publish'); +$renderer = $PAGE->get_renderer('core', 'course'); // Unpublish course. if ($publication = \core\hub\publication::get_publication($publicationid, $courseid)) { diff --git a/course/publish/metadata.php b/course/publish/metadata.php index 57470a68135..21ffb348803 100644 --- a/course/publish/metadata.php +++ b/course/publish/metadata.php @@ -179,7 +179,7 @@ echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('publishcourseon', 'hub', 'Moodle.net'), 3, 'main'); // Display hub information (logo, name, description). -$renderer = $PAGE->get_renderer('core', 'publish'); +$renderer = $PAGE->get_renderer('core', 'course'); if ($hubinfo = \core\hub\registration::get_moodlenet_info()) { echo $renderer->hubinfo($hubinfo); } diff --git a/course/publish/renderer.php b/course/publish/renderer.php deleted file mode 100644 index 9dbf3b3b377..00000000000 --- a/course/publish/renderer.php +++ /dev/null @@ -1,204 +0,0 @@ -. // -// // -/////////////////////////////////////////////////////////////////////////// - -/** - * Course publish renderer. - * @package course - * @subpackage publish - * @copyright 2010 Moodle Pty Ltd (http://moodle.com) - * @author Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class core_publish_renderer extends plugin_renderer_base { - - /** - * Display the selector to advertise or publish a course - */ - public function publicationselector($courseid) { - $text = ''; - - $advertiseurl = new moodle_url("/course/publish/metadata.php", - array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true)); - $advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub')); - $text .= $this->output->render($advertisebutton); - $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'), - array('class' => 'publishhelp')); - - $text .= html_writer::empty_tag('br'); /// TODO Delete - - $uploadurl = new moodle_url("/course/publish/metadata.php", - array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true)); - $uploadbutton = new single_button($uploadurl, get_string('share', 'hub')); - $text .= $this->output->render($uploadbutton); - $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'), - array('class' => 'publishhelp')); - - return $text; - } - - /** - * Display the listing of hub where a course is registered on - */ - public function registeredonhublisting($courseid, $publications) { - global $CFG; - $table = new html_table(); - $table->head = array(get_string('type', 'hub'), - get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub')); - $table->size = array('20%', '30%', '%20', '%25'); - - $brtag = html_writer::empty_tag('br'); - - foreach ($publications as $publication) { - - $params = array('id' => $publication->courseid, 'publicationid' => $publication->id); - $cancelurl = new moodle_url("/course/publish/index.php", $params); - $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub')); - $cancelbutton->class = 'centeredbutton'; - $cancelbuttonhtml = $this->output->render($cancelbutton); - - if ($publication->enrollable) { - $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'publicationid' => $publication->id); - $updateurl = new moodle_url("/course/publish/metadata.php", $params); - $updatebutton = new single_button($updateurl, get_string('update', 'hub')); - $updatebutton->class = 'centeredbutton'; - $updatebuttonhtml = $this->output->render($updatebutton); - - $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml; - } else { - $operations = $cancelbuttonhtml; - } - - //if the publication check time if bigger than May 2010, it has been checked - if ($publication->timechecked > 1273127954) { - if ($publication->status == 0) { - $status = get_string('statusunpublished', 'hub'); - } else { - $status = get_string('statuspublished', 'hub'); - if (!empty($publication->link)) { - $status = html_writer::link($publication->link, $status); - } - } - - $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'), - array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' - . $courseid . "&updatestatusid=" . $publication->id - . "&sesskey=" . sesskey())) . - $brtag . get_string('lasttimechecked', 'hub') . ": " - . format_time(time() - $publication->timechecked); - } else { - $status = get_string('neverchecked', 'hub') . $brtag - . html_writer::tag('a', get_string('updatestatus', 'hub'), - array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' - . $courseid . "&updatestatusid=" . $publication->id - . "&sesskey=" . sesskey())); - } - //add button cells - $cells = array($publication->enrollable ? - get_string('advertised', 'hub') : get_string('shared', 'hub'), - userdate($publication->timepublished, - get_string('strftimedatetimeshort')), $status, $operations); - $row = new html_table_row($cells); - $table->data[] = $row; - } - - $contenthtml = html_writer::table($table); - - return $contenthtml; - } - - /** - * Display unpublishing confirmation page - * @param object $publication - * $publication->courseshortname - $publication->courseid - $publication->hubname - $publication->huburl - $publication->id - */ - public function confirmunpublishing($publication) { - $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid, - 'hubcourseid' => $publication->hubcourseid, - 'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true); - $optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid); - $publication->hubname = html_writer::tag('a', 'Moodle.net', - array('href' => HUB_MOODLEORGHUBURL)); - $formcontinue = new single_button(new moodle_url("/course/publish/index.php", - $optionsyes), get_string('unpublish', 'hub'), 'post'); - $formcancel = new single_button(new moodle_url("/course/publish/index.php", - $optionsno), get_string('cancel'), 'get'); - return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication), - $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) { - $sizeinfo = new stdClass(); - $sizeinfo->total = number_format($backupfile->get_filesize() / 1000000, 2); - $html = html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo), - array('class' => 'courseuploadtextinfo')); - return $html; - } - - /** - * Display upload successfull message and a button to the publish index page - * @param int $id the course id - * @return $html string - */ - public function sentbackupinfo($id) { - $html = html_writer::tag('div', get_string('sent', 'hub'), - array('class' => 'courseuploadtextinfo')); - $publishindexurl = new moodle_url('/course/publish/index.php', - array('sesskey' => sesskey(), 'id' => $id, - 'published' => true)); - $continue = $this->output->render( - new single_button($publishindexurl, get_string('continue'))); - $html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue')); - return $html; - } - - /** - * Hub information (logo - name - description - link) - * @param object $hubinfo - * @return string html code - */ - public function hubinfo($hubinfo) { - $screenshothtml = html_writer::empty_tag('img', - array('src' => $hubinfo['imgurl'], 'alt' => $hubinfo['name'])); - $hubdescription = html_writer::tag('div', $screenshothtml, - array('class' => 'hubscreenshot')); - - $hubdescription .= html_writer::tag('a', $hubinfo['name'], - array('class' => 'hublink', 'href' => $hubinfo['url'], - 'onclick' => 'this.target="_blank"')); - - $hubdescription .= html_writer::tag('div', format_text($hubinfo['description'], FORMAT_PLAIN), - array('class' => 'hubdescription')); - $hubdescription = html_writer::tag('div', $hubdescription, array('class' => 'hubinfo clearfix')); - - return $hubdescription; - } - -} diff --git a/course/renderer.php b/course/renderer.php index a086ba61fa5..68767ffa8a8 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -2137,6 +2137,180 @@ class core_course_renderer extends plugin_renderer_base { $data = $page->export_for_template($this->output); return $this->output->render_from_template('core_course/activity_navigation', $data); } + + /** + * Display the selector to advertise or publish a course + * @param int $courseid + */ + public function publicationselector($courseid) { + $text = ''; + + $advertiseurl = new moodle_url("/course/publish/metadata.php", + array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true)); + $advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub')); + $text .= $this->output->render($advertisebutton); + $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'), + array('class' => 'publishhelp')); + + $text .= html_writer::empty_tag('br'); // TODO Delete. + + $uploadurl = new moodle_url("/course/publish/metadata.php", + array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true)); + $uploadbutton = new single_button($uploadurl, get_string('share', 'hub')); + $text .= $this->output->render($uploadbutton); + $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'), + array('class' => 'publishhelp')); + + return $text; + } + + /** + * Display the listing of hub where a course is registered on + * @param int $courseid + * @param array $publications + */ + public function registeredonhublisting($courseid, $publications) { + global $CFG; + $table = new html_table(); + $table->head = array(get_string('type', 'hub'), + get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub')); + $table->size = array('20%', '30%', '%20', '%25'); + + $brtag = html_writer::empty_tag('br'); + + foreach ($publications as $publication) { + + $params = array('id' => $publication->courseid, 'publicationid' => $publication->id); + $cancelurl = new moodle_url("/course/publish/index.php", $params); + $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub')); + $cancelbutton->class = 'centeredbutton'; + $cancelbuttonhtml = $this->output->render($cancelbutton); + + if ($publication->enrollable) { + $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'publicationid' => $publication->id); + $updateurl = new moodle_url("/course/publish/metadata.php", $params); + $updatebutton = new single_button($updateurl, get_string('update', 'hub')); + $updatebutton->class = 'centeredbutton'; + $updatebuttonhtml = $this->output->render($updatebutton); + + $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml; + } else { + $operations = $cancelbuttonhtml; + } + + // If the publication check time if bigger than May 2010, it has been checked. + if ($publication->timechecked > 1273127954) { + if ($publication->status == 0) { + $status = get_string('statusunpublished', 'hub'); + } else { + $status = get_string('statuspublished', 'hub'); + if (!empty($publication->link)) { + $status = html_writer::link($publication->link, $status); + } + } + + $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'), + array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' + . $courseid . "&updatestatusid=" . $publication->id + . "&sesskey=" . sesskey())) . + $brtag . get_string('lasttimechecked', 'hub') . ": " + . format_time(time() - $publication->timechecked); + } else { + $status = get_string('neverchecked', 'hub') . $brtag + . html_writer::tag('a', get_string('updatestatus', 'hub'), + array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' + . $courseid . "&updatestatusid=" . $publication->id + . "&sesskey=" . sesskey())); + } + // Add button cells. + $cells = array($publication->enrollable ? + get_string('advertised', 'hub') : get_string('shared', 'hub'), + userdate($publication->timepublished, + get_string('strftimedatetimeshort')), $status, $operations); + $row = new html_table_row($cells); + $table->data[] = $row; + } + + $contenthtml = html_writer::table($table); + + return $contenthtml; + } + + /** + * Display unpublishing confirmation page + * @param stdClass $publication + * $publication->courseshortname + * $publication->courseid + * $publication->hubname + * $publication->huburl + * $publication->id + */ + public function confirmunpublishing($publication) { + $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid, + 'hubcourseid' => $publication->hubcourseid, + 'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true); + $optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid); + $publication->hubname = html_writer::tag('a', 'Moodle.net', + array('href' => HUB_MOODLEORGHUBURL)); + $formcontinue = new single_button(new moodle_url("/course/publish/index.php", + $optionsyes), get_string('unpublish', 'hub'), 'post'); + $formcancel = new single_button(new moodle_url("/course/publish/index.php", + $optionsno), get_string('cancel'), 'get'); + return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication), + $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) { + $sizeinfo = new stdClass(); + $sizeinfo->total = number_format($backupfile->get_filesize() / 1000000, 2); + $html = html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo), + array('class' => 'courseuploadtextinfo')); + return $html; + } + + /** + * Display upload successfull message and a button to the publish index page + * @param int $id the course id + * @return $html string + */ + public function sentbackupinfo($id) { + $html = html_writer::tag('div', get_string('sent', 'hub'), + array('class' => 'courseuploadtextinfo')); + $publishindexurl = new moodle_url('/course/publish/index.php', + array('sesskey' => sesskey(), 'id' => $id, + 'published' => true)); + $continue = $this->output->render( + new single_button($publishindexurl, get_string('continue'))); + $html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue')); + return $html; + } + + /** + * Hub information (logo - name - description - link) + * @param object $hubinfo + * @return string html code + */ + public function hubinfo($hubinfo) { + $screenshothtml = html_writer::empty_tag('img', + array('src' => $hubinfo['imgurl'], 'alt' => $hubinfo['name'])); + $hubdescription = html_writer::tag('div', $screenshothtml, + array('class' => 'hubscreenshot')); + + $hubdescription .= html_writer::tag('a', $hubinfo['name'], + array('class' => 'hublink', 'href' => $hubinfo['url'], + 'onclick' => 'this.target="_blank"')); + + $hubdescription .= html_writer::tag('div', format_text($hubinfo['description'], FORMAT_PLAIN), + array('class' => 'hubdescription')); + $hubdescription = html_writer::tag('div', $hubdescription, array('class' => 'hubinfo clearfix')); + + return $hubdescription; + } } /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 43592096658..360fee16e52 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -27,9 +27,8 @@ information provided here is intended especially for developers. * The following have been removed from the list of core subsystems: - core_register - core_publish - Following this change, \core_register_renderer has been removed and it's only method - \core_register_renderer::moodleorg_registration_message() has been moved to - \core_admin_renderer::moodleorg_registration_message(). + Following this change, \core_register_renderer and \core_publish_renderer have been removed and their methods have been + moved to \core_admin_renderer and \core_course_renderer respectively. === 3.4 ===