Commit 02039379 authored by Petr Skoda's avatar Petr Skoda
Browse files

== 1.3alpha - 2003/03/12===

    * compatible with 1.6dev only, use previous version for 1.5.x
    * unicode upgrade supported - not much tested
    * backup fixes - from Penny Leach, thanks!
    * all languages converted to utf-8
    * moved to contrib/book_16 directory
    * added proper content encoding conversion during import
parents
$Id: README.txt,v 1.1 2006/03/12 18:39:59 skodak Exp $
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999-2004 Martin Dougiamas http://dougiamas.com //
// //
///////////////////////////////////////////////////////////////////////////
// //
// Book module original code //
// Copyright (C) 2004 Petr Skoda (petr.skoda@vslib.cz) //
// //
///////////////////////////////////////////////////////////////////////////
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
Book module for Moodle - version 1.1 (stable release)
===============================================================================
Created by:
Petr Skoda (skodak) - most of the coding & design
Mojmir Volf - CSS formatted printer friendly format
Developed for Technical University of Liberec (Czech Republic).
Many ideas and code were taken from other Moodle modules and Moodle itself;-)
Installation:
1/ upgrade your Moodle installation to version 1.5.1 or later
(you are advised to install latest official stable 1.5.2+ branch)
2/ download book.zip to your moodle/mod directory and unzip it there
3/ go to http://yoursite.com/admin - all necessary tables will be created
List of features - version 1.2:
* easy to use - new teachers can quickly create multipage study materials
* two levels - only chapters and subchapters
* possible automatic chapter numbering
* chapters authored in build-in HTML editor (html stored in database,
images in course data)
* printing support - all chapters can be displayed on one CSS formatted page
* backup/restore with internal link preservation
* support for global searching in study materials (see contrib/search)
* import from html files (relinking of images, flash, Java applets and
relative links)
* works with MySQL and PostgreSQL databases
* no need to move language packs any more
Intentionally omitted features:
* more chapter levels - it would encourage teachers to write too much
complex and long books, better use standard standalone HTML editor and
import it as Resource. DocBook format is another suitable solution.
* TOC hiding in normal view - instead use printer friendly view
* PDF export - there is no elegant way AFAIK to convert HTML to PDF,
use virtual PDF printer or better use DocBook format for authoring
* detailed student tracking (postponed till officially supported)
* export as zipped set of HTML pages - instead use browser command
Save page as... in print view
Future:
* I like eXe editor, I would like to improve Book in this direction ... ;-)
CHANGELOG:
== 1.1 - 2005/01/01 =======================================================
* compatible ONLY with 1.4.3 and later!
* removed some unused searching stuff
* fixed headers in print.php
== 1.1RC1 - 2004/11/15 =======================================================
* compatible ONLY with 1.4.2 and later !!!
* added sesskey for enhanced security
* navigation links do not enter hidden chapters
* import - correct linking when slasharguments are off
* removed coursefiles.php
== 1.2RC - 2005/07/13 ==========================================================
* compatible with 1.5.1 + only
* improved restore
* fixed selection of directories for import
* html editor for summary
* fixed postgresql upgrade
* no need to move language packs
== 1.2 - 2003/03/11 ==========================================================
* removed 64kB page content limit in mysql
* exit button now goes to course section anchor
* chater title now in browser title bar
* added translations be and sv
* during import chapters with names "*_sub.htm?" are imported as subchapters
* deleting in import selection windows now works
* last version before transition to 1.6
== 1.3alpha - 2003/03/12 ======================================================
* compatible with 1.6dev only, use previous version for 1.5.x
* unicode upgrade supported - not much tested
* backup fixes - from Penny Leach, thanks!
* all languages converted to utf-8
* moved to contrib/book_16 directory
* added proper content encoding conversion during import
skodak
<?PHP // $Id: backuplib.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
//This php script contains all the stuff to backup/restore
//book mods
//This is the 'graphical' structure of the book mod:
//
// book
// (CL,pk->id)
// |
// |
// |
// book_chapters
// (CL,pk->id, fk->bookid)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
//This function executes all the backup procedure about this mod
function book_backup_mods($bf,$preferences) {
global $CFG;
$status = true;
////Iterate over book table
if ($books = get_records ('book', 'course', $preferences->backup_course, 'id')) {
foreach ($books as $book) {
if (backup_mod_selected($preferences,'book',$book->id)) {
$status = book_backup_one_mod($bf,$preferences,$book);
}
}
}
return $status;
}
function book_backup_one_mod($bf,$preferences,$book) {
global $CFG;
if (is_numeric($book)) {
$book = get_record('book','id',$book);
}
$status = true;
//Start mod
fwrite ($bf,start_tag('MOD',3,true));
//Print book data
fwrite ($bf,full_tag('ID',4,false,$book->id));
fwrite ($bf,full_tag('MODTYPE',4,false,'book'));
fwrite ($bf,full_tag('NAME',4,false,$book->name));
fwrite ($bf,full_tag('SUMMARY',4,false,$book->summary));
fwrite ($bf,full_tag('NUMBERING',4,false,$book->numbering));
fwrite ($bf,full_tag('DISABLEPRINTING',4,false,$book->disableprinting));
fwrite ($bf,full_tag('CUSTOMTITLES',4,false,$book->customtitles));
fwrite ($bf,full_tag('TIMECREATED',4,false,$book->timecreated));
fwrite ($bf,full_tag('TIMEMODIFIED',4,false,$book->timemodified));
//back up the chapters
$status = backup_book_chapters($bf,$preferences,$book);
//End mod
$status = fwrite($bf,end_tag('MOD',3,true));
return $status;
}
//Backup book_chapters contents (executed from book_backup_mods)
function backup_book_chapters($bf,$preferences,$book) {
global $CFG;
$status = true;
//Print book's chapters
if ($chapters = get_records('book_chapters', 'bookid', $book->id, 'id')) {
//Write start tag
$status =fwrite ($bf,start_tag('CHAPTERS',4,true));
foreach ($chapters as $ch) {
//Start chapter
fwrite ($bf,start_tag('CHAPTER',5,true));
//Print chapter data
fwrite ($bf,full_tag('ID',6,false,$ch->id));
fwrite ($bf,full_tag('PAGENUM',6,false,$ch->pagenum));
fwrite ($bf,full_tag('SUBCHAPTER',6,false,$ch->subchapter));
fwrite ($bf,full_tag('TITLE',6,false,$ch->title));
fwrite ($bf,full_tag('CONTENT',6,false,$ch->content));
fwrite ($bf,full_tag('HIDDEN',6,false,$ch->hidden));
fwrite ($bf,full_tag('TIMECREATED',6,false,$ch->timecreated));
fwrite ($bf,full_tag('TIMEMODIFIED',6,false,$ch->timemodified));
fwrite ($bf,full_tag('IMPORTSRC',6,false,$ch->importsrc));
//End chapter
$status = fwrite ($bf,end_tag('CHAPTER',5,true));
}
//Write end tag
$status = fwrite ($bf,end_tag('CHAPTERS',4,true));
}
return $status;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function book_encode_content_links ($content,$preferences) {
global $CFG;
$base = preg_quote($CFG->wwwroot,"/");
$result = $content;
//Link to the list of books
$buscar="/(".$base."\/mod\/book\/index.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@BOOKINDEX*$2@$',$result);
//Link to book's specific chapter
$buscar="/(".$base."\/mod\/book\/view.php\?id\=)([0-9]+)\&chapterid\=([0-9]+)/";
$result= preg_replace($buscar,'$@BOOKCHAPTER*$2*$3@$',$result);
//Link to book's first chapter
$buscar="/(".$base."\/mod\/book\/view.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@BOOKSTART*$2@$',$result);
return $result;
}
////Return an array of info (name,value)
function book_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += book_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string('modulenameplural','book');
$info[0][1] = count_records('book', 'course', $course);
//No user data for books ;-)
return $info;
}
////Return an array of info (name,value)
function book_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
return $info;
}
?>
/* $Id: book_print.css,v 1.1 2006/03/12 18:39:59 skodak Exp $ */
h1, h2, h3, h4, h5, h6 {
margin-left: 0px;
font-family: "Times New Roman", Times, serif;
page-break-after: avoid;
page-break-inside: avoid;
}
.book_title {
margin-left: -40px;
font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
font-size: 3em;
font-weight: bold;
margin-top: 120px;
margin-bottom: 30px;
text-align: center;
}
.book_summary {
margin-left: -40px;
text-align: center;
margin-bottom: 120px;
}
.book_chapter_title {
font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
text-align: left;
font-size: 1.7em;
font-weight: bold;
border-style: solid;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 1px;
border-left-width: 0px;
margin-left: -40px;
margin-left: 0px;
margin-bottom: 20px;
}
.book_chapter {
page-break-before: always;
}
body {
margin-left: 50px;
margin-right: 10px;
color: #000000;
background-color: #FFFFFF;
font-family: "Times New Roman", Times, serif;
font-size: 1em;
font-weight: normal;
text-decoration: none;
}
/* link rewriting for mozilla - collides with filters :-( */
/*
a[href^="http://"]:after, a[href^="ftp://"]:after {
content: " ["attr(href)"]";
}
*/
/* just some hack - ignore user defined <font> */
font {
color: #000000;
background-color: #EEEEEE;
font-family: "Times New Roman", Times, serif;
font-size: 1em;
font-weight: normal;
text-decoration: none;
}
/* ===== TOC numbering styles ===== */
/* numbering == NONE */
.book_toc_none {
page-break-before: always;
}
.book_toc_none ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_none ul ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_none li {
margin-top: 10px;
list-style: none;
}
.book_toc_none li li {
margin-top: 0px;
list-style: none;
}
/* numbering == NUMBERED */
.book_toc_numbered {
page-break-before: always;
}
.book_toc_numbered ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_numbered ul ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_numbered li {
margin-top: 10px;
list-style: none;
}
.book_toc_numbered li li {
margin-top: 0px;
list-style: none;
}
/* numbering == BULLETS */
.book_toc_bullets {
page-break-before: always;
}
.book_toc_bullets ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_bullets ul ul {
margin-left: 20px;
padding-left: 0px;
}
.book_toc_bullets li {
margin-top: 10px;
list-style: none;
}
.book_toc_bullets li li {
margin-top: 0px;
list-style: circle;
}
/* numbering == INDENTED */
.book_toc_indented {
page-break-before: always;
}
.book_toc_indented ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_indented ul ul {
margin-left: 20px;
padding-left: 0px;
}
.book_toc_indented li {
margin-top: 10px;
list-style: none;
}
.book_toc_indented li li {
margin-top: 0px;
list-style: none;
}
/* $Id: book_theme.css,v 1.1 2006/03/12 18:39:59 skodak Exp $*/
/* later should be defined in themes*/
.book_chapter_title {
font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
text-align: left;
font-size: large;
font-weight: bold;
margin-left: 0px;
margin-bottom: 20px;
}
.book_content {
text-align: left;
}
/* == TOC styles == */
/* toc style NONE */
.book_toc_none ul {
margin-left: 5px;
padding-left: 0px;
}
.book_toc_none ul ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_none li {
margin-top: 5px;
list-style: none;
}
.book_toc_none li li {
margin-top: 0px;
list-style: none;
}
/* toc style NUMBERED */
.book_toc_numbered ul {
margin-left: 5px;
padding-left: 0px;
}
.book_toc_numbered ul ul {
margin-left: 0px;
padding-left: 0px;
}
.book_toc_numbered li {
margin-top: 5px;
list-style: none;
}
.book_toc_numbered li li {
margin-top: 0px;
list-style: none;
}
/*toc style BULLETS */
.book_toc_bullets ul {
margin-left: 5px;
padding-left: 0px;
}
.book_toc_bullets ul ul {
margin-left: 20px;
padding-left: 0px;
}
.book_toc_bullets li {
margin-top: 5px;
list-style: none;
}
.book_toc_bullets li li {
margin-top: 0px;
list-style: circle;
}
/* toc style INDENTED*/
.book_toc_indented ul {
margin-left: 5px;
padding-left: 0px;
}
.book_toc_indented ul ul {
margin-left: 15px;
padding-left: 0px;
}
.book_toc_indented li {
margin-top: 5px;
list-style: none;
}
.book_toc_indented li li {
margin-top: 0px;
list-style: none;
}
<!-- $Id: config.html,v 1.1 2006/03/12 18:39:59 skodak Exp $ //-->
<form method="post" action="module.php" name="form">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
<table cellpadding="9" cellspacing="0">
<tr valign="top">
<td align="right">
<p>book_tocwidth:</p>
</td>
<td>
<?php
$choices = array('140'=>'140', '160'=>'160', '180'=>'180', '200'=>'200',
'220'=>'220', '240'=>'240', '260'=>'260', '280'=>'280', '300'=>'300');
choose_from_menu ($choices, 'book_tocwidth', $CFG->book_tocwidth, '');
?>
</td>
<td>
<?php print_string('tocwidth', 'book') ?>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="<?php print_string('savechanges') ?>" />
</td>
</tr>
</table>
</form>
This diff is collapsed.
<?php // $Id: migrate2utf8.php,v 1.1 2006/03/12 18:40:01 skodak Exp $
function migrate2utf8_book_name($recordid){
global $CFG, $globallang;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$book = get_record('book','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
if ($globallang) {
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
$courselang = get_course_lang($book->course); //Non existing!
$userlang = get_main_teacher_lang($book->course); //N.E.!!
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
}
/// We are going to use textlib facilities
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
/// Convert the text
$result = utfconvert($book->name, $fromenc);
$newbook = new object;
$newbook->id = $recordid;
$newbook->name = $result;
migrate2utf8_update_record('book',$newbook);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_book_summary($recordid){
global $CFG, $globallang;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$book = get_record('book','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
if ($globallang) {
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
$courselang = get_course_lang($book->course); //Non existing!
$userlang = get_main_teacher_lang($book->course); //N.E.!!
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
}
/// We are going to use textlib facilities
/// Convert the text
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
$result = utfconvert($book->summary, $fromenc);
$newbook = new object;
$newbook->id = $recordid;
$newbook->summary = $result;
migrate2utf8_update_record('book',$newbook);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_book_chapters_title($recordid){