mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-37085 Substitute get_print_section_cm_text() with cm_info functions
This commit is contained in:
parent
f558b291c1
commit
f89c53f679
4 changed files with 61 additions and 38 deletions
|
@ -41,8 +41,8 @@ class block_site_main_menu extends block_list {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($content, $instancename) =
|
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||||
get_print_section_cm_text($cm, $course);
|
$instancename = $cm->get_formatted_name();
|
||||||
|
|
||||||
if (!($url = $cm->get_url())) {
|
if (!($url = $cm->get_url())) {
|
||||||
$this->content->items[] = $content;
|
$this->content->items[] = $content;
|
||||||
|
@ -111,8 +111,8 @@ class block_site_main_menu extends block_list {
|
||||||
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
||||||
$this->content->icons[] = '';
|
$this->content->icons[] = '';
|
||||||
}
|
}
|
||||||
list($content, $instancename) =
|
$content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||||
get_print_section_cm_text($modinfo->cms[$modnumber], $course);
|
$instancename = $mod->get_formatted_name();
|
||||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||||
|
|
||||||
if (!($url = $mod->get_url())) {
|
if (!($url = $mod->get_url())) {
|
||||||
|
|
|
@ -43,8 +43,8 @@ class block_social_activities extends block_list {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($content, $instancename) =
|
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||||
get_print_section_cm_text($cm, $course);
|
$instancename = $cm->get_formatted_name();
|
||||||
|
|
||||||
if (!($url = $cm->get_url())) {
|
if (!($url = $cm->get_url())) {
|
||||||
$this->content->items[] = $content;
|
$this->content->items[] = $content;
|
||||||
|
@ -113,8 +113,8 @@ class block_social_activities extends block_list {
|
||||||
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
||||||
$this->content->icons[] = '';
|
$this->content->icons[] = '';
|
||||||
}
|
}
|
||||||
list($content, $instancename) =
|
$content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||||
get_print_section_cm_text($modinfo->cms[$modnumber], $course);
|
$instancename = $mod->get_formatted_name();
|
||||||
|
|
||||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||||
|
|
||||||
|
|
|
@ -1307,42 +1307,18 @@ function set_section_visible($courseid, $sectionnumber, $visibility) {
|
||||||
*
|
*
|
||||||
* Calls format_text or format_string as appropriate, and obtains the correct icon.
|
* Calls format_text or format_string as appropriate, and obtains the correct icon.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 2.5
|
||||||
|
*
|
||||||
* This data is also used in other areas of the code.
|
* This data is also used in other areas of the code.
|
||||||
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
|
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
|
||||||
* @param object $course Moodle course object
|
* @param object $course (argument not used)
|
||||||
* @return array An array with the following values in this order:
|
* @return array An array with the following values in this order:
|
||||||
* $content (optional extra content for after link),
|
* $content (optional extra content for after link),
|
||||||
* $instancename (text of link)
|
* $instancename (text of link)
|
||||||
*/
|
*/
|
||||||
function get_print_section_cm_text(cm_info $cm, $course) {
|
function get_print_section_cm_text(cm_info $cm, $course) {
|
||||||
global $OUTPUT;
|
return array($cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)),
|
||||||
|
$cm->get_formatted_name());
|
||||||
// Get content from modinfo if specified. Content displays either
|
|
||||||
// in addition to the standard link (below), or replaces it if
|
|
||||||
// the link is turned off by setting ->url to null.
|
|
||||||
if (($content = $cm->get_content()) !== '') {
|
|
||||||
// Improve filter performance by preloading filter setttings for all
|
|
||||||
// activities on the course (this does nothing if called multiple
|
|
||||||
// times)
|
|
||||||
filter_preload_activities($cm->get_modinfo());
|
|
||||||
|
|
||||||
// Get module context
|
|
||||||
$modulecontext = context_module::instance($cm->id);
|
|
||||||
$labelformatoptions = new stdClass();
|
|
||||||
$labelformatoptions->noclean = true;
|
|
||||||
$labelformatoptions->overflowdiv = true;
|
|
||||||
$labelformatoptions->context = $modulecontext;
|
|
||||||
$content = format_text($content, FORMAT_HTML, $labelformatoptions);
|
|
||||||
} else {
|
|
||||||
$content = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get course context
|
|
||||||
$coursecontext = context_course::instance($course->id);
|
|
||||||
$stringoptions = new stdClass;
|
|
||||||
$stringoptions->context = $coursecontext;
|
|
||||||
$instancename = format_string($cm->name, true, $stringoptions);
|
|
||||||
return array($content, $instancename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1463,7 +1439,8 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||||
echo html_writer::start_tag('div', array('class' => $indentclasses));
|
echo html_writer::start_tag('div', array('class' => $indentclasses));
|
||||||
|
|
||||||
// Get data about this course-module
|
// Get data about this course-module
|
||||||
list($content, $instancename) = get_print_section_cm_text($mod, $course);
|
$content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||||
|
$instancename = $mod->get_formatted_name();
|
||||||
|
|
||||||
//Accessibility: for files get description via icon, this is very ugly hack!
|
//Accessibility: for files get description via icon, this is very ugly hack!
|
||||||
$altname = '';
|
$altname = '';
|
||||||
|
|
|
@ -756,6 +756,52 @@ class cm_info extends stdClass {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the content to display on course/overview page, formatted and passed through filters
|
||||||
|
*
|
||||||
|
* if $options['context'] is not specified, the module context is used
|
||||||
|
*
|
||||||
|
* @param array|stdClass $options formatting options, see {@link format_text()}
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_formatted_content($options = array()) {
|
||||||
|
$this->obtain_view_data();
|
||||||
|
if (empty($this->content)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if ($this->modname === 'label') {
|
||||||
|
// special case, label returns already formatted content, see cm_info::__construct()
|
||||||
|
// and label_get_coursemodule_info()
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
// Improve filter performance by preloading filter setttings for all
|
||||||
|
// activities on the course (this does nothing if called multiple
|
||||||
|
// times)
|
||||||
|
filter_preload_activities($this->get_modinfo());
|
||||||
|
|
||||||
|
$options = (array)$options;
|
||||||
|
if (!isset($options['context'])) {
|
||||||
|
$options['context'] = context_module::instance($this->id);
|
||||||
|
}
|
||||||
|
return format_text($this->content, FORMAT_HTML, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name to display on course/overview page, formatted and passed through filters
|
||||||
|
*
|
||||||
|
* if $options['context'] is not specified, the module context is used
|
||||||
|
*
|
||||||
|
* @param array|stdClass $options formatting options, see {@link format_string()}
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_formatted_name($options = array()) {
|
||||||
|
$options = (array)$options;
|
||||||
|
if (!isset($options['context'])) {
|
||||||
|
$options['context'] = context_module::instance($this->id);
|
||||||
|
}
|
||||||
|
return format_string($this->name, true, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: Will collect view data, if not already obtained.
|
* Note: Will collect view data, if not already obtained.
|
||||||
* @return string Extra CSS classes to add to html output for this activity on main page
|
* @return string Extra CSS classes to add to html output for this activity on main page
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue