/** * Renders html to display the module content on the course page (i.e. text of the labels) * * @param cm_info $mod * @param array $displayoptions * @return string */ public function course_section_cm_text(cm_info $mod, $displayoptions = array()) { $output = ''; if (!$mod->uservisible && empty($mod->availableinfo)) { // nothing to be displayed to the user return $output; } $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); $accesstext = ''; $textclasses = ''; if ($mod->uservisible) { $conditionalhidden = $this->is_cm_conditionally_hidden($mod); $accessiblebutdim = (!$mod->visible || $conditionalhidden) && has_capability('moodle/course:viewhiddenactivities', $mod->context); if ($accessiblebutdim) { $textclasses .= ' dimmed_text'; if ($conditionalhidden) { $textclasses .= ' conditionalhidden'; } // Show accessibility note only if user can access the module himself. $accesstext = get_accesshide(get_string('hiddenfromstudents') . ':' . $mod->modfullname); } } else { $textclasses .= ' dimmed_text'; } if ($mod->url) { if ($content) { // If specified, display extra content after link. $output = html_writer::tag('div', $content, array('class' => trim('contentafterlink ' . $textclasses))); } } else { $groupinglabel = $mod->get_grouping_label($textclasses); // No link, so display only content. $output = html_writer::tag('div', $accesstext . $content . $groupinglabel, array('class' => 'contentwithoutlink ' . $textclasses)); } return $output; }
/** * Obtains shared data that is used in print_section when displaying a * course-module entry. * * Deprecated. Instead of: * list($content, $name) = get_print_section_cm_text($cm, $course); * use: * $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); * $name = $cm->get_formatted_name(); * * @deprecated since 2.5 * @see cm_info::get_formatted_content() * @see cm_info::get_formatted_name() * * 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 object $course (argument not used) * @return array An array with the following values in this order: * $content (optional extra content for after link), * $instancename (text of link) */ function get_print_section_cm_text(cm_info $cm, $course) { debugging('Function get_print_section_cm_text() is deprecated. Please use ' . 'cm_info::get_formatted_content() and cm_info::get_formatted_name()', DEBUG_DEVELOPER); return array($cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)), $cm->get_formatted_name()); }
/** * Renders html to display the module content on the course page (i.e. text of the labels) * * @param cm_info $mod * @param array $displayoptions * @return string */ public function course_section_cm_text(cm_info $mod, $displayoptions = array()) { $output = ''; if (!$mod->uservisible && (empty($mod->showavailability) || empty($mod->availableinfo))) { // nothing to be displayed to the user return $output; } $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); $conditionalhidden = $this->is_cm_conditionally_hidden($mod); $accessiblebutdim = !$mod->visible || $conditionalhidden; $textclasses = ''; $accesstext = ''; if ($accessiblebutdim) { $textclasses .= ' dimmed_text'; if ($conditionalhidden) { $textclasses .= ' conditionalhidden'; } if ($mod->uservisible) { // show accessibility note only if user can access the module himself $accesstext = get_accesshide(get_string('hiddenfromstudents') . ': '); } } if ($mod->get_url()) { if ($content) { // If specified, display extra content after link. $output = html_writer::tag('div', $content, array('class' => trim('contentafterlink ' . $textclasses))); } } else { // No link, so display only content. $output = html_writer::tag('div', $accesstext . $content, array('class' => $textclasses)); } return $output; }