Commit 9d2fe179 authored by Petr Skoda's avatar Petr Skoda
Browse files

conversion

parent f19d9517
......@@ -40,16 +40,15 @@ require_sesskey();
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:edit', $context);
$PAGE->set_url('/mod/book/delete.php', array('id'=>$id, 'chapterid'=>$chapterid));
$chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
///header and strings
$strbooks = get_string('modulenameplural', 'book');
$strbook = get_string('modulename', 'book');
$navigation = build_navigation('', $cm);
print_header("$course->shortname: $book->name", $course->fullname, $navigation);
$PAGE->set_title(format_string($book->name));
$PAGE->add_body_class('mod_book');
$PAGE->set_heading(format_string($course->fullname));
///form processing
if ($confirm) { // the operation was confirmed.
......@@ -74,17 +73,19 @@ if ($confirm) { // the operation was confirmed.
book_check_structure($book->id);
redirect('view.php?id='.$cm->id);
}
echo $OUTPUT->header();
// the operation has not been confirmed yet so ask the user to do so
if ($chapter->subchapter) {
$strconfirm = get_string('confchapterdelete','book');
} else {
// the operation has not been confirmed yet so ask the user to do so
if ($chapter->subchapter) {
$strconfirm = get_string('confchapterdelete','book');
} else {
$strconfirm = get_string('confchapterdeleteall','book');
}
echo '<br />';
notice_yesno("<b>$chapter->title</b><p>$strconfirm</p>",
"delete.php?id=$cm->id&chapterid=$chapter->id&confirm=1&sesskey=$USER->sesskey",
"view.php?id=$cm->id&chapterid=$chapter->id");
$strconfirm = get_string('confchapterdeleteall','book');
}
echo '<br />';
$continue = new moodle_url('/mod/book/delete.php', array('id'=>$cm->id, 'chapterid'=>$chapter->id, 'confirm'=>1));
$cancel = new moodle_url('/mod/book/view.php', array('id'=>$cm->id, 'chapterid'=>$chapter->id));
echo $OUTPUT->confirm("<strong>$chapter->title</strong><p>$strconfirm</p>", $continue, $cancel);
print_footer($course);
echo $OUTPUT->footer();
......@@ -45,6 +45,8 @@ require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:edit', $context);
$PAGE->set_url('/mod/book/edit.php', array('cmid'=>$cmid, 'id'=>$chapterid, 'pagenum'=>$pagenum, 'subchapter'=>$subchapter));
if ($chapterid) {
$chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
} else {
......@@ -109,23 +111,14 @@ if ($mform->is_cancelled()) {
}
/// Otherwise fill and print the form.
$strbook = get_string('modulename', 'book');
$strbooks = get_string('modulenameplural', 'book');
$stredit = get_string('edit');
$pageheading = get_string('editingchapter', 'book');
///prepare the page header
$navlinks = array();
$navlinks[] = array('name' => $stredit, 'link' => '', 'type' => 'title');
$navigation = build_navigation($navlinks, $cm);
print_header("$course->shortname: $book->name", $course->fullname, $navigation);
$PAGE->set_title(format_string($book->name));
$PAGE->add_body_class('mod_book');
$PAGE->set_heading(format_string($course->fullname));
$icon = '<img class="icon" src="pix/chapter.gif" alt="" />&nbsp;';
print_heading_with_help($pageheading, 'edit', 'book', $icon);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('editingchapter', 'book'));
$mform->display();
print_footer($course);
echo $OUTPUT->footer();
......@@ -31,6 +31,8 @@ require_once($CFG->libdir.'/filelib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
die('Not converted to 2.0 yet, sorry');
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
......
......@@ -42,6 +42,8 @@ require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:import', $context);
$PAGE->set_url('/mod/book/import.php', array('id'=>$id));
//check all variables
unset($id);
......
......@@ -201,3 +201,43 @@ function book_supports($feature) {
default: return null;
}
}
/**
* Adds module specific settings to the settings block
*
* @param settings_navigation $settings The settings navigation object
* @param navigation_node $forumnode The node to add module settings to
* @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;
}
if (empty($PAGE->cm->context)) {
$PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
}
if (!has_capability('mod/book:edit', $PAGE->cm->context)) {
return;
}
$params = $PAGE->url->params();
if (empty($params['id']) or empty($params['chapterid'])) {
return;
}
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
$edit = '0';
} else {
$string = get_string("turneditingon");
$edit = '1';
}
$url = new moodle_url('/mod/book/view.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid'], 'edit'=>$edit, 'sesskey'=>sesskey()));
$booknode->add($string, $url, navigation_node::TYPE_SETTING);
}
\ No newline at end of file
......@@ -74,30 +74,6 @@ function book_check_structure($bookid) {
}
}
/// prepare button to turn chapter editing on - connected with course editing
function book_edit_button($book, $cm, $chapter) {
global $CFG, $USER;
if (has_capability('mod/book:edit', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
$edit = '0';
} else {
$string = get_string("turneditingon");
$edit = '1';
}
return '<form method="get" action="'.$CFG->wwwroot.'/mod/book/view.php"><div>'.
'<input type="hidden" name="id" value="'.$cm->id.'" />'.
'<input type="hidden" name="chapterid" value="'.$chapter->id.'" />'.
'<input type="hidden" name="edit" value="'.$edit.'" />'.
'<input type="submit" value="'.$string.'" /></div></form>';
} else {
return '';
}
}
/// general function for logging to table
function book_log($str1, $str2, $level = 0) {
switch ($level) {
......
......@@ -44,7 +44,7 @@ require_capability('mod/book:edit', $context);
$chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
$oldchapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum', 'id, pagenum, subchapter');
$oldchapters = $DB->get_records('book_chapters', array('bookid'=>$book->id), 'pagenum', 'id, pagenum, subchapter');
$nothing = 0;
......
......@@ -114,8 +114,7 @@ if ($chapter) {
} else {
add_to_log($course->id, 'book', 'print', 'print.php?id='.$cm->id, $book->id, $cm->id);
$site = get_record('course','id',1);
$chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum');
$chapters = $DB->get_records('book_chapters', array('bookid'=>$book->id), 'pagenum');
/// page header
?>
......@@ -134,7 +133,7 @@ if ($chapter) {
<div class="book_info"><table>
<tr>
<td><?PHP echo get_string('site') ?>:</td>
<td><a href="<?PHP echo $CFG->wwwroot ?>"><?PHP echo format_string($site->fullname) ?></a></td>
<td><a href="<?PHP echo $CFG->wwwroot ?>"><?PHP echo format_string($SITE->fullname) ?></a></td>
</tr><tr>
<td><?PHP echo get_string('course') ?>:</td>
<td><?PHP echo format_string($course->fullname) ?></td>
......
......@@ -39,6 +39,8 @@ require_sesskey();
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:edit', $context);
$PAGE->set_url('/mod/book/show.php', array('id'=>$id, 'chapterid'=>$chapterid));
$chapter = $DB->get_record('book_chapters', array('id'=>$chapterid, 'bookid'=>$book->id), '*', MUST_EXIST);
......
......@@ -148,19 +148,19 @@ if ($print) { ///TOC for printing
}
$toc .= '&nbsp;&nbsp;';
if ($i != 1) {
$toc .= ' <a title="'.get_string('up').'" href="move.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;up=1&amp;sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/up.gif" height="11" class="iconsmall" alt="'.get_string('up').'" /></a>';
$toc .= ' <a title="'.get_string('up').'" href="move.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;up=1&amp;sesskey='.$USER->sesskey.'"><img src="'.$OUTPUT->pix_url('t/up').'" height="11" class="iconsmall" alt="'.get_string('up').'" /></a>';
}
if ($i != count($chapters)) {
$toc .= ' <a title="'.get_string('down').'" href="move.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;up=0&amp;sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/down.gif" height="11" class="iconsmall" alt="'.get_string('down').'" /></a>';
$toc .= ' <a title="'.get_string('down').'" href="move.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;up=0&amp;sesskey='.$USER->sesskey.'"><img src="'.$OUTPUT->pix_url('t/down').'" height="11" class="iconsmall" alt="'.get_string('down').'" /></a>';
}
$toc .= ' <a title="'.get_string('edit').'" href="edit.php?cmid='.$cm->id.'&amp;id='.$ch->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" height="11" class="iconsmall" alt="'.get_string('edit').'" /></a>';
$toc .= ' <a title="'.get_string('delete').'" href="delete.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/delete.gif" height="11" class="iconsmall" alt="'.get_string('delete').'" /></a>';
$toc .= ' <a title="'.get_string('edit').'" href="edit.php?cmid='.$cm->id.'&amp;id='.$ch->id.'"><img src="'.$OUTPUT->pix_url('t/edit').'" height="11" class="iconsmall" alt="'.get_string('edit').'" /></a>';
$toc .= ' <a title="'.get_string('delete').'" href="delete.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$OUTPUT->pix_url('t/delete').'" height="11" class="iconsmall" alt="'.get_string('delete').'" /></a>';
if ($ch->hidden) {
$toc .= ' <a title="'.get_string('show').'" href="show.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/show.gif" height="11" class="iconsmall" alt="'.get_string('show').'" /></a>';
$toc .= ' <a title="'.get_string('show').'" href="show.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$OUTPUT->pix_url('t/show').'" height="11" class="iconsmall" alt="'.get_string('show').'" /></a>';
} else {
$toc .= ' <a title="'.get_string('hide').'" href="show.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/hide.gif" height="11" class="iconsmall" alt="'.get_string('hide').'" /></a>';
$toc .= ' <a title="'.get_string('hide').'" href="show.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'&amp;sesskey='.$USER->sesskey.'"><img src="'.$OUTPUT->pix_url('t/hide').'" height="11" class="iconsmall" alt="'.get_string('hide').'" /></a>';
}
$toc .= ' <a title="'.get_string('addafter', 'book').'" href="edit.php?cmid='.$cm->id.'&amp;pagenum='.$ch->pagenum.'&amp;subchapter='.$ch->subchapter.'"><img src="pix/add.gif" height="11" class="iconsmall" alt="'.get_string('addafter', 'book').'" /></a>';
$toc .= ' <a title="'.get_string('addafter', 'book').'" href="edit.php?cmid='.$cm->id.'&amp;pagenum='.$ch->pagenum.'&amp;subchapter='.$ch->subchapter.'"><img src="'.$OUTPUT->pix_url('add', 'mod_book').'" height="11" class="iconsmall" alt="'.get_string('addafter', 'book').'" /></a>';
$toc .= (!$ch->subchapter) ? '<ul>' : '</li>';
$first = 0;
......
......@@ -48,10 +48,10 @@ $allowprint = has_capability('mod/book:print', $context) and !$book->disablepri
$allowexport = has_capability('mod/book:exportimscp', $context);
$viewhidden = has_capability('mod/book:viewhiddenchapters', $context);
$PAGE->set_url('/mod/book/view.php', array('id'=>$id, 'chpterid'=>'chapterid'));
$PAGE->set_url('/mod/book/view.php', array('id'=>$id, 'chapterid'=>$chapterid));
if ($allowedit) {
if ($edit != -1) {
if ($edit != -1 and confirm_sesskey()) {
$USER->editing = $edit;
} else {
if (isset($USER->editing)) {
......@@ -117,20 +117,10 @@ $strbook = get_string('modulename', 'book');
$strtoc = get_string('toc', 'book');
/// prepare header
$navigation = build_navigation('', $cm);
$buttons = $allowedit ? book_edit_button($book, $cm, $chapter) : '&nbsp;';
print_header( "$course->shortname: $book->name ($chapter->title)",
$course->fullname,
$navigation,
'',
'',
true,
$buttons,
navmenu($course, $cm)
);
$PAGE->set_title(format_string($book->name));
$PAGE->add_body_class('mod_book');
$PAGE->set_heading(format_string($course->fullname));
echo $OUTPUT->header();
/// prepare chapter navigation icons
$previd = null;
......@@ -153,18 +143,18 @@ if ($ch == current($chapters)) {
}
$chnavigation = '';
if ($previd) {
$chnavigation .= '<a title="'.get_string('navprev', 'book').'" href="view.php?id='.$cm->id.'&amp;chapterid='.$previd.'"><img src="pix/nav_prev.gif" class="bigicon" alt="'.get_string('navprev', 'book').'"/></a>';
$chnavigation .= '<a title="'.get_string('navprev', 'book').'" href="view.php?id='.$cm->id.'&amp;chapterid='.$previd.'"><img src="'.$OUTPUT->pix_url('nav_prev', 'mod_book').'" class="bigicon" alt="'.get_string('navprev', 'book').'"/></a>';
} else {
$chnavigation .= '<img src="pix/nav_prev_dis.gif" class="bigicon" alt="" />';
}
if ($nextid) {
$chnavigation .= '<a title="'.get_string('navnext', 'book').'" href="view.php?id='.$cm->id.'&amp;chapterid='.$nextid.'"><img src="pix/nav_next.gif" class="bigicon" alt="'.get_string('navnext', 'book').'" /></a>';
$chnavigation .= '<a title="'.get_string('navnext', 'book').'" href="view.php?id='.$cm->id.'&amp;chapterid='.$nextid.'"><img src="'.$OUTPUT->pix_url('nav_next', 'mod_book').'" class="bigicon" alt="'.get_string('navnext', 'book').'" /></a>';
} else {
$sec = '';
if ($section = $DB->get_record('course_sections', array('id'=>$cm->section))) {
$sec = $section->section;
}
$chnavigation .= '<a title="'.get_string('navexit', 'book').'" href="../../course/view.php?id='.$course->id.'#section-'.$sec.'"><img src="pix/nav_exit.gif" class="bigicon" alt="'.get_string('navexit', 'book').'" /></a>';
$chnavigation .= '<a title="'.get_string('navexit', 'book').'" href="../../course/view.php?id='.$course->id.'#section-'.$sec.'"><img src="'.$OUTPUT->pix_url('nav_exit', 'mod_book').'" class="bigicon" alt="'.get_string('navexit', 'book').'" /></a>';
}
/// prepare print icons
......@@ -172,13 +162,13 @@ if (!$allowprint) {
$printbook = '';
$printchapter = '';
} else {
$printbook = '<a title="'.get_string('printbook', 'book').'" href="print.php?id='.$cm->id.'" onclick="this.target=\'_blank\'"><img src="pix/print_book.gif" class="bigicon" alt="'.get_string('printbook', 'book').'"/></a>';
$printchapter = '<a title="'.get_string('printchapter', 'book').'" href="print.php?id='.$cm->id.'&amp;chapterid='.$chapter->id.'" onclick="this.target=\'_blank\'"><img src="pix/print_chapter.gif" class="bigicon" alt="'.get_string('printchapter', 'book').'"/></a>';
$printbook = '<a title="'.get_string('printbook', 'book').'" href="print.php?id='.$cm->id.'" onclick="this.target=\'_blank\'"><img src="'.$OUTPUT->pix_url('print_book', 'mod_book').'" class="bigicon" alt="'.get_string('printbook', 'book').'"/></a>';
$printchapter = '<a title="'.get_string('printchapter', 'book').'" href="print.php?id='.$cm->id.'&amp;chapterid='.$chapter->id.'" onclick="this.target=\'_blank\'"><img src="'.$OUTPUT->pix_url('print_chapter', 'mod_book').'" class="bigicon" alt="'.get_string('printchapter', 'book').'"/></a>';
}
// prepare $toc and $currtitle, $currsubtitle
$print = 0;
require('toc.php');
include('toc.php');
if ($edit) {
$tocwidth = $CFG->book_tocwidth + 80;
......@@ -189,7 +179,8 @@ if ($edit) {
$doimport = ($allowimport and $edit) ? '<div>(<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</div>' : '';
/// Enable the IMS CP button
$generateimscp = ($allowexport) ? '<a title="'.get_string('generateimscp', 'book').'" href="generateimscp.php?id='.$cm->id.'"><img class="bigicon" src="pix/generateimscp.gif" alt="'.get_string('generateimscp', 'book').'"></img></a>' : '';
//$generateimscp = ($allowexport) ? '<a title="'.get_string('generateimscp', 'book').'" href="generateimscp.php?id='.$cm->id.'"><img class="bigicon" src="'.$OUTPUT->pix_url('generateimscp', 'mod_book').'" alt="'.get_string('generateimscp', 'book').'"></img></a>' : '';
$generateimscp = ''; //TODO after new file handling
// =====================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment