MDL-41690 course: remove use of deprecated functions

This commit is contained in:
Dan Poltawski 2013-12-17 17:13:53 +08:00
parent 07e78d935f
commit 73ee2fda6b
12 changed files with 34 additions and 35 deletions

View File

@ -114,11 +114,11 @@ class block_recent_activity_renderer extends plugin_renderer_base {
break;
case 'add mod':
$text = get_string('added', 'moodle', $cm->modfullname). '<br />'.
html_writer::link($cm->get_url(), format_string($cm->name, true));
html_writer::link($cm->url, format_string($cm->name, true));
break;
case 'update mod':
$text = get_string('updated', 'moodle', $cm->modfullname). '<br />'.
html_writer::link($cm->get_url(), format_string($cm->name, true));
html_writer::link($cm->url, format_string($cm->name, true));
break;
default:
return '';

View File

@ -44,7 +44,7 @@ class block_site_main_menu extends block_list {
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
$instancename = $cm->get_formatted_name();
if (!($url = $cm->get_url())) {
if (!($url = $cm->url)) {
$this->content->items[] = $content;
$this->content->icons[] = '';
} else {
@ -123,7 +123,7 @@ class block_site_main_menu extends block_list {
$instancename = $mod->get_formatted_name();
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!($url = $mod->get_url())) {
if (!($url = $mod->url)) {
$this->content->items[] = $content . $editbuttons;
$this->content->icons[] = '';
} else {

View File

@ -46,7 +46,7 @@ class block_social_activities extends block_list {
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
$instancename = $cm->get_formatted_name();
if (!($url = $cm->get_url())) {
if (!($url = $cm->url)) {
$this->content->items[] = $content;
$this->content->icons[] = '';
} else {
@ -110,7 +110,7 @@ class block_social_activities extends block_list {
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!($url = $mod->get_url())) {
if (!($url = $mod->url)) {
$this->content->items[] = $content . $editbuttons;
$this->content->icons[] = '';
} else {

View File

@ -729,15 +729,15 @@ class dndupload_ajax_processor {
$resp->icon = $mod->get_icon_url()->out();
$resp->name = $mod->name;
if ($mod->has_view()) {
$resp->link = $mod->get_url()->out();
$resp->link = $mod->url->out();
} else {
$resp->link = null;
}
$resp->content = $mod->get_content();
$resp->content = $mod->content;
$resp->elementid = 'module-'.$mod->id;
$actions = course_get_cm_edit_actions($mod, 0, $mod->sectionnum);
$resp->commands = ' '. $courserenderer->course_section_cm_edit_actions($actions, $mod);
$resp->onclick = $mod->get_on_click();
$resp->onclick = $mod->onclick;
$resp->visible = $mod->visible;
// If using groupings, then display grouping name.

View File

@ -148,15 +148,15 @@ class core_course_external extends external_api {
$modcontext = context_module::instance($cm->id);
if (!empty($cm->showdescription) or $cm->modname == 'label') {
// We want to use the external format. However from reading get_formatted_content(), get_content() format is always FORMAT_HTML.
list($module['description'], $descriptionformat) = external_format_text($cm->get_content(),
// We want to use the external format. However from reading get_formatted_content(), $cm->content format is always FORMAT_HTML.
list($module['description'], $descriptionformat) = external_format_text($cm->content,
FORMAT_HTML, $modcontext->id, $cm->modname, 'intro', $cm->id);
}
//url of the module
$url = $cm->get_url();
$url = $cm->url;
if ($url) { //labels don't have url
$module['url'] = $cm->get_url()->out(false);
$module['url'] = $url->out(false);
}
$canviewhidden = has_capability('moodle/course:viewhiddenactivities',

View File

@ -100,7 +100,7 @@ class format_singleactivity extends format_base {
if (!$cm->uservisible) {
return null;
}
$action = $cm->get_url();
$action = $cm->url;
if (!$action) {
// Do not add to navigation activity without url (i.e. labels).
return null;
@ -412,13 +412,13 @@ class format_singleactivity extends format_base {
// Student views an empty course page.
return;
}
} else if (!$cm->uservisible || !$cm->get_url()) {
} else if (!$cm->uservisible || !$cm->url) {
// Activity is set but not visible to current user or does not have url.
// Display course page (either empty or with availability restriction info).
return;
} else {
// Everything is set up and accessible, redirect to the activity page!
redirect($cm->get_url());
redirect($cm->url);
}
}
}

View File

@ -743,7 +743,7 @@ class core_course_renderer extends plugin_renderer_base {
// nothing to be displayed to the user
return $output;
}
$url = $mod->get_url();
$url = $mod->url;
if (!$url) {
return $output;
}
@ -793,7 +793,7 @@ class core_course_renderer extends plugin_renderer_base {
// Get on-click attribute value if specified and decode the onclick - it
// has already been encoded for display (puke).
$onclick = htmlspecialchars_decode($mod->get_on_click(), ENT_QUOTES);
$onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES);
$groupinglabel = '';
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', context_course::instance($mod->course))) {
@ -851,7 +851,7 @@ class core_course_renderer extends plugin_renderer_base {
} else {
$textclasses .= ' dimmed_text';
}
if ($mod->get_url()) {
if ($mod->url) {
if ($content) {
// If specified, display extra content after link.
$output = html_writer::tag('div', $content, array('class' =>
@ -923,7 +923,7 @@ class core_course_renderer extends plugin_renderer_base {
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->get_extra_classes();
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
@ -937,7 +937,6 @@ class core_course_renderer extends plugin_renderer_base {
*
* This function calls:
* {@link core_course_renderer::course_section_cm_name()}
* {@link cm_info::get_after_link()}
* {@link core_course_renderer::course_section_cm_text()}
* {@link core_course_renderer::course_section_cm_availability()}
* {@link core_course_renderer::course_section_cm_completion()}
@ -1005,7 +1004,7 @@ class core_course_renderer extends plugin_renderer_base {
}
// Module can put text after the link (e.g. forum unread)
$output .= $mod->get_after_link();
$output .= $mod->afterlink;
// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
$output .= html_writer::end_tag('div'); // .activityinstance
@ -1018,7 +1017,7 @@ class core_course_renderer extends plugin_renderer_base {
// it should work similarly (at least in terms of ordering) to an
// activity.
$contentpart = $this->course_section_cm_text($mod, $displayoptions);
$url = $mod->get_url();
$url = $mod->url;
if (empty($url)) {
$output .= $contentpart;
}
@ -1027,7 +1026,7 @@ class core_course_renderer extends plugin_renderer_base {
if ($this->page->user_is_editing()) {
$editactions = course_get_cm_edit_actions($mod, $mod->indent, $sectionreturn);
$modicons .= ' '. $this->course_section_cm_edit_actions($editactions, $mod, $displayoptions);
$modicons .= $mod->get_after_edit_icons();
$modicons .= $mod->afterediticons;
}
$modicons .= $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);

View File

@ -600,13 +600,13 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
foreach($firstsection['modules'] as $module) {
if ($module['id'] == $forumcm->id and $module['modname'] == 'forum') {
$cm = $modinfo->cms[$forumcm->id];
$formattedtext = format_text($cm->get_content(), FORMAT_HTML,
$formattedtext = format_text($cm->content, FORMAT_HTML,
array('noclean' => true, 'para' => false, 'filter' => false));
$this->assertEquals($formattedtext, $module['description']);
$testexecuted = $testexecuted + 1;
} else if ($module['id'] == $labelcm->id and $module['modname'] == 'label') {
$cm = $modinfo->cms[$labelcm->id];
$formattedtext = format_text($cm->get_content(), FORMAT_HTML,
$formattedtext = format_text($cm->content, FORMAT_HTML,
array('noclean' => true, 'para' => false, 'filter' => false));
$this->assertEquals($formattedtext, $module['description']);
$testexecuted = $testexecuted + 1;

View File

@ -1860,13 +1860,13 @@ class global_navigation extends navigation_node {
$activity->hidden = (!$cm->visible);
$activity->modname = $cm->modname;
$activity->nodetype = navigation_node::NODETYPE_LEAF;
$activity->onclick = $cm->get_on_click();
$url = $cm->get_url();
$activity->onclick = $cm->onclick;
$url = $cm->url;
if (!$url) {
$activity->url = null;
$activity->display = false;
} else {
$activity->url = $cm->get_url()->out();
$activity->url = $url->out();
$activity->display = $cm->uservisible ? true : false;
if (self::module_extends_navigation($cm->modname)) {
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
@ -2011,7 +2011,7 @@ class global_navigation extends navigation_node {
} else {
$icon = new pix_icon('icon', get_string('modulename', $cm->modname), $cm->modname);
}
$url = $cm->get_url();
$url = $cm->url;
$activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
$activitynode->title(get_string('modulename', $cm->modname));
$activitynode->hidden = (!$cm->visible);

View File

@ -460,7 +460,7 @@ function folder_get_coursemodule_info($cm) {
* @param cm_info $cm
*/
function folder_cm_info_dynamic(cm_info $cm) {
if ($cm->get_custom_data()) {
if ($cm->customdata) {
// the field 'customdata' is not empty IF AND ONLY IF we display contens inline
$cm->set_no_view_link();
}
@ -474,12 +474,12 @@ function folder_cm_info_dynamic(cm_info $cm) {
*/
function folder_cm_info_view(cm_info $cm) {
global $PAGE;
if ($cm->uservisible && $cm->get_custom_data() &&
if ($cm->uservisible && $cm->customdata &&
has_capability('mod/folder:view', $cm->context)) {
// Restore folder object from customdata.
// Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline.
// Otherwise the content is default.
$folder = $cm->get_custom_data();
$folder = $cm->customdata;
$folder->id = (int)$cm->instance;
$folder->course = (int)$cm->course;
$folder->display = FOLDER_DISPLAY_INLINE;

View File

@ -8009,7 +8009,7 @@ function forum_cm_info_view(cm_info $cm) {
if (forum_tp_can_track_forums()) {
if ($unread = forum_tp_count_forum_unread_posts($cm, $cm->get_course())) {
$out = '<span class="unread"> <a href="' . $cm->get_url() . '">';
$out = '<span class="unread"> <a href="' . $cm->url . '">';
if ($unread == 1) {
$out .= get_string('unreadpostsone', 'forum');
} else {

View File

@ -288,7 +288,7 @@ function resource_get_coursemodule_info($coursemodule) {
* @param cm_info $cm Course module information
*/
function resource_cm_info_view(cm_info $cm) {
$details = $cm->get_custom_data();
$details = $cm->customdata;
if ($details) {
$cm->set_after_link(' ' . html_writer::tag('span', $details,
array('class' => 'resourcelinkdetails')));