mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-72413 resource: Use the common module for setting the header
This commit is contained in:
parent
7d3927afea
commit
94886e96e7
59
mod/resource/deprecatedlib.php
Normal file
59
mod/resource/deprecatedlib.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* List of deprecated mod_resource functions.
|
||||
*
|
||||
* @package mod_resource
|
||||
* @copyright 2021 Peter D
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Print resource heading.
|
||||
*
|
||||
* @deprecated since Moodle 4.0
|
||||
* @param object $resource
|
||||
* @param object $cm
|
||||
* @param object $course
|
||||
* @param bool $notused This variable is no longer used
|
||||
* @return void
|
||||
*/
|
||||
function resource_print_heading($resource, $cm, $course, $notused = false) {
|
||||
global $OUTPUT;
|
||||
debugging('resource_print_heading is deprecated. Handled by activity_header now.', DEBUG_DEVELOPER);
|
||||
echo $OUTPUT->heading(format_string($resource->name), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print resource introduction.
|
||||
*
|
||||
* @deprecated since Moodle 4.0
|
||||
* @param object $resource
|
||||
* @param object $cm
|
||||
* @param object $course
|
||||
* @param bool $ignoresettings print even if not specified in modedit
|
||||
* @return void
|
||||
*/
|
||||
function resource_print_intro($resource, $cm, $course, $ignoresettings=false) {
|
||||
global $OUTPUT;
|
||||
debugging('resource_print_intro is deprecated. Handled by activity_header now.', DEBUG_DEVELOPER);
|
||||
if ($intro = resource_get_intro($resource, $cm, $ignoresettings)) {
|
||||
echo $OUTPUT->box_start('mod_introbox', 'resourceintro');
|
||||
echo $intro;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ function resource_redirect_if_migrated($oldid, $cmid) {
|
||||
* @return does not return
|
||||
*/
|
||||
function resource_display_embed($resource, $cm, $course, $file) {
|
||||
global $PAGE, $OUTPUT, $USER;
|
||||
global $PAGE, $OUTPUT;
|
||||
|
||||
$clicktoopen = resource_get_clicktoopen($file, $resource->revision);
|
||||
|
||||
@ -99,19 +99,13 @@ function resource_display_embed($resource, $cm, $course, $file) {
|
||||
$code = resourcelib_embed_general($moodleurl, $title, $clicktoopen, $mimetype);
|
||||
}
|
||||
|
||||
resource_print_header($resource, $cm, $course);
|
||||
resource_print_heading($resource, $cm, $course);
|
||||
// Let the module handle the display.
|
||||
$PAGE->activityheader->set_description(resource_get_intro($resource, $cm));
|
||||
|
||||
// Display any activity information (eg completion requirements / dates).
|
||||
$cminfo = cm_info::create($cm);
|
||||
$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id);
|
||||
$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id);
|
||||
echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates);
|
||||
resource_print_header($resource, $cm, $course);
|
||||
|
||||
echo format_text($code, FORMAT_HTML, ['noclean' => true]);
|
||||
|
||||
resource_print_intro($resource, $cm, $course);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@ -131,9 +125,8 @@ function resource_display_frame($resource, $cm, $course, $file) {
|
||||
|
||||
if ($frame === 'top') {
|
||||
$PAGE->set_pagelayout('frametop');
|
||||
$PAGE->activityheader->set_description(resource_get_intro($resource, $cm, true));
|
||||
resource_print_header($resource, $cm, $course);
|
||||
resource_print_heading($resource, $cm, $course);
|
||||
resource_print_intro($resource, $cm, $course);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
@ -208,17 +201,12 @@ function resource_get_clicktodownload($file, $revision) {
|
||||
* @return does not return
|
||||
*/
|
||||
function resource_print_workaround($resource, $cm, $course, $file) {
|
||||
global $CFG, $OUTPUT, $USER;
|
||||
global $CFG, $OUTPUT, $PAGE;
|
||||
|
||||
// Let the module handle the display.
|
||||
$PAGE->activityheader->set_description(resource_get_intro($resource, $cm, true));
|
||||
|
||||
resource_print_header($resource, $cm, $course);
|
||||
resource_print_heading($resource, $cm, $course, true);
|
||||
|
||||
// Display any activity information (eg completion requirements / dates).
|
||||
$cminfo = cm_info::create($cm);
|
||||
$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id);
|
||||
$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id);
|
||||
echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates);
|
||||
|
||||
resource_print_intro($resource, $cm, $course, true);
|
||||
|
||||
$resource->mainfile = $file->get_filename();
|
||||
echo '<div class="resourceworkaround">';
|
||||
@ -270,23 +258,6 @@ function resource_print_header($resource, $cm, $course) {
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print resource heading.
|
||||
* @param object $resource
|
||||
* @param object $cm
|
||||
* @param object $course
|
||||
* @param bool $notused This variable is no longer used
|
||||
* @return void
|
||||
*/
|
||||
function resource_print_heading($resource, $cm, $course, $notused = false) {
|
||||
global $OUTPUT, $PAGE;
|
||||
|
||||
if (!$PAGE->has_secondary_navigation()) {
|
||||
echo $OUTPUT->heading(format_string($resource->name), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets details of the file to cache in course cache to be displayed using {@link resource_get_optional_details()}
|
||||
*
|
||||
@ -415,16 +386,14 @@ function resource_get_optional_details($resource, $cm) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print resource introduction.
|
||||
* Get resource introduction.
|
||||
*
|
||||
* @param object $resource
|
||||
* @param object $cm
|
||||
* @param object $course
|
||||
* @param bool $ignoresettings print even if not specified in modedit
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
function resource_print_intro($resource, $cm, $course, $ignoresettings=false) {
|
||||
global $OUTPUT;
|
||||
|
||||
function resource_get_intro(object $resource, object $cm, bool $ignoresettings = false): string {
|
||||
$options = empty($resource->displayoptions) ? [] : (array) unserialize_array($resource->displayoptions);
|
||||
|
||||
$extraintro = resource_get_optional_details($resource, $cm);
|
||||
@ -433,17 +402,18 @@ function resource_print_intro($resource, $cm, $course, $ignoresettings=false) {
|
||||
$extraintro = html_writer::tag('p', $extraintro, array('class' => 'resourcedetails'));
|
||||
}
|
||||
|
||||
$content = "";
|
||||
if ($ignoresettings || !empty($options['printintro']) || $extraintro) {
|
||||
$gotintro = trim(strip_tags($resource->intro));
|
||||
if ($gotintro || $extraintro) {
|
||||
echo $OUTPUT->box_start('mod_introbox', 'resourceintro');
|
||||
if ($gotintro) {
|
||||
echo format_module_intro('resource', $resource, $cm->id);
|
||||
$content = format_module_intro('resource', $resource, $cm->id);
|
||||
}
|
||||
echo $extraintro;
|
||||
echo $OUTPUT->box_end();
|
||||
$content .= $extraintro;
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -454,12 +424,10 @@ function resource_print_intro($resource, $cm, $course, $ignoresettings=false) {
|
||||
* @return void, does not return
|
||||
*/
|
||||
function resource_print_tobemigrated($resource, $cm, $course) {
|
||||
global $DB, $OUTPUT;
|
||||
|
||||
global $DB, $OUTPUT, $PAGE;
|
||||
$PAGE->activityheader->set_description(resource_get_intro($resource, $cm));
|
||||
$resource_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
|
||||
resource_print_header($resource, $cm, $course);
|
||||
resource_print_heading($resource, $cm, $course);
|
||||
resource_print_intro($resource, $cm, $course);
|
||||
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
@ -473,12 +441,11 @@ function resource_print_tobemigrated($resource, $cm, $course) {
|
||||
* @return void, does not return
|
||||
*/
|
||||
function resource_print_filenotfound($resource, $cm, $course) {
|
||||
global $DB, $OUTPUT;
|
||||
global $DB, $OUTPUT, $PAGE;
|
||||
|
||||
$resource_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
|
||||
$PAGE->activityheader->set_description(resource_get_intro($resource, $cm));
|
||||
resource_print_header($resource, $cm, $course);
|
||||
resource_print_heading($resource, $cm, $course);
|
||||
resource_print_intro($resource, $cm, $course);
|
||||
if ($resource_old) {
|
||||
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
|
||||
} else {
|
||||
|
5
mod/resource/upgrade.txt
Normal file
5
mod/resource/upgrade.txt
Normal file
@ -0,0 +1,5 @@
|
||||
This files describes API changes in the quiz code.
|
||||
|
||||
=== 4.0 ===
|
||||
|
||||
* Functions resource_print_heading and resource_print_intro have been deprecated in favour for the activity header.
|
Loading…
x
Reference in New Issue
Block a user