From 58ee763bfb6c2425f57a32d94736357dd53e6101 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 10 Sep 2012 15:44:21 +0800 Subject: [PATCH 1/2] MDL-33198 book: Adding h tags to book titles to increase accessibility while printing a book --- mod/book/tool/print/index.php | 13 +++++++++---- mod/book/tool/print/locallib.php | 6 +----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mod/book/tool/print/index.php b/mod/book/tool/print/index.php index 9077b84a9c3..f33f9a11ad7 100644 --- a/mod/book/tool/print/index.php +++ b/mod/book/tool/print/index.php @@ -91,6 +91,7 @@ if ($chapter) { +

name, true, array('context'=>$context)) ?>

customtitles) { if (!$chapter->subchapter) { $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); - echo '

'.$currtitle.'

'; + echo '

'.$currtitle.'

'; } else { $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context); $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); - echo '

'.$currtitle.'
'.$currsubtitle.'

'; + echo '

'.$currtitle.'

'.$currsubtitle.'

'; } } @@ -128,7 +129,7 @@ if ($chapter) { -

name, true, array('context'=>$context)) ?>

+

name, true, array('context'=>$context)) ?>

intro, $book->introformat, array('noclean'=>true, 'context'=>$context)) ?>

@@ -162,7 +163,11 @@ if ($chapter) { } echo '
'; if (!$book->customtitles) { - echo '

'.$titles[$ch->id].'

'; + if (!$chapter->subchapter) { + echo '

'.$titles[$ch->id].'

'; + } else { + echo '

'.$titles[$ch->id].'

'; + } } $content = str_replace($link1, '#ch', $chapter->content); $content = str_replace($link2, '#top', $content); diff --git a/mod/book/tool/print/locallib.php b/mod/book/tool/print/locallib.php index 200bee74867..27838a9ff2e 100644 --- a/mod/book/tool/print/locallib.php +++ b/mod/book/tool/print/locallib.php @@ -60,11 +60,7 @@ function booktool_print_get_toc($chapters, $book, $cm) { $toc .= html_writer::tag('a', '', array('name' => 'toc')); // Representation of toc (HTML). - if ($book->customtitles) { - $toc .= html_writer::tag('h1', get_string('toc', 'mod_book')); - } else { - $toc .= html_writer::tag('p', get_string('toc', 'mod_book'), array('class' => 'book_chapter_title')); - } + $toc .= html_writer::tag('h2', get_string('toc', 'mod_book'), array('class' => 'book_chapter_title')); $toc .= html_writer::start_tag('ul'); foreach ($chapters as $ch) { if (!$ch->hidden) { From ec5c45c4edc550825e63fb648b11426881f9bc05 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 10 Sep 2012 14:45:44 +0800 Subject: [PATCH 2/2] MDL-33198 book: Adding h tags to book title to increase accessibility --- mod/book/view.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mod/book/view.php b/mod/book/view.php index f5643d36a5b..91b83b88f72 100644 --- a/mod/book/view.php +++ b/mod/book/view.php @@ -181,11 +181,12 @@ if (!$book->customtitles) { $hidden = $chapter->hidden ? 'dimmed_text' : ''; if (!$chapter->subchapter) { $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); - echo '

'.$currtitle.'

'; + echo $OUTPUT->heading($currtitle, 2, array('class' => 'book_chapter_title '.$hidden)); } else { $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context); $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); - echo '

'.$currtitle.'
'.$currsubtitle.'

'; + echo $OUTPUT->heading($currtitle, 2, array('class' => 'book_chapter_title '.$hidden)); + echo $OUTPUT->heading($currsubtitle, 3, array('class' => 'book_chapter_title '.$hidden)); } } $chaptertext = file_rewrite_pluginfile_urls($chapter->content, 'pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id);