Skip to content

Commit

Permalink
Respect the automatic title setting when displaying the block
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jul 29, 2016
1 parent 1677f8a commit 17639cb
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions block_course_contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,47 @@ public function get_content() {
if (!$section->uservisible) {
continue;
}

if ($globalconfig->autotitle === 'forced_off') {
$autotitle = false;

} else if ($globalconfig->autotitle === 'forced_on') {
$autotitle = true;

} else if (empty($this->config) or !isset($this->config->autotitle)) {
// Instance not configured, use the globally defined default value.
if ($globalconfig->autotitle === 'optional_on') {
$autotitle = true;
} else {
$autotitle = false;
}

} else if (!empty($this->config->autotitle)) {
$autotitle = true;

} else {
$autotitle = false;
}

$title = null;

if (!empty($section->name)) {
// If the section has explic title defined, it is used.
$title = format_string($section->name, true, array('context' => $context));
} else {

} else if ($autotitle) {
// Attempt to extract the title from the section summary.
$summary = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course',
'section', $section->id);
$summary = format_text($summary, $section->summaryformat, array('para' => false, 'context' => $context));
$title = format_string($this->extract_title($summary), true, array('context' => $context));
if (empty($title)) {
$title = $format->get_section_name($section);
}
}

// If at this point we have no title available, use the default one.
if (empty($title)) {
$title = $format->get_section_name($section);
}

$odd = $r % 2;
if ($format->is_section_current($section)) {
$text .= html_writer::start_tag('li', array('class' => 'section-item current r'.$odd));
Expand Down

0 comments on commit 17639cb

Please sign in to comment.