diff --git a/mod/book/backup/moodle1/lib.php b/mod/book/backup/moodle1/lib.php
index f0a1cba9cf8..00805bf2dbf 100644
--- a/mod/book/backup/moodle1/lib.php
+++ b/mod/book/backup/moodle1/lib.php
@@ -130,14 +130,14 @@ class moodle1_mod_book_handler extends moodle1_mod_handler {
}
/**
- * This is executed when the parser reaches the opening element
+ * This is executed when the parser reaches the opening element
*/
public function on_book_chapters_start() {
$this->xmlwriter->begin_tag('chapters');
}
/**
- * This is executed when the parser reaches the closing element
+ * This is executed when the parser reaches the closing element
*/
public function on_book_chapters_end() {
$this->xmlwriter->end_tag('chapters');
diff --git a/mod/book/db/upgrade.php b/mod/book/db/upgrade.php
index c25f93f6c36..735116cd360 100644
--- a/mod/book/db/upgrade.php
+++ b/mod/book/db/upgrade.php
@@ -13,7 +13,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Book module upgrade code
*
diff --git a/mod/book/delete.php b/mod/book/delete.php
index 196d10336a0..63c9507064a 100644
--- a/mod/book/delete.php
+++ b/mod/book/delete.php
@@ -45,9 +45,8 @@ $chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$b
// Header and strings.
-$PAGE->set_title(format_string($book->name));
-$PAGE->add_body_class('mod_book');
-$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title($book->name);
+$PAGE->set_heading($course->fullname);
// Form processing.
if ($confirm) { // the operation was confirmed.
diff --git a/mod/book/edit.php b/mod/book/edit.php
index a625636669b..541233daf48 100644
--- a/mod/book/edit.php
+++ b/mod/book/edit.php
@@ -108,9 +108,8 @@ if ($mform->is_cancelled()) {
}
// Otherwise fill and print the form.
-$PAGE->set_title(format_string($book->name));
-$PAGE->add_body_class('mod_book');
-$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title($book->name);
+$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('editingchapter', 'mod_book'));
diff --git a/mod/book/edit_form.php b/mod/book/edit_form.php
index 4e424d91574..c62d6674411 100644
--- a/mod/book/edit_form.php
+++ b/mod/book/edit_form.php
@@ -29,11 +29,19 @@ require_once($CFG->libdir.'/formslib.php');
class book_chapter_edit_form extends moodleform {
function definition() {
- global $CFG;
$chapter = $this->_customdata['chapter'];
$options = $this->_customdata['options'];
+ //Disabled subchapter option when editing first node
+ $disabledmsg = null;
+ $disabledarr = null;
+
+ if (!$chapter->id && $chapter->pagenum == 1 || $chapter->pagenum == 1) {
+ $disabledmsg = get_string('subchapternotice', 'book');
+ $disabledarr = array('group' => 1, 'disabled' => 'disabled');
+ }
+
$mform = $this->_form;
$mform->addElement('header', 'general', get_string('edit'));
@@ -42,7 +50,7 @@ class book_chapter_edit_form extends moodleform {
$mform->setType('title', PARAM_RAW);
$mform->addRule('title', null, 'required', null, 'client');
- $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'mod_book'));
+ $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'mod_book'), $disabledmsg, $disabledarr);
$mform->addElement('editor', 'content_editor', get_string('content', 'mod_book'), null, $options);
$mform->setType('content_editor', PARAM_RAW);
diff --git a/mod/book/index.php b/mod/book/index.php
index bf8b117b705..b413ba3cc2c 100644
--- a/mod/book/index.php
+++ b/mod/book/index.php
@@ -88,14 +88,14 @@ foreach ($books as $book) {
$currentsection = $book->section;
}
} else {
- $printsection = ''.userdate($book->timemodified)."";
+ $printsection = html_writer::tag('span', userdate($book->timemodified), array('class' => 'smallinfo'));
}
- $class = $book->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed
+ $class = $book->visible ? null : array('class' => 'dimmed'); // hidden modules are dimmed
$table->data[] = array (
$printsection,
- "id\">".format_string($book->name)."",
+ html_writer::link(new moodle_url('view.php', array('id' => $cm->id)), format_string($book->name), $class),
format_module_intro('book', $book, $cm->id));
}
diff --git a/mod/book/lang/en/book.php b/mod/book/lang/en/book.php
index 7b10beb3a1e..c853dd28383 100644
--- a/mod/book/lang/en/book.php
+++ b/mod/book/lang/en/book.php
@@ -58,7 +58,6 @@ $string['numbering2'] = 'Bullets';
$string['numbering3'] = 'Indented';
$string['numberingoptions'] = 'Available options for chapter formatting';
$string['numberingoptions_desc'] = 'Options for displaying chapters and subchapters in the table of contents';
-$string['chapterscount'] = 'Chapters';
$string['addafter'] = 'Add new chapter';
$string['confchapterdelete'] = 'Do you really want to delete this chapter?';
$string['confchapterdeleteall'] = 'Do you really want to delete this chapter and all its subchapters?';
@@ -73,6 +72,6 @@ $string['book:viewhiddenchapters'] = 'View hidden book chapters';
$string['errorchapter'] = 'Error reading chapter of book.';
$string['page-mod-book-x'] = 'Any book module page';
-
+$string['subchapternotice'] = 'This option is disabled, because the first chapter cannot be a subchapter';
$string['subplugintype_booktool'] = 'Book tool';
$string['subplugintype_booktool_plural'] = 'Book tools';
diff --git a/mod/book/lib.php b/mod/book/lib.php
index 50da68b4d19..7ba75b61138 100644
--- a/mod/book/lib.php
+++ b/mod/book/lib.php
@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die;
* @return array
*/
function book_get_numbering_types() {
- global $CFG; // required for the include
+
require_once(dirname(__FILE__).'/locallib.php');
return array (
@@ -215,7 +215,6 @@ function book_scale_used_anywhere($scaleid) {
* @return array
*/
function book_get_view_actions() {
- global $CFG; // necessary for includes
$return = array('view', 'view all');
@@ -240,7 +239,6 @@ function book_get_view_actions() {
* @return array
*/
function book_get_post_actions() {
- global $CFG; // necessary for includes
$return = array('update');
@@ -291,13 +289,11 @@ function book_supports($feature) {
* @return void
*/
function book_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
- global $USER, $PAGE, $CFG, $DB, $OUTPUT;
- if ($PAGE->cm->modname !== 'book') {
- return;
- }
+ global $USER, $PAGE;
$plugins = get_plugin_list('booktool');
+
foreach ($plugins as $plugin => $dir) {
if (file_exists("$dir/lib.php")) {
require_once("$dir/lib.php");
diff --git a/mod/book/locallib.php b/mod/book/locallib.php
index e51522b31cc..ae144c68d80 100644
--- a/mod/book/locallib.php
+++ b/mod/book/locallib.php
@@ -24,6 +24,8 @@
defined('MOODLE_INTERNAL') || die;
+global $CFG;
+
require_once(dirname(__FILE__).'/lib.php');
require_once($CFG->libdir.'/filelib.php');
@@ -217,7 +219,7 @@ function book_add_fake_block($chapters, $chapter, $book, $cm, $edit) {
function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
global $USER, $OUTPUT;
- $toc = ''; // Representation of toc (HTML)
+ $toc ='';
$nch = 0; // Chapter number
$ns = 0; // Subchapter number
$first = 1;
@@ -226,27 +228,35 @@ function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
switch ($book->numbering) {
case BOOK_NUM_NONE:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_none'));
break;
case BOOK_NUM_NUMBERS:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_numbered'));
break;
case BOOK_NUM_BULLETS:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_bullets'));
break;
case BOOK_NUM_INDENTED:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_indented'));
break;
}
if ($edit) { // Teacher's TOC
- $toc .= '
';
+ $toc .= html_writer::start_tag('ul');
$i = 0;
foreach ($chapters as $ch) {
$i++;
$title = trim(format_string($ch->title, true, array('context'=>$context)));
if (!$ch->subchapter) {
- $toc .= ($first) ? '- ' : '
';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::start_tag('li');
+ }
+
if (!$ch->hidden) {
$nch++;
$ns = 0;
@@ -257,10 +267,18 @@ function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
if ($book->numbering == BOOK_NUM_NUMBERS) {
$title = "x $title";
}
- $title = ''.$title.'';
+ $title = html_writer::tag('span', $title, array('class' => 'dimmed_text'));
}
} else {
- $toc .= ($first) ? '- ' : '
- ';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ $toc .= html_writer::start_tag('ul');
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::start_tag('li');
+ }
+
if (!$ch->hidden) {
$ns++;
if ($book->numbering == BOOK_NUM_NUMBERS) {
@@ -270,75 +288,109 @@ function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
if ($book->numbering == BOOK_NUM_NUMBERS) {
$title = "x.x $title";
}
- $title = ''.$title.'';
+ $title = html_writer::tag('span', $title, array('class' => 'dimmed_text'));
}
}
if ($ch->id == $chapter->id) {
- $toc .= ''.$title.'';
+ $toc .= html_writer::tag('strong', $title);
} else {
- $toc .= ''.$title.'';
+ $toc .= html_writer::link(new moodle_url('view.php', array('id' => $cm->id, 'chapterid' => $ch->id)), $title, array('title' => s($title)));
}
$toc .= ' ';
if ($i != 1) {
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('move.php', array('id' => $cm->id, 'chapterid' => $ch->id, 'up' => '1', 'sesskey' => $USER->sesskey)),
+ $OUTPUT->pix_icon('t/up', get_string('up')), array('title' => get_string('up')));
}
if ($i != count($chapters)) {
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('move.php', array('id' => $cm->id, 'chapterid' => $ch->id, 'up' => '0', 'sesskey' => $USER->sesskey)),
+ $OUTPUT->pix_icon('t/down', get_string('down')), array('title' => get_string('down')));
}
- $toc .= '
';
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('edit.php', array('cmid' => $cm->id, 'id' => $ch->id)),
+ $OUTPUT->pix_icon('t/edit', get_string('edit')), array('title' => get_string('edit')));
+ $toc .= html_writer::link(new moodle_url('delete.php', array('id' => $cm->id, 'chapterid' => $ch->id, 'sesskey' => $USER->sesskey)),
+ $OUTPUT->pix_icon('t/delete', get_string('delete')), array('title' => get_string('delete')));
if ($ch->hidden) {
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('show.php', array('id' => $cm->id, 'chapterid' => $ch->id, 'sesskey' => $USER->sesskey)),
+ $OUTPUT->pix_icon('t/show', get_string('show')), array('title' => get_string('show')));
} else {
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('show.php', array('id' => $cm->id, 'chapterid' => $ch->id, 'sesskey' => $USER->sesskey)),
+ $OUTPUT->pix_icon('t/hide', get_string('hide')), array('title' => get_string('hide')));
}
- $toc .= '
';
+ $toc .= html_writer::link(new moodle_url('edit.php', array('cmid' => $cm->id, 'pagenum' => $ch->pagenum, 'subchapter' => $ch->subchapter)),
+ $OUTPUT->pix_icon('add', get_string('addafter', 'mod_book'), 'mod_book'), array('title' => get_string('addafter', 'mod_book')));
- $toc .= (!$ch->subchapter) ? ' ';
+
+ if (!$ch->subchapter) {
+ $toc .= html_writer::start_tag('ul');
+ } else {
+ $toc .= html_writer::end_tag('li');
+ }
$first = 0;
}
- $toc .= '
';
+
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::end_tag('ul');
+
} else { // Normal students view
- $toc .= '
';
+ $toc .= html_writer::start_tag('ul');
foreach ($chapters as $ch) {
$title = trim(format_string($ch->title, true, array('context'=>$context)));
if (!$ch->hidden) {
if (!$ch->subchapter) {
$nch++;
$ns = 0;
- $toc .= ($first) ? '- ' : '
';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::start_tag('li');
+ }
+
if ($book->numbering == BOOK_NUM_NUMBERS) {
$title = "$nch $title";
}
} else {
$ns++;
- $toc .= ($first) ? '- ' : '
- ';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ $toc .= html_writer::start_tag('ul');
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::start_tag('li');
+ }
+
if ($book->numbering == BOOK_NUM_NUMBERS) {
$title = "$nch.$ns $title";
}
}
if ($ch->id == $chapter->id) {
- $toc .= ''.$title.'';
+ $toc .= html_writer::tag('strong', $title);
} else {
- $toc .= ''.$title.'';
+ $toc .= html_writer::link(new moodle_url('view.php', array('id' => $cm->id, 'chapterid' => $ch->id)), $title, array('title' => s($title)));
}
- $toc .= (!$ch->subchapter) ? '
';
+
+ if (!$ch->subchapter) {
+ $toc .= html_writer::start_tag('ul');
+ } else {
+ $toc .= html_writer::end_tag('li');
+ }
+
$first = 0;
}
}
- $toc .= '
';
+
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::end_tag('ul');
+
}
- $toc .= '
';
+ $toc .= html_writer::end_tag('div');
$toc = str_replace('
', '', $toc); // Cleanup of invalid structures.
diff --git a/mod/book/styles.css b/mod/book/styles.css
index 6ddaf09cf06..8bd9425ea9b 100644
--- a/mod/book/styles.css
+++ b/mod/book/styles.css
@@ -1,5 +1,5 @@
-.mod_book .book_chapter_title {
+.path-mod-book .book_chapter_title {
font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
text-align: left;
font-size: large;
@@ -9,7 +9,7 @@
margin-bottom: 20px;
}
-.mod_book img.bigicon {
+.path-mod-book img.bigicon {
vertical-align: middle;
margin-right: 4px;
margin-left: 4px;
@@ -18,7 +18,7 @@
border: 0px;
}
-.mod_book .navtop {
+.path-mod-book .navtop {
text-align: right;
margin-bottom: 0.5em;
}
diff --git a/mod/book/tool/exportimscp/index.php b/mod/book/tool/exportimscp/index.php
index 29d7b445c10..5e05581efc5 100644
--- a/mod/book/tool/exportimscp/index.php
+++ b/mod/book/tool/exportimscp/index.php
@@ -44,10 +44,6 @@ $context = context_module::instance($cm->id);
require_capability('mod/book:read', $context);
require_capability('booktool/exportimscp:export', $context);
-$strbooks = get_string('modulenameplural', 'book');
-$strbook = get_string('modulename', 'book');
-$strtop = get_string('top', 'book');
-
add_to_log($course->id, 'book', 'exportimscp', 'tool/exportimscp/index.php?id='.$cm->id, $book->id, $cm->id);
$file = booktool_exportimscp_build_package($book, $context);
diff --git a/mod/book/tool/exportimscp/lib.php b/mod/book/tool/exportimscp/lib.php
index d0f149c0495..620b524c611 100644
--- a/mod/book/tool/exportimscp/lib.php
+++ b/mod/book/tool/exportimscp/lib.php
@@ -31,11 +31,8 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function booktool_exportimscp_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
- global $USER, $PAGE, $CFG, $DB, $OUTPUT;
- if ($PAGE->cm->modname !== 'book') {
- return;
- }
+ global $PAGE;
if (has_capability('booktool/exportimscp:export', $PAGE->cm->context)) {
$url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id'=>$PAGE->cm->id));
diff --git a/mod/book/tool/importhtml/index.php b/mod/book/tool/importhtml/index.php
index 91a202c351a..eaae261f830 100644
--- a/mod/book/tool/importhtml/index.php
+++ b/mod/book/tool/importhtml/index.php
@@ -48,9 +48,8 @@ if ($chapterid) {
$chapter = false;
}
-$PAGE->set_title(format_string($book->name));
-$PAGE->add_body_class('mod_book');
-$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title($book->name);
+$PAGE->set_heading($course->fullname);
// Prepare the page header.
$strbook = get_string('modulename', 'mod_book');
diff --git a/mod/book/tool/importhtml/lib.php b/mod/book/tool/importhtml/lib.php
index 96cb709ee52..09d032f3e0c 100644
--- a/mod/book/tool/importhtml/lib.php
+++ b/mod/book/tool/importhtml/lib.php
@@ -31,11 +31,8 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function booktool_importhtml_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
- global $USER, $PAGE, $CFG, $DB, $OUTPUT;
- if ($PAGE->cm->modname !== 'book') {
- return;
- }
+ global $PAGE;
if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
$url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id'=>$PAGE->cm->id));
diff --git a/mod/book/tool/print/lib.php b/mod/book/tool/print/lib.php
index 427acc83e6c..f3b2f8cce8d 100644
--- a/mod/book/tool/print/lib.php
+++ b/mod/book/tool/print/lib.php
@@ -31,11 +31,8 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function booktool_print_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
- global $USER, $PAGE, $CFG, $DB, $OUTPUT;
- if ($PAGE->cm->modname !== 'book') {
- return;
- }
+ global $PAGE;
$params = $PAGE->url->params();
diff --git a/mod/book/tool/print/locallib.php b/mod/book/tool/print/locallib.php
index c86303983d4..200bee74867 100644
--- a/mod/book/tool/print/locallib.php
+++ b/mod/book/tool/print/locallib.php
@@ -45,43 +45,67 @@ function booktool_print_get_toc($chapters, $book, $cm) {
switch ($book->numbering) {
case BOOK_NUM_NONE:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_none'));
break;
case BOOK_NUM_NUMBERS:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_numbered'));
break;
case BOOK_NUM_BULLETS:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_bullets'));
break;
case BOOK_NUM_INDENTED:
- $toc .= '
';
+ $toc .= html_writer::start_tag('div', array('class' => 'book_toc_indented'));
break;
}
- $toc .= '
'; // Representation of toc (HTML).
+ $toc .= html_writer::tag('a', '', array('name' => 'toc')); // Representation of toc (HTML).
if ($book->customtitles) {
- $toc .= '
'.get_string('toc', 'mod_book').'
';
+ $toc .= html_writer::tag('h1', get_string('toc', 'mod_book'));
} else {
- $toc .= '
'.get_string('toc', 'mod_book').'
';
+ $toc .= html_writer::tag('p', get_string('toc', 'mod_book'), array('class' => 'book_chapter_title'));
}
- $toc .= '
';
+ $toc .= html_writer::start_tag('ul');
foreach ($chapters as $ch) {
if (!$ch->hidden) {
$title = book_get_chapter_title($ch->id, $chapters, $book, $context);
if (!$ch->subchapter) {
- $toc .= $first ? '- ' : '
';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::start_tag('li');
+ }
+
} else {
- $toc .= $first ? '- ' : '
- ';
+
+ if ($first) {
+ $toc .= html_writer::start_tag('li');
+ $toc .= html_writer::start_tag('ul');
+ $toc .= html_writer::start_tag('li');
+ } else {
+ $toc .= html_writer::start_tag('li');
+ }
+
}
$titles[$ch->id] = $title;
- $toc .= ''.$title.'';
- $toc .= (!$ch->subchapter) ? '
';
+ $toc .= html_writer::link(new moodle_url('#ch'.$ch->id), $title, array('title' => s($title)));
+ if (!$ch->subchapter) {
+ $toc .= html_writer::start_tag('ul');
+ } else {
+ $toc .= html_writer::end_tag('li');
+ }
$first = false;
}
}
- $toc .= '
';
- $toc .= '
';
+
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('li');
+ $toc .= html_writer::end_tag('ul');
+ $toc .= html_writer::end_tag('div');
+
$toc = str_replace('
', '', $toc); // Cleanup of invalid structures.
return array($toc, $titles);
diff --git a/mod/book/view.php b/mod/book/view.php
index f7adbbe98b1..26d5ac0b3d0 100644
--- a/mod/book/view.php
+++ b/mod/book/view.php
@@ -114,9 +114,8 @@ $strbook = get_string('modulename', 'mod_book');
$strtoc = get_string('toc', 'mod_book');
// prepare header
-$PAGE->set_title(format_string($book->name));
-$PAGE->add_body_class('mod_book');
-$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title($book->name);
+$PAGE->set_heading($course->fullname);
book_add_fake_block($chapters, $chapter, $book, $cm, $edit);