From 3cf1fea55ab2dada24b027627e1cc07a33c576b5 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 5 Oct 2016 11:38:12 +0800 Subject: [PATCH] MDL-56270 mod_book: Add next/prev chapter to attributes This adds the details of the next/previous chapter to the image attributes and link for the in-page chapter-to-chapter navigation. --- mod/book/lang/en/book.php | 2 ++ mod/book/view.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mod/book/lang/en/book.php b/mod/book/lang/en/book.php index 77381f185cb78..f1724de5fbe3a 100644 --- a/mod/book/lang/en/book.php +++ b/mod/book/lang/en/book.php @@ -84,7 +84,9 @@ $string['confchapterdeleteall'] = 'Do you really want to delete this chapter and all its subchapters?'; $string['top'] = 'top'; $string['navprev'] = 'Previous'; +$string['navprevtitle'] = 'Previous: {$a}'; $string['navnext'] = 'Next'; +$string['navnexttitle'] = 'Next: {$a}'; $string['navexit'] = 'Exit book'; $string['book:addinstance'] = 'Add a new book'; $string['book:read'] = 'View book'; diff --git a/mod/book/view.php b/mod/book/view.php index 6261ad1412e29..f1a1c4b5bc579 100644 --- a/mod/book/view.php +++ b/mod/book/view.php @@ -126,8 +126,10 @@ // prepare chapter navigation icons $previd = null; $prevtitle = null; +$navprevtitle = null; $nextid = null; $nexttitle = null; +$navnexttitle = null; $last = null; foreach ($chapters as $ch) { if (!$edit and $ch->hidden) { @@ -136,11 +138,13 @@ if ($last == $chapter->id) { $nextid = $ch->id; $nexttitle = book_get_chapter_title($ch->id, $chapters, $book, $context); + $navnexttitle = get_string('navnexttitle', 'mod_book', $nexttitle); break; } if ($ch->id != $chapter->id) { $previd = $ch->id; $prevtitle = book_get_chapter_title($ch->id, $chapters, $book, $context); + $navprevtitle = get_string('navprevtitle', 'mod_book', $prevtitle); } $last = $ch->id; } @@ -155,9 +159,9 @@ if ($previd) { $navprev = get_string('navprev', 'book'); if ($book->navstyle == 1) { - $chnavigation .= '' . - '' . $navprev . ''; + '' . $navprevtitle . ''; } else { $chnavigation .= '' . @@ -172,9 +176,9 @@ if ($nextid) { $navnext = get_string('navnext', 'book'); if ($book->navstyle == 1) { - $chnavigation .= '' . - '' . $navnext . ''; + '' . $navnexttitle . ''; } else { $chnavigation .= ' ' .