Merge branch 'MDL-46984_master' of https://github.com/markn86/moodle

This commit is contained in:
Sam Hemelryk 2014-10-09 09:16:40 +13:00
commit b92a7dd0d8
2 changed files with 18 additions and 7 deletions

View File

@ -791,12 +791,7 @@ class core_course_renderer extends plugin_renderer_base {
// has already been encoded for display (puke).
$onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES);
$groupinglabel = '';
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', context_course::instance($mod->course))) {
$groupings = groups_get_all_groupings($mod->course);
$groupinglabel = html_writer::tag('span', '('.format_string($groupings[$mod->groupingid]->name).')',
array('class' => 'groupinglabel '.$textclasses));
}
$groupinglabel = $mod->get_grouping_label($textclasses);
// Display link itself.
$activitylink = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(),
@ -853,8 +848,10 @@ class core_course_renderer extends plugin_renderer_base {
trim('contentafterlink ' . $textclasses)));
}
} else {
$groupinglabel = $mod->get_grouping_label($textclasses);
// No link, so display only content.
$output = html_writer::tag('div', $accesstext . $content,
$output = html_writer::tag('div', $accesstext . $content . $groupinglabel,
array('class' => 'contentwithoutlink ' . $textclasses));
}
return $output;

View File

@ -1396,6 +1396,20 @@ class cm_info implements IteratorAggregate {
return $icon;
}
/**
* @param string $textclasses additionnal classes for grouping label
* @return string An empty string or HTML grouping label span tag
*/
public function get_grouping_label($textclasses = '') {
$groupinglabel = '';
if (!empty($this->groupingid) && has_capability('moodle/course:managegroups', context_course::instance($this->course))) {
$groupings = groups_get_all_groupings($this->course);
$groupinglabel = html_writer::tag('span', '('.format_string($groupings[$this->groupingid]->name).')',
array('class' => 'groupinglabel '.$textclasses));
}
return $groupinglabel;
}
/**
* Returns a localised human-readable name of the module type
*