book should be now compatible with 1.8

This commit is contained in:
Petr Skoda 2007-05-20 06:00:26 +00:00
parent c54440410b
commit dab784a34e
16 changed files with 437 additions and 433 deletions

View File

@ -1,4 +1,4 @@
$Id: README.txt,v 1.2 2006/04/24 19:41:14 skodak Exp $
$Id: README.txt,v 1.3 2007/05/20 06:00:29 skodak Exp $
///////////////////////////////////////////////////////////////////////////
// //
@ -110,5 +110,9 @@ CHANGELOG:
* all languages converted to utf-8
* moved to contrib/book_16 directory
* added proper content encoding conversion during import
== 1.4alpha - 2007/05/20 ====================================================
* compatible with 1.8
* export link enabled - thanks Eloy!
* no new features
skodak

View File

@ -1,4 +1,4 @@
/* $Id: book_theme.css,v 1.1 2006/03/12 18:39:59 skodak Exp $*/
/* $Id: book_theme.css,v 1.2 2007/05/20 06:00:30 skodak Exp $*/
/* later should be defined in themes*/
@ -16,6 +16,15 @@
text-align: left;
}
img.bigicon {
vertical-align:middle;
margin-right:4px;
margin-left:4px;
width:24px;
height:24px;
border:0px;
}
/* == TOC styles == */
/* toc style NONE */

View File

@ -1,4 +1,4 @@
<?php // $Id: coursefiles.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?php // $Id: coursefiles.php,v 1.2 2007/05/20 06:00:26 skodak Exp $
// Manage all uploaded files in a course file area
@ -9,6 +9,7 @@
require('../../config.php');
require($CFG->libdir.'/filelib.php');
require($CFG->libdir.'/adminlib.php');
$id = required_param('id', PARAM_INT);
$file = optional_param('file', '', PARAM_PATH);
@ -16,10 +17,14 @@
$action = optional_param('action', '', PARAM_ACTION);
$name = optional_param('name', '', PARAM_FILE);
$oldname = optional_param('oldname', '', PARAM_FILE);
$choose = required_param('choose', PARAM_CLEAN);
$choose = optional_param('choose', '', PARAM_FILE); //in fact it is always 'formname.inputname'
$userfile= optional_param('userfile','',PARAM_FILE);
$save = optional_param('save', 0, PARAM_BOOL);
$text = optional_param('text', '', PARAM_RAW);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if ($choose) {
if (count(explode('.', $choose)) != 2) {
if (count(explode('.', $choose)) > 2) {
error('Incorrect format for choose parameter');
}
}
@ -29,32 +34,26 @@
error("That's an invalid course id");
}
require_login($course->id);
require_login($course);
if (! isteacheredit($course->id) ) {
error("You need to be a teacher with editing privileges");
}
require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id));
function html_footer() {
global $course, $choose, $adminroot;
global $course, $choose;
echo '</td></tr></table>';
if ($choose) {
echo "</td></tr></table></body></html>";
if ($course->id == SITEID) {
admin_externalpage_print_footer($adminroot);
} else {
echo "</td></tr></table></body></html>";
print_footer($course);
}
}
function html_header($course, $wdir, $formfield=""){
global $CFG, $ME, $choose;
if (! $site = get_site()) {
error("Invalid site!");
}
if ($course->id == $site->id) {
if ($course->id == SITEID) {
$strfiles = get_string("sitefiles");
} else {
$strfiles = get_string("files");
@ -80,43 +79,65 @@
print_header();
$chooseparts = explode('.', $choose);
if (count($chooseparts)==2){
?>
<script language="javascript" type="text/javascript">
<!--
<script type="text/javascript">
//<![CDATA[
function set_value(txt) {
opener.document.forms['<?php echo $chooseparts[0]."'].".$chooseparts[1] ?>.value = txt;
window.close();
}
-->
//]]>
</script>
<?php
$fullnav = str_replace('->', '&raquo;', "$course->shortname -> $fullnav");
} elseif (count($chooseparts)==1){
?>
<script type="text/javascript">
//<![CDATA[
function set_value(txt) {
opener.document.getElementById('<?php echo $chooseparts[0] ?>').value = txt;
window.close();
}
//]]>
</script>
<?php
}
$fullnav = str_replace('->', '&raquo;', format_string($course->shortname) . " -> $fullnav");
echo '<div id="nav-bar">'.$fullnav.'</div>';
if ($course->id == $site->id) {
if ($course->id == SITEID and $wdir != "/backupdata") {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
} else {
if ($course->id == $site->id) {
print_header("$course->shortname: $strfiles", "$course->fullname",
"<a href=\"../$CFG->admin/index.php\">".get_string("administration").
"</a> -> $fullnav", $formfield);
if ($course->id == SITEID) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
if ($wdir == "/backupdata") {
$adminroot = admin_get_root();
admin_externalpage_setup('frontpagerestore', $adminroot);
admin_externalpage_print_header($adminroot);
} else {
$adminroot = admin_get_root();
admin_externalpage_setup('sitefiles', $adminroot);
admin_externalpage_print_header($adminroot);
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
} else {
print_header("$course->shortname: $strfiles", "$course->fullname",
print_header("$course->shortname: $strfiles", $course->fullname,
"<a href=\"../course/view.php?id=$course->id\">$course->shortname".
"</a> -> $fullnav", $formfield);
}
}
echo "<table border=\"0\" align=\"center\" cellspacing=\"3\" cellpadding=\"3\" width=\"640\">";
echo "<table border=\"0\" style=\"margin-left:auto;margin-right:auto\" cellspacing=\"3\" cellpadding=\"3\" width=\"640\">";
echo "<tr>";
echo "<td colspan=\"2\">";
@ -132,15 +153,12 @@
// End of configuration and access control
if (!$wdir) {
$wdir="/";
if ($wdir == '') {
$wdir = "/";
}
if (($wdir != '/' and detect_munged_arguments($wdir, 0))
or ($file != '' and detect_munged_arguments($file, 0))) {
$message = "Error: Directories can not contain \"..\"";
$wdir = "/";
$action = "";
if ($wdir{0} != '/') { //make sure $wdir starts with slash
$wdir = "/".$wdir;
}
if ($wdir == "/backupdata") {
@ -149,13 +167,18 @@
}
}
if (!is_dir($basedir.$wdir)) {
html_header($course, $wdir);
error("Requested directory does not exist.", "$CFG->wwwroot/files/index.php?id=$id");
}
switch ($action) {
case "upload":
html_header($course, $wdir);
require_once($CFG->dirroot.'/lib/uploadlib.php');
if (!empty($save) and confirm_sesskey()) {
if ($save and confirm_sesskey()) {
$course->maxbytes = 0; // We are ignoring course limits
$um = new upload_manager('userfile',false,false,$course,false,0);
$dir = "$basedir$wdir";
@ -173,38 +196,42 @@
$strmaxsize = get_string("maxsize", "", $filesize);
$strcancel = get_string("cancel");
echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b>";
echo "<table><tr><td colspan=\"2\">";
echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b></p>";
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"coursefiles.php\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo "<table><tr><td colspan=\"2\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />";
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
upload_print_form_fragment(1,array('userfile'),null,false,null,$upload_max_filesize,0,false);
echo " </td><tr><td width=\"10\">";
echo " </td></tr></table>";
echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />";
echo "</div>";
echo "</form>";
echo "</td><td width=\"100%\">";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"$strcancel\" />";
echo "</div>";
echo "</form>";
echo "</td></tr></table>";
}
html_footer();
break;
case "delete":
if (!empty($confirm) and confirm_sesskey()) {
if ($confirm and confirm_sesskey()) {
html_header($course, $wdir);
foreach ($USER->filelist as $file) {
$fullfile = $basedir.$file;
if (! fulldelete($fullfile)) {
echo "<br />Error: Could not delete: $fullfile";
if (!empty($USER->filelist)) {
foreach ($USER->filelist as $file) {
$fullfile = $basedir.'/'.$file;
if (! fulldelete($fullfile)) {
echo "<br />Error: Could not delete: $fullfile";
}
}
}
clearfilelist();
@ -213,15 +240,27 @@
} else {
html_header($course, $wdir);
if (setfilelist($_POST)) {
echo "<p align=\"center\">".get_string("deletecheckwarning").":</p>";
notify(get_string('deletecheckwarning').':');
print_simple_box_start("center");
printfilelist($USER->filelist);
print_simple_box_end();
echo "<br />";
notice_yesno (get_string("deletecheckfiles"),
"coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=delete&amp;confirm=1&amp;sesskey=$USER->sesskey&amp;choose=$choose",
"coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=cancel&amp;choose=$choose");
require_once($CFG->dirroot.'/mod/resource/lib.php');
$block = resource_delete_warning($course, $USER->filelist);
if (empty($CFG->resource_blockdeletingfile) or $block == '') {
$optionsyes = array('id'=>$id, 'wdir'=>$wdir, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'choose'=>$choose);
$optionsno = array('id'=>$id, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose);
notice_yesno (get_string('deletecheckfiles'), 'coursefiles.php', 'coursefiles.php', $optionsyes, $optionsno, 'post', 'get');
} else {
notify(get_string('warningblockingdelete', 'resource'));
$options = array('id'=>$id, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose);
print_continue("coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=cancel&amp;choose=$choose");
}
} else {
displaydir($wdir);
}
@ -234,7 +273,7 @@
if (($count = setfilelist($_POST)) and confirm_sesskey()) {
$USER->fileop = $action;
$USER->filesource = $wdir;
echo "<p align=\"center\">";
echo "<p class=\"centerpara\">";
print_string("selectednowmove", "moodle", $count);
echo "</p>";
}
@ -247,10 +286,10 @@
if (isset($USER->fileop) and ($USER->fileop == "move") and confirm_sesskey()) {
foreach ($USER->filelist as $file) {
$shortfile = basename($file);
$oldfile = $basedir.$file;
$oldfile = $basedir.'/'.$file;
$newfile = $basedir.$wdir."/".$shortfile;
if (!rename($oldfile, $newfile)) {
echo "<p>Error: $shortfile not moved";
echo "<p>Error: $shortfile not moved</p>";
}
}
}
@ -260,25 +299,30 @@
break;
case "rename":
if (!empty($name) and confirm_sesskey()) {
if (($name != '') and confirm_sesskey()) {
html_header($course, $wdir);
$name = clean_filename($name);
if (file_exists($basedir.$wdir."/".$name)) {
echo "Error: $name already exists!";
echo "<center>Error: $name already exists!</center>";
} else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) {
echo "Error: could not rename $oldname to $name";
echo "<p align=\"center\">Error: could not rename $oldname to $name</p>";
} else {
//file was renamed now update resources if needed
require_once($CFG->dirroot.'/mod/resource/lib.php');
resource_renamefiles($course, $wdir, $oldname, $name);
}
displaydir($wdir);
} else {
$strrename = get_string("rename");
$strcancel = get_string("cancel");
$strrenamefileto = get_string("renamefileto", "moodle", $file);
html_header($course, $wdir, "form.name");
echo "<p>$strrenamefileto:";
echo "<p>$strrenamefileto:</p>";
echo "<table><tr><td>";
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<form action=\"coursefiles.php\" method=\"post\">";
echo "<fieldset class=\"invisiblefieldset\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />";
@ -286,54 +330,61 @@
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />";
echo " <input type=\"submit\" value=\"$strrename\" />";
echo "</fieldset>";
echo "</form>";
echo "</td><td>";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"$strcancel\" />";
echo "</div>";
echo "</form>";
echo "</td></tr></table>";
}
html_footer();
break;
case "mkdir":
if (!empty($name) and confirm_sesskey()) {
case "makedir":
if (($name != '') and confirm_sesskey()) {
html_header($course, $wdir);
$name = clean_filename($name);
if (file_exists("$basedir$wdir/$name")) {
echo "Error: $name already exists!";
} else if (! make_upload_directory("$course->id/$wdir/$name")) {
} else if (! make_upload_directory("$course->id$wdir/$name")) {
echo "Error: could not create $name";
}
displaydir($wdir);
} else {
$strcreate = get_string("create");
$strcancel = get_string("cancel");
$strcreatefolder = get_string("createfolder", "moodle", $wdir);
html_header($course, $wdir, "form.name");
echo "<p>$strcreatefolder:";
echo "<p>$strcreatefolder:</p>";
echo "<table><tr><td>";
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<form action=\"coursefiles.php\" method=\"post\">";
echo "<fieldset class=\"invisiblefieldset\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />";
echo " <input type=\"text\" name=\"name\" size=\"35\" />";
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
echo " <input type=\"submit\" value=\"$strcreate\" />";
echo "</fieldset>";
echo "</form>";
echo "</td><td>";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"$strcancel\" />";
echo "</div>";
echo "</form>";
echo "</td></tr></table>";
}
@ -342,16 +393,17 @@
case "edit":
html_header($course, $wdir);
if (isset($text) and confirm_sesskey()) {
$fileptr = fopen($basedir.$file,"w");
if (($text != '') and confirm_sesskey()) {
$fileptr = fopen($basedir.'/'.$file,"w");
$text = preg_replace('/\x0D/', '', $text); // http://moodle.org/mod/forum/discuss.php?d=38860
fputs($fileptr, stripslashes($text));
fclose($fileptr);
displaydir($wdir);
} else {
$streditfile = get_string("edit", "", "<b>$file</b>");
$fileptr = fopen($basedir.$file, "r");
$contents = fread($fileptr, filesize($basedir.$file));
$fileptr = fopen($basedir.'/'.$file, "r");
$contents = fread($fileptr, filesize($basedir.'/'.$file));
fclose($fileptr);
if (mimeinfo("type", $file) == "text/html") {
@ -364,8 +416,9 @@
print_heading("$streditfile");
echo "<table><tr><td colspan=\"2\">";
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<form action=\"coursefiles.php\" method=\"post\">";
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"file\" value=\"$file\" />";
@ -374,18 +427,21 @@
print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents);
echo "</td></tr><tr><td>";
echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />";
echo "</div>";
echo "</form>";
echo "</td><td>";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />";
echo "</div>";
echo "</form>";
echo "</td></tr></table>";
if ($usehtmleditor) {
if ($usehtmleditor) {
use_html_editor();
}
@ -395,7 +451,7 @@
break;
case "zip":
if (!empty($name) and confirm_sesskey()) {
if (($name != '') and confirm_sesskey()) {
html_header($course, $wdir);
$name = clean_filename($name);
@ -404,13 +460,13 @@
$files[] = "$basedir/$file";
}
if (!zip_files($files,"$basedir/$wdir/$name")) {
if (!zip_files($files,"$basedir$wdir/$name")) {
error(get_string("zipfileserror","error"));
}
clearfilelist();
displaydir($wdir);
} else {
html_header($course, $wdir, "form.name");
@ -420,24 +476,28 @@
printfilelist($USER->filelist);
print_simple_box_end();
echo "<br />";
echo "<p align=\"center\">".get_string("whattocallzip");
echo "<p align=\"center\">".get_string("whattocallzip")."</p>";
echo "<table><tr><td>";
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<form action=\"coursefiles.php\" method=\"post\">";
echo "<fieldset class=\"invisiblefieldset\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />";
echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />";
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />";
echo "<fieldset>";
echo "</form>";
echo "</td><td>";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />";
echo "</div>";
echo "</form>";
echo "</td></tr></table>";
} else {
@ -450,7 +510,7 @@
case "unzip":
html_header($course, $wdir);
if (!empty($file) and confirm_sesskey()) {
if (($file != '') and confirm_sesskey()) {
$strok = get_string("ok");
$strunpacking = get_string("unpacking", "", $file);
@ -458,18 +518,20 @@
$file = basename($file);
if (!unzip_file("$basedir/$wdir/$file")) {
if (!unzip_file("$basedir$wdir/$file")) {
error(get_string("unzipfileserror","error"));
}
echo "<center><form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div style=\"text-align:center\"><form action=\"coursefiles.php\" method=\"get\">";
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"$strok\" />";
echo "</div>";
echo "</form>";
echo "</center>";
echo "</div>";
} else {
displaydir($wdir);
}
@ -478,7 +540,7 @@
case "listzip":
html_header($course, $wdir);
if (!empty($file) and confirm_sesskey()) {
if (($file != '') and confirm_sesskey()) {
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
@ -489,16 +551,16 @@
$file = basename($file);
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
$archive = new PclZip(cleardoubleslashes("$basedir/$wdir/$file"));
if (!$list = $archive->listContent(cleardoubleslashes("$basedir/$wdir"))) {
$archive = new PclZip(cleardoubleslashes("$basedir$wdir/$file"));
if (!$list = $archive->listContent(cleardoubleslashes("$basedir$wdir"))) {
notify($archive->errorInfo(true));
} else {
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\" class=\"files\">";
echo "<tr class=\"file\"><th align=\"left\" class=\"header name\">$strname</th><th align=\"right\" class=\"header size\">$strsize</th><th align=\"right\" class=\"header date\">$strmodified</th></tr>";
echo "<tr class=\"file\"><th align=\"left\" class=\"header name\" scope=\"col\">$strname</th><th align=\"right\" class=\"header size\" scope=\"col\">$strsize</th><th align=\"right\" class=\"header date\" scope=\"col\">$strmodified</th></tr>";
foreach ($list as $item) {
echo "<tr>";
print_cell("left", $item['filename'], 'name');
print_cell("left", s($item['filename']), 'name');
if (! $item['folder']) {
print_cell("right", display_size($item['size']), 'size');
} else {
@ -511,11 +573,13 @@
echo "</table>";
}
echo "<br /><center><form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
echo " <input type=\"submit\" value=\"$strok\" />";
echo "</div>";
echo "</form>";
echo "</center>";
} else {
@ -526,7 +590,7 @@
case "restore":
html_header($course, $wdir);
if (!empty($file) and confirm_sesskey()) {
if (($file != '') and confirm_sesskey()) {
echo "<p align=\"center\">".get_string("youaregoingtorestorefrom").":</p>";
print_simple_box_start("center");
echo $file;
@ -535,14 +599,14 @@
echo "<p align=\"center\">".get_string("areyousuretorestorethisinfo")."</p>";
$restore_path = "$CFG->wwwroot/backup/restore.php";
notice_yesno (get_string("areyousuretorestorethis"),
$restore_path."?id=".$id."&amp;file=".cleardoubleslashes($id.$wdir."/".$file),
$restore_path."?id=".$id."&amp;file=".cleardoubleslashes($id.$wdir."/".$file)."&amp;method=manual",
"coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=cancel");
} else {
displaydir($wdir);
}
html_footer();
break;
case "cancel":
clearfilelist();
@ -568,9 +632,7 @@ function setfilelist($VARS) {
if (substr($key,0,4) == "file") {
$count++;
$val = rawurldecode($val);
if (!detect_munged_arguments($val, 0)) {
$USER->filelist[] = $val;
}
$USER->filelist[] = clean_param($val, PARAM_PATH);
}
}
return $count;
@ -587,11 +649,14 @@ function clearfilelist() {
function printfilelist($filelist) {
global $CFG, $basedir;
$strfolder = get_string("folder");
$strfile = get_string("file");
foreach ($filelist as $file) {
if (is_dir($basedir.$file)) {
echo "<img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
if (is_dir($basedir.'/'.$file)) {
echo "<img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" /> $file<br />";
$subfilelist = array();
$currdir = opendir($basedir.$file);
$currdir = opendir($basedir.'/'.$file);
while (false !== ($subfile = readdir($currdir))) {
if ($subfile <> ".." && $subfile <> ".") {
$subfilelist[] = $file."/".$subfile;
@ -599,9 +664,9 @@ function printfilelist($filelist) {
}
printfilelist($subfilelist);
} else {
} else {
$icon = mimeinfo("icon", $file);
echo "<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
echo "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> $file<br />";
}
}
}
@ -611,7 +676,7 @@ function print_cell($alignment='center', $text='&nbsp;', $class='') {
if ($class) {
$class = ' class="'.$class.'"';
}
echo '<td align="'.$alignment.'" nowrap="nowrap"'.$class.'>'.$text.'</td>';
echo '<td align="'.$alignment.'" style="white-space:nowrap "'.$class.'>'.$text.'</td>';
}
function displaydir ($wdir) {
@ -623,13 +688,14 @@ function displaydir ($wdir) {
global $choose;
$fullpath = $basedir.$wdir;
$dirlist = array();
$directory = opendir($fullpath); // Find all files
while (false !== ($file = readdir($directory))) {
if ($file == "." || $file == "..") {
continue;
}
if (is_dir($fullpath."/".$file)) {
$dirlist[] = $file;
} else {
@ -644,6 +710,8 @@ function displaydir ($wdir) {
$straction = get_string("action");
$strmakeafolder = get_string("makeafolder");
$struploadafile = get_string("uploadafile");
$strselectall = get_string("selectall");
$strselectnone = get_string("deselectall");
$strwithchosenfiles = get_string("withchosenfiles");
$strmovetoanotherfolder = get_string("movetoanotherfolder");
$strmovefilestohere = get_string("movefilestohere");
@ -654,25 +722,26 @@ function displaydir ($wdir) {
$strunzip = get_string("unzip");
$strlist = get_string("list");
$strrestore= get_string("restore");
$strchoose = get_string("choose");
$strchoose = get_string("choose");
$strfolder = get_string("folder");
$strfile = get_string("file");
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"dirform\">";
echo '<input type="hidden" name="choose" value="'.$choose.'">';
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">";
echo "<form action=\"coursefiles.php\" method=\"post\" id=\"dirform\">";
echo "<div>";
echo '<input type="hidden" name="choose" value="'.$choose.'" />';
// echo "<hr align=\"center\" noshade=\"noshade\" size=\"1\" />";
echo "<hr/>";
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">";
echo "<tr>";
echo "<th width=\"5\"></th>";
echo "<th align=\"left\" class=\"header name\">$strname</th>";
echo "<th align=\"right\" class=\"header size\">$strsize</th>";
echo "<th align=\"right\" class=\"header date\">$strmodified</th>";
echo "<th align=\"right\" class=\"header commands\">$straction</th>";
echo "<th scope=\"col\"></th>";
echo "<th class=\"header name\" scope=\"col\">$strname</th>";
echo "<th class=\"header size\" scope=\"col\">$strsize</th>";
echo "<th class=\"header date\" scope=\"col\">$strmodified</th>";
echo "<th class=\"header commands\" scope=\"col\">$straction</th>";
echo "</tr>\n";
if ($wdir == "/") {
$wdir = "";
}
if (!empty($wdir)) {
if ($wdir != "/") {
$dirlist[] = '..';
}
@ -683,17 +752,11 @@ function displaydir ($wdir) {
foreach ($dirlist as $dir) {
echo "<tr class=\"folder\">";
$dirurl = "$wdir/$dir";
if (substr($dirurl,0,1) == '/') {
$selectdir = substr($dirurl,1);
} else {
$selectdir = $dirurl;
}
if ($dir == '..') {
$fileurl = rawurlencode(dirname($wdir));
print_cell();
print_cell('left', '<a href="coursefiles.php?id='.$id.'&amp;wdir='.$fileurl.'&amp;choose='.$choose.'"><img src="'.$CFG->pixpath.'/f/parent.gif" height="16" width="16" alt="'.get_string('parentfolder').'" /></a> <a href="coursefiles.php?id='.$id.'&amp;wdir='.$fileurl.'&amp;choose='.$choose.'">'.get_string('parentfolder').'</a>', 'name');
// alt attribute intentionally empty to prevent repetition in screen reader
print_cell('left', '<a href="coursefiles.php?id='.$id.'&amp;wdir='.$fileurl.'&amp;choose='.$choose.'"><img src="'.$CFG->pixpath.'/f/parent.gif" class="icon" alt="" />&nbsp;'.get_string('parentfolder').'</a>', 'name');
print_cell();
print_cell();
print_cell();
@ -705,18 +768,19 @@ function displaydir ($wdir) {
$filesafe = rawurlencode($dir);
$filesize = display_size(get_directory_size("$fullpath/$dir"));
$filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
$selectfile = trim($wdir."/".$dir, "/");
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox');
print_cell("left", "<a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl&amp;choose=$choose\"><img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"Folder\" /></a> <a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl&amp;choose=$choose\">".htmlspecialchars($dir)."</a>", 'name');
print_cell("left", "<a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl&amp;choose=$choose\"><img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" />&nbsp;".htmlspecialchars($dir)."</a>", 'name');
print_cell("right", $filesize, 'size');
print_cell("right", $filedate, 'date');
if ($choose) {
$edittext = "<b><a onMouseDown=\"return set_value('$selectdir')\" href=\"\">$strchoose</a></b>&nbsp;";
} else {
$edittext = '';
}
$edittext = "<b><a onclick=\"return set_value('$selectfile')\" href=\"\">$strchoose</a></b>&nbsp;";
} else {
$edittext = '';
}
print_cell("right", "$edittext <a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$filesafe&amp;action=rename&amp;choose=$choose\">$strrename</a>", 'commands');
}
echo "</tr>";
}
}
@ -730,32 +794,24 @@ function displaydir ($wdir) {
$count++;
$filename = $fullpath."/".$file;
$fileurl = "$wdir/$file";
$fileurl = trim($wdir, "/")."/$file";
$filesafe = rawurlencode($file);
$fileurlsafe = rawurlencode($fileurl);
$filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
if (substr($fileurl,0,1) == '/') {
$selectfile = substr($fileurl,1);
} else {
$selectfile = $fileurl;
}
$selectfile = trim($fileurl, "/");
echo "<tr class=\"file\">";
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox');
echo "<td align=\"left\" nowrap=\"nowrap\" class=\"name\">";
echo "<td align=\"left\" style=\"white-space:nowrap\" class=\"name\">";
if ($CFG->slasharguments) {
$ffurl = "/file.php/$id$fileurl";
$ffurl = str_replace('//', '/', "/file.php/$id/$fileurl");
} else {
$ffurl = "/file.php?file=/$id$fileurl";
$ffurl = str_replace('//', '/', "/file.php?file=/$id/$fileurl");
}
link_to_popup_window ($ffurl, "display",
"<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" border=\"0\" alt=\"File\" />",
480, 640);
echo '&nbsp;';
link_to_popup_window ($ffurl, "display",
htmlspecialchars($file),
link_to_popup_window ($ffurl, "display",
"<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" />&nbsp;".htmlspecialchars($file),
480, 640);
echo "</td>";
@ -763,8 +819,8 @@ function displaydir ($wdir) {
print_cell("right", display_size($file_size), 'size');
print_cell("right", $filedate, 'date');
if ($choose && $icon == "html.gif") {
$edittext = "<b><a onMouseDown=\"return set_value('$selectfile')\" href=\"\">$strchoose</a></b>&nbsp;";
if ($choose) {
$edittext = "<strong><a onclick=\"return set_value('$selectfile')\" href=\"#\">$strchoose</a></strong>&nbsp;";
} else {
$edittext = '';
}
@ -775,24 +831,24 @@ function displaydir ($wdir) {
} else if ($icon == "zip.gif") {
$edittext .= "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=unzip&amp;sesskey=$USER->sesskey&amp;choose=$choose\">$strunzip</a>&nbsp;";
$edittext .= "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=listzip&amp;sesskey=$USER->sesskey&amp;choose=$choose\">$strlist</a> ";
if (!empty($CFG->backup_version) and has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
$edittext .= "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$filesafe&amp;action=restore&amp;sesskey=$USER->sesskey&amp;choose=$choose\">$strrestore</a> ";
}
}
print_cell("right", "$edittext <a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$filesafe&amp;action=rename&amp;choose=$choose\">$strrename</a>", 'commands');
echo "</tr>";
}
}
echo "</table>";
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
echo "<hr />";
//echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
if (empty($wdir)) {
$wdir = "/";
}
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">";
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">";
echo "<tr><td>";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo '<input type="hidden" name="choose" value="'.$choose.'">';
echo '<input type="hidden" name="choose" value="'.$choose.'" />';
echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" /> ";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
$options = array (
@ -801,41 +857,59 @@ function displaydir ($wdir) {
"zip" => "$strcreateziparchive"
);
if (!empty($count)) {
choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()");
choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:getElementById('dirform').submit()");
}
echo "</td></tr></table>";
echo "</div>";
echo "</form>";
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\"><tr>";
echo "<td align=\"center\">";
if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />";
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
echo " <input type=\"submit\" value=\"$strmovefilestohere\" />";
echo "</div>";
echo "</form>";
}
echo "</td>";
echo "<td align=\"right\">";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />";
echo " <input type=\"submit\" value=\"$strmakeafolder\" />";
echo "</div>";
echo "</form>";
echo "</td>";
echo "<td align=\"right\">";
echo "<form action=\"coursefiles.php\" method=\"get\">"; //dummy form - alignment only
echo "<fieldset class=\"invisiblefieldset\">";
echo " <input type=\"button\" value=\"$strselectall\" onclick=\"checkall();\" />";
echo " <input type=\"button\" value=\"$strselectnone\" onclick=\"uncheckall();\" />";
echo "</fieldset>";
echo "</form>";
echo "</td>";
echo "<td align=\"right\">";
echo "<form action=\"coursefiles.php\" method=\"get\">";
echo ' <input type="hidden" name="choose" value="'.$choose.'">';
echo "<div>";
echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />";
echo " <input type=\"submit\" value=\"$struploadafile\" />";
echo "</div>";
echo "</form>";
echo "</td></tr>";
echo "</table>";
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
echo "<hr/>";
//echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
}

View File

@ -1,4 +1,4 @@
<?PHP // $Id: edit.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?PHP // $Id: edit.php,v 1.2 2007/05/20 06:00:26 skodak Exp $
require_once('../../config.php');
require_once('lib.php');
@ -13,7 +13,7 @@ $subchapter = optional_param('subchapter', 0, PARAM_BOOL);
// =========================================================================
require_login();
if (!$cm = get_record('course_modules', 'id', $id)) {
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
@ -21,9 +21,8 @@ if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (!isteacheredit($course->id)) {
error('Only editing teachers can edit books!', $_SERVER['HTTP_REFERER']);
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('moodle/course:manageactivities', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');

View File

@ -1,4 +1,4 @@
<?PHP // $Id: generateimscp.php,v 1.1 2007/02/11 12:18:23 stronk7 Exp $
<?PHP // $Id: generateimscp.php,v 1.2 2007/05/20 06:00:26 skodak Exp $
///////////////////////////////////////////////////////////////////////////
// //
@ -29,13 +29,11 @@ require_once('lib.php');
require_once($CFG->dirroot . '/backup/lib.php');
require_once($CFG->dirroot . '/lib/filelib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
$id = required_param('id', PARAM_INT); // Course Module ID
if ($CFG->forcelogin) {
require_login();
}
require_login();
if (!$cm = get_record('course_modules', 'id', $id)) {
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
@ -43,22 +41,13 @@ if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if ($course->category) {
require_login($course->id);
}
if (!$cm->visible and !isteacher($course->id)) {
notice(get_string('activityiscurrentlyhidden'));
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('moodle/course:manageactivities', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
}
if (!isteacher($course->id)) {
error('Only teachers are allowed to generate IMS CP packages');
}
$strbooks = get_string('modulenameplural', 'book');
$strbook = get_string('modulename', 'book');
$strtop = get_string('top', 'book');
@ -220,6 +209,7 @@ function chapter2html($chapter, $courseid, $bookid) {
$content .= '</head>' . "\n";
$content .= '<body>' . "\n";
$content .= '<h1 id="header">' . $chapter->title . '</h1>' ."\n";
$options = new object();
$options->noclean = true;
$content .= format_text($chapter->content, '', $options, $courseid) . "\n";
$content .= '</body>' . "\n";
@ -255,7 +245,7 @@ function chapter2html($chapter, $courseid, $bookid) {
}
/// Build the final object needed to have all the info in order to create the manifest
$object = new stdClass;
$object = new object();
$object->content = $content;
$object->localfiles = $basefiles;

View File

@ -1,4 +1,4 @@
<?PHP // $Id: import.php,v 1.2 2006/11/21 19:26:36 skodak Exp $
<?PHP // $Id: import.php,v 1.3 2007/05/20 06:00:29 skodak Exp $
require_once('../../config.php');
require_once('lib.php');
@ -12,7 +12,7 @@ $cancel = optional_param('cancel', 0, PARAM_BOOL);
// =========================================================================
require_login();
if (!$cm = get_record('course_modules', 'id', $id)) {
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
@ -20,9 +20,8 @@ if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (!isteacheredit($course->id)) {
error('Only editing teachers can edit books!');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('moodle/course:manageactivities', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
@ -150,8 +149,8 @@ if (($form = data_submitted()) && (confirm_sesskey())) {
</td>
<td>
<?php
echo '<input name="reference" size="40" value="" />&nbsp;';
button_to_popup_window ('/mod/book/coursefiles.php?choose=theform.reference&id='.$course->id,
echo '<input id="id_reference" name="reference" size="40" value="" />&nbsp;';
button_to_popup_window ('/mod/book/coursefiles.php?choose=id_reference&id='.$course->id,
'coursefiles', $strchoose, 500, 750, $strchoose);
?>
</td>

View File

@ -1,4 +1,4 @@
<?PHP // $Id: index.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?PHP // $Id: index.php,v 1.2 2007/05/20 06:00:29 skodak Exp $
/// This page lists all the instances of book in a particular course
@ -10,17 +10,12 @@ $id = required_param('id', PARAM_INT); // Course Module ID
// =========================================================================
// security checks START - teachers and students view
// =========================================================================
if ($CFG->forcelogin) {
require_login();
}
if (!$course = get_record('course', 'id', $id)) {
error('Course ID is incorrect');
}
if ($course->category) {
require_login($course->id);
}
require_course_login($course, true);
//check all variables
unset($id);

View File

@ -1,4 +1,4 @@
<?PHP // $Id: book.php,v 1.1 2006/03/12 18:40:04 skodak Exp $
<?PHP // $Id: book.php,v 1.2 2007/05/20 06:00:30 skodak Exp $
$string['modulename'] = 'Book';
$string['modulenameplural'] = 'Books';
@ -40,6 +40,7 @@ $string['navexit'] = 'Exit Book';
$string['importingchapters'] = 'Importing chapters into book';
$string['import'] = 'Import';
$string['doimport'] = 'Import';
$string['doexport'] = 'Export';
$string['importing'] = 'Importing';
$string['relinking'] = 'Relinking';
$string['importinfo'] = 'Import selected HTML file or directory.<br />Chapters are sorted alphabetically using file names.<br />Files named \'sub_*.*\' are always imported as subchapters.';

42
lib.php
View File

@ -1,19 +1,21 @@
<?PHP // $Id: lib.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?PHP // $Id: lib.php,v 1.2 2007/05/20 06:00:30 skodak Exp $
define('NUM_NONE', '0');
define('NUM_NUMBERS', '1');
define('NUM_BULLETS', '2');
define('NUM_INDENTED', '3');
$NUMBERING_TYPE = array (NUM_NONE => get_string('numbering0', 'book'),
NUM_NUMBERS => get_string('numbering1', 'book'),
NUM_BULLETS => get_string('numbering2', 'book'),
NUM_INDENTED => get_string('numbering3', 'book') );
if (!isset($CFG->book_tocwidth)) {
set_config("book_tocwidth", 180); // default toc width
}
function book_get_numbering_types() {
return array (NUM_NONE => get_string('numbering0', 'book'),
NUM_NUMBERS => get_string('numbering1', 'book'),
NUM_BULLETS => get_string('numbering2', 'book'),
NUM_INDENTED => get_string('numbering3', 'book') );
}
/// Library of functions and constants for module 'book'
@ -25,6 +27,12 @@ function book_add_instance($book) {
$book->timecreated = time();
$book->timemodified = $book->timecreated;
if (!isset($book->customtitles)) {
$book->customtitles = 0;
}
if (!isset($book->disableprinting)) {
$book->disableprinting = 0;
}
return insert_record('book', $book);
}
@ -37,6 +45,12 @@ function book_update_instance($book) {
$book->timemodified = time();
$book->id = $book->instance;
if (!isset($book->customtitles)) {
$book->customtitles = 0;
}
if (!isset($book->disableprinting)) {
$book->disableprinting = 0;
}
# May have to add extra stuff in here #
@ -64,6 +78,20 @@ function book_delete_instance($id) {
return $result;
}
function book_get_types() {
global $CFG;
$types = array();
$type = new object();
$type->modclass = MOD_CLASS_RESOURCE;
$type->type = 'book';
$type->typestr = get_string('modulename', 'book');
$types[] = $type;
return $types;
}
function book_user_outline($course, $user, $mod, $book) {
/// Return a small object with summary information about what a
/// user has done with a given particular instance of this module
@ -178,11 +206,11 @@ function book_edit_button($id, $courseid, $chapterid) {
$string = get_string("turneditingon");
$edit = '1';
}
return '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/mod/book/view.php">'.
return '<form method="get" action="'.$CFG->wwwroot.'/mod/book/view.php"><div>'.
'<input type="hidden" name="id" value="'.$id.'" />'.
'<input type="hidden" name="chapterid" value="'.$chapterid.'" />'.
'<input type="hidden" name="edit" value="'.$edit.'" />'.
'<input type="submit" value="'.$string.'" /></form>';
'<input type="submit" value="'.$string.'" /></div></form>';
} else {
return '';
}

116
mod.html
View File

@ -1,116 +0,0 @@
<?php // $Id: mod.html,v 1.1 2006/03/12 18:39:59 skodak Exp $
require($CFG->dirroot.'/mod/book/lib.php');
if (empty($form->name)) {
$form->name = '';
}
if (empty($form->summary)) {
$form->summary = '';
}
if (empty($form->numbering)) {
$form->numbering = NUM_NONE;
}
if (empty($form->disableprinting)) {
$form->disableprinting = 0;
}
if (empty($form->customtitles)) {
$form->customtitles = 0;
}
?>
<form name="form" method="post" action="mod.php">
<table cellpadding="5" align="center">
<tr valign="top">
<td align="right"><p><b><?php print_string('name') ?>:</b></p></td>
<td>
<input type="text" name="name" size="30" value="<?php p($form->name) ?>">
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string('summary') ?>:</b></p>
<font size="1">
<?php
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
echo "<br />";
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
emoticonhelpbutton("form", "description");
}
?>
<br />
</font>
</td>
<td>
<?php print_textarea($usehtmleditor, 20, 60, 680, 400, 'summary', $form->summary); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string('numbering', 'book') ?>:</b></p></td>
<td>
<?php
choose_from_menu($NUMBERING_TYPE, 'numbering', $form->numbering, '');
helpbutton('numberingtype', get_string('numbering', 'book'), 'book');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string('disableprinting', 'book') ?>:</b></p></td>
<td>
<select size="1" name="disableprinting">
<option value="1" <?php
if ( $form->disableprinting ) {
echo 'selected="selected"';
}
?>><?php echo get_string('yes') ?>
</option>
<option value="0" <?php
if ( !$form->disableprinting ) {
echo 'selected="selected"';
}
?>><?php echo get_string('no') ?>
</option>
</select> <?php helpbutton('disableprinting', get_string('disableprinting', 'book'), 'book') ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string('customtitles', 'book') ?>:</b></p></td>
<td>
<select size="1" name="customtitles">
<option value="1" <?php
if ( $form->customtitles ) {
echo 'selected="selected"';
}
?>><?php echo get_string('yes') ?>
</option>
<option value="0" <?php
if ( !$form->customtitles ) {
echo 'selected="selected"';
}
?>><?php echo get_string('no') ?>
</option>
</select> <?php helpbutton('customtitles', get_string('customtitles', 'book'), 'book') ?>
</td>
</tr>
</table>
<center>
<input type="submit" value="<?php print_string('savechanges') ?>" />
</center>
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
</form>

44
mod_form.php Normal file
View File

@ -0,0 +1,44 @@
<?php
require_once($CFG->dirroot.'/mod/book/lib.php');
require_once('moodleform_mod.php');
class mod_book_mod_form extends moodleform_mod {
function definition() {
global $CFG;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'summary', get_string('summary'));
$mform->setType('summary', PARAM_RAW);
$mform->addRule('summary', null, 'required', null, 'client');
$mform->setHelpButton('summary', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('select', 'numbering', get_string('numbering', 'book'), book_get_numbering_types());
$mform->setHelpButton('numbering', array('numberingtype', get_string('numbering', 'book'), 'book'));
$mform->addElement('checkbox', 'disableprinting', get_string('disableprinting', 'book'));
$mform->setHelpButton('disableprinting', array('disableprinting', get_string('disableprinting', 'book'), 'book'));
$mform->setDefault('disableprinting', 0);
$mform->addElement('checkbox', 'customtitles', get_string('customtitles', 'book'));
$mform->setHelpButton('customtitles', array('customtitles', get_string('customtitles', 'book'), 'book'));
$mform->setDefault('customtitles', 0);
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
}
?>

View File

@ -1,4 +1,4 @@
<?PHP // $Id: print.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?PHP // $Id: print.php,v 1.2 2007/05/20 06:00:26 skodak Exp $
require_once('../../config.php');
require_once('lib.php');
@ -9,11 +9,7 @@ $chapterid = optional_param('chapterid', 0, PARAM_INT); // Chapter ID
// =========================================================================
// security checks START - teachers and students view
// =========================================================================
if ($CFG->forcelogin) {
require_login();
}
if (!$cm = get_record('course_modules', 'id', $id)) {
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
@ -21,13 +17,7 @@ if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if ($course->category) {
require_login($course->id);
}
if (!$cm->visible and !isteacher($course->id)) {
notice(get_string('activityiscurrentlyhidden'));
}
require_course_login($course, true, $cm);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
@ -61,23 +51,15 @@ unset($chapterid);
$strbooks = get_string('modulenameplural', 'book');
$strbook = get_string('modulename', 'book');
$strtop = get_string('top', 'book');
if (!empty($CFG->unicode)) {
$encoding = 'utf-8';
} else {
$encoding = get_string('thischarset');
}
moodle_setlocale(); //workaround for buggy forced course language
$strtop = get_string('top', 'book');
@header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
@header('Pragma: no-cache');
@header('Expires: ');
@header('Accept-Ranges: none');
@header('Content-type: text/html; charset='.$encoding);
@header('Content-type: text/html; charset=utf-8');
$formatoptions = new stdClass;
$formatoptions = new object();
$formatoptions->noclean = true;
if ($chapter) {
@ -94,9 +76,9 @@ if ($chapter) {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?PHP echo str_replace('"', '&quot;', $book->name) ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?PHP echo $encoding ?>" />
<meta name="description" content="<?PHP echo str_replace('"', '&quot;', $book->name) ?>" />
<title><?PHP echo format_string($book->name) ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<?PHP echo s(format_string($book->name)) ?>" />
<link rel="stylesheet" type="text/css" href="book_print.css" />
</head>
<body>
@ -125,28 +107,28 @@ if ($chapter) {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?PHP echo str_replace('"', '&quot;', $book->name) ?></title>
<title><?PHP echo format_string(name) ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?PHP echo $encoding ?>" />
<meta name="description" content="<?PHP echo str_replace('"', '&quot;', $book->name) ?>" />
<meta name="description" content="<?PHP echo s(format_string($book->name)) ?>" />
<link rel="stylesheet" type="text/css" href="book_print.css" />
</head>
<body>
<a name="top"></a>
<p class="book_title"><?PHP echo strip_tags($book->name) ?></p>
<p class="book_summary"><?PHP echo strip_tags($book->summary) ?></p>
<p class="book_title"><?PHP echo format_string($book->name) ?></p>
<p class="book_summary"><?PHP echo format_string($book->summary) ?></p>
<div class="book_info"><table>
<tr>
<td><?PHP echo get_string('site') ?>:</td>
<td><a href="<?PHP echo $CFG->wwwroot ?>"><?PHP echo strip_tags($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 strip_tags($course->fullname) ?></td>
<td><?PHP echo format_string($course->fullname) ?></td>
</tr><tr>
<td><?PHP echo get_string('modulename', 'book') ?>:</td>
<td><?PHP echo strip_tags($book->name) ?></td>
<td><?PHP echo format_string($book->name) ?></td>
</tr><tr>
<td><?PHP echo get_string('printedby', 'book') ?>:</td>
<td><?PHP echo strip_tags(fullname($USER, true)) ?></td>
<td><?PHP echo format_string(fullname($USER, true)) ?></td>
</tr><tr>
<td><?PHP echo get_string('printdate','book') ?>:</td>
<td><?PHP echo userdate(time()) ?></td>

View File

@ -1,4 +1,4 @@
<?PHP // $Id: teacheraccess.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
<?PHP // $Id: teacheraccess.php,v 1.2 2007/05/20 06:00:27 skodak Exp $
///standard routine to allow only teachers in
///check of $id and $chapterid parameters
@ -14,8 +14,7 @@ require_login();
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if (!$cm = get_record('course_modules', 'id', $id)) {
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
@ -23,9 +22,8 @@ if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (!isteacheredit($course->id)) {
error('Only editing teachers can edit books!');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('moodle/course:manageactivities', $context);
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');

20
toc.php
View File

@ -1,4 +1,4 @@
<?PHP // $Id: toc.php,v 1.2 2006/11/07 18:32:05 skodak Exp $
<?PHP // $Id: toc.php,v 1.3 2007/05/20 06:00:30 skodak Exp $
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
@ -125,23 +125,23 @@ if ($print) { ///TOC for printing
$currsubtitle = '&nbsp;';
}
} else {
$toc .= '<a title="'.htmlspecialchars($title).'" href="view.php?id='.$cm->id.'&chapterid='.$ch->id.'">'.$title.'</a>';
$toc .= '<a title="'.htmlspecialchars($title).'" href="view.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'">'.$title.'</a>';
}
$toc .= '&nbsp;&nbsp;';
if ($i != 1) {
$toc .= ' <a title="'.get_string('up').'" href="move.php?id='.$cm->id.'&chapterid='.$ch->id.'&up=1&sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/up.gif" height="11" width="11" border="0" /></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="'.$CFG->pixpath.'/t/up.gif" 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.'&chapterid='.$ch->id.'&up=0&sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/down.gif" height="11" width="11" border="0" /></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="'.$CFG->pixpath.'/t/down.gif" height="11" class="iconsmall" alt="'.get_string('down').'" /></a>';
}
$toc .= ' <a title="'.get_string('edit').'" href="edit.php?id='.$cm->id.'&chapterid='.$ch->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" /></a>';
$toc .= ' <a title="'.get_string('delete').'" href="delete.php?id='.$cm->id.'&chapterid='.$ch->id.'&sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" /></a>';
$toc .= ' <a title="'.get_string('edit').'" href="edit.php?id='.$cm->id.'&amp;chapterid='.$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>';
if ($ch->hidden) {
$toc .= ' <a title="'.get_string('show').'" href="show.php?id='.$cm->id.'&chapterid='.$ch->id.'&sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/show.gif" height="11" width="11" border="0" /></a>';
$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>';
} else {
$toc .= ' <a title="'.get_string('hide').'" href="show.php?id='.$cm->id.'&chapterid='.$ch->id.'&sesskey='.$USER->sesskey.'"><img src="'.$CFG->pixpath.'/t/hide.gif" height="11" width="11" border="0" /></a>';
$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('addafter', 'book').'" href="edit.php?id='.$cm->id.'&pagenum='.$ch->pagenum.'&subchapter='.$ch->subchapter.'"><img src="pix/add.gif" height="11" width="11" border="0" /></a>';
$toc .= ' <a title="'.get_string('addafter', 'book').'" href="edit.php?id='.$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 .= (!$ch->subchapter) ? '<ul>' : '</li>';
$first = 0;
@ -177,7 +177,7 @@ if ($print) { ///TOC for printing
$currsubtitle = '&nbsp;';
}
} else {
$toc .= '<a title="'.htmlspecialchars($title).'" href="view.php?id='.$cm->id.'&chapterid='.$ch->id.'">'.$title.'</a>';
$toc .= '<a title="'.htmlspecialchars($title).'" href="view.php?id='.$cm->id.'&amp;chapterid='.$ch->id.'">'.$title.'</a>';
}
$toc .= (!$ch->subchapter) ? '<ul>' : '</li>';
$first = 0;

View File

@ -1,13 +1,13 @@
<?PHP // $Id: version.php,v 1.2 2007/04/06 17:13:31 skodak Exp $
<?PHP // $Id: version.php,v 1.3 2007/05/20 06:00:28 skodak Exp $
/////////////////////////////////////////////////////////////////////////////////
/// Called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2007040600; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2006101020; // Requires this Moodle version
$module->version = 2007052000; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2007021505; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$release = "1.3alpha+"; // User-friendly version number
$release = "1.4alpha"; // User-friendly version number
?>

View File

@ -1,4 +1,4 @@
<?PHP // $Id: view.php,v 1.2 2006/10/16 08:05:26 gustav_delius Exp $
<?PHP // $Id: view.php,v 1.3 2007/05/20 06:00:29 skodak Exp $
require_once('../../config.php');
require_once('lib.php');
@ -10,29 +10,25 @@ $edit = optional_param('edit', -1, PARAM_BOOL); // Edit mode
// =========================================================================
// security checks START - teachers edit; students view
// =========================================================================
if ($CFG->forcelogin) {
require_login();
}
if (!$cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID is incorrect');
if (!$cm = get_coursemodule_from_id('book', $id)) {
error('Course Module ID was incorrect');
}
if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if ($course->category) {
require_login($course->id);
}
if (!$book = get_record('book', 'id', $cm->instance)) {
error('Course module is incorrect');
}
$isteacher = isteacheredit($course->id);
if ($isteacher) {
if($edit != -1) {
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$allowedit = has_capability('moodle/course:manageactivities', $context);
if ($allowedit) {
if ($edit != -1) {
$USER->editing = $edit;
} else {
if (isset($USER->editing)) {
@ -45,16 +41,12 @@ if ($isteacher) {
$edit = 0;
}
if (!$cm->visible and !$isteacher) {
notice(get_string('activityiscurrentlyhidden'));
}
/// read chapters
$select = $isteacher ? "bookid = $book->id" : "bookid = $book->id AND hidden = 0";
$select = $allowedit ? "bookid = $book->id" : "bookid = $book->id AND hidden = 0";
$chapters = get_records_select('book_chapters', $select, 'pagenum', 'id, pagenum, subchapter, title, hidden');
if (!$chapters) {
if ($isteacher) {
if ($allowedit) {
redirect('edit.php?id='.$cm->id); //no chapters - add new one
die;
} else {
@ -64,7 +56,7 @@ if (!$chapters) {
/// check chapterid and read chapter data
if ($chapterid == '0') { // go to first chapter if no given
foreach($chapters as $ch) {
if ($isteacher) {
if ($allowedit) {
$chapterid = $ch->id;
break;
}
@ -85,7 +77,7 @@ unset($id);
unset($chapterid);
/// chapter is hidden for students
if (!$isteacher and $chapter->hidden) {
if (!$allowedit and $chapter->hidden) {
error('Error reading book chapters.');
}
@ -97,7 +89,7 @@ if ($chapter->bookid != $book->id) {
// security checks END
// =========================================================================
add_to_log($course->id, 'book', 'view', 'view.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id);
add_to_log($course->id, 'book', 'view', 'view.php?id='.$cm->id.'&amp;chapterid='.$chapter->id, $book->id, $cm->id);
///read standard strings
@ -112,7 +104,7 @@ if ($course->category) {
$navigation = '';
}
$buttons = $isteacher ? '<table cellspacing="0" cellpadding="0"><tr><td>'.update_module_button($cm->id, $course->id, $strbook).'</td>'.
$buttons = $allowedit ? '<table cellspacing="0" cellpadding="0"><tr><td>'.update_module_button($cm->id, $course->id, $strbook).'</td>'.
'<td>&nbsp;</td><td>'.book_edit_button($cm->id, $course->id, $chapter->id).'</td></tr></table>'
: '&nbsp;';
@ -148,19 +140,18 @@ if ($ch == current($chapters)) {
}
$chnavigation = '';
if ($previd) {
$chnavigation .= '<a title="'.get_string('navprev', 'book').'" href="view.php?id='.$cm->id.'&chapterid='.$previd.'"><img src="pix/nav_prev.gif" height="24" width="24" border="0"></img></a>';
$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>';
} else {
$chnavigation .= '<img src="pix/nav_prev_dis.gif" height="24" width="24" border="0"></img>';
$chnavigation .= '<img src="pix/nav_prev_dis.gif" class="bigicon" alt="" />';
}
$chnavigation .= '&nbsp;&nbsp;<img src="pix/nav_sep.gif" height="24" width="2" border="0"></img>&nbsp;&nbsp;';
if ($nextid) {
$chnavigation .= '<a title="'.get_string('navnext', 'book').'" href="view.php?id='.$cm->id.'&chapterid='.$nextid.'"><img src="pix/nav_next.gif" height="24" width="24" border="0"></img></a>';
$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>';
} else {
$sec = '';
if ($section = get_record('course_sections', '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" height="24" width="24" border="0"></img></a>';
$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>';
}
/// prepare print icons
@ -168,8 +159,8 @@ if ($book->disableprinting) {
$printbook = '';
$printchapter = '';
} else {
$printbook = '<a title="'.get_string('printbook', 'book').'" href="print.php?id='.$cm->id.'" target="_blank"><img src="pix/print_book.gif" height="24" width="24" border="0"></img></a>';
$printchapter = '<a title="'.get_string('printchapter', 'book').'" href="print.php?id='.$cm->id.'&chapterid='.$chapter->id.'" target="_blank"><img src="pix/print_chapter.gif" height="24" width="24" border="0"></img></a>';
$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>';
}
// prepare $toc and $currtitle, $currsubtitle
@ -181,7 +172,8 @@ if ($edit) {
$tocwidth = $CFG->book_tocwidth;
}
$doimport = ($isteacher and $edit) ? '<font size="-1"> (<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</font>' : '';
$doimport = ($allowedit and $edit) ? '<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>' : '';
$doexport = ($allowedit and $edit) ? '<a href="generateimscp.php?id='.$cm->id.'">'.get_string('doexport', 'book').'</a>' : '';
// =====================================================
@ -194,12 +186,17 @@ $doimport = ($isteacher and $edit) ? '<font size="-1"> (<a href="import.php?id='
<!-- subchapter title and upper navigation row //-->
<tr>
<td width="<?php echo $tocwidth ?>" valign="bottom">
<?php print_string('toc', 'book'); echo $doimport; ?>
<?php
print_string('toc', 'book');
if (!empty($doimport)) {
echo "<br/>($doimport, $doexport)";
}
?>
</td>
<td valign="top">
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="0">
<tr>
<td nowrap align="left"><?php echo $printbook.'&nbsp'.$printchapter ?></td>
<td nowrap align="left"><?php echo $printbook.$printchapter ?></td>
<td nowrap align="right"><?php echo $chnavigation ?></td>
</tr>
</table>
@ -210,10 +207,10 @@ $doimport = ($isteacher and $edit) ? '<font size="-1"> (<a href="import.php?id='
<tr>
<td width="<?php echo $tocwidth ?>" valign="top" align="left">
<?php
print_simple_box_start('middle', '100%');
print_box_start('generalbox');
echo $toc;
print_simple_box_end();
if ($isteacher and $edit) {
print_box_end();
if ($allowedit and $edit) {
echo '<font size="1"><br />';
helpbutton('faq', get_string('faq','book'), 'book', true, true);
echo '</font>';
@ -222,7 +219,7 @@ $doimport = ($isteacher and $edit) ? '<font size="-1"> (<a href="import.php?id='
</td>
<td valign="top" align="right">
<?php
print_simple_box_start('middle', '100%');
print_box_start('generalbox');
$content = '';
if (!$book->customtitles) {
if ($currsubtitle == '&nbsp;') {
@ -238,9 +235,9 @@ $doimport = ($isteacher and $edit) ? '<font size="-1"> (<a href="import.php?id='
echo '<div class="book_content">';
echo format_text($content, FORMAT_HTML, $nocleanoption, $course->id);
echo '</div>';
print_simple_box_end();
print_box_end();
/// lower navigation
echo '<p>'.$chnavigation.'<p>';
echo '<p>'.$chnavigation.'</p>';
?>
</td>
</tr>