$result = true;
if ($oldversion < 20020810) {
- if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
- $result = false;
- }
+ if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
+ $result = false;
+ }
+ }
+ if ($oldversion < 2002101200) {
+ execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
}
return $result;
user int(10) unsigned NOT NULL default '0',\r
modified int(10) unsigned NOT NULL default '0',\r
text text NOT NULL,\r
+ format tinyint(2) NOT NULL default '0',\r
rating tinyint(4) default '0',\r
comment text,\r
teacher int(10) unsigned NOT NULL default '0',\r
-<BLOCKQUOTE>
-<FORM name="form" method="post" action="edit.php">
-<TEXTAREA NAME=text COLS=60 ROWS=10 WRAP="virtual"><? p($entry->text) ?></TEXTAREA>
-<P>
+<FORM name="theform" method="post" <?=$onsubmit ?> action="edit.php">
+ <? if ($usehtmleditor) { ?>
+ <object id="richedit" style="BACKGROUND-COLOR: buttonface" data="../../lib/rte/richedit.html"
+ width="595" height="400" type="text/x-scriptlet" VIEWASTEXT>
+ </object>
+ <TEXTAREA style="display:none" NAME="text" ROWS=1 COLS=50><? p($entry->text) ?></TEXTAREA>
+ <? } else { ?>
+ <TEXTAREA NAME=text COLS=60 ROWS=20 WRAP="virtual"><? p($entry->text) ?></TEXTAREA>
+ <? } ?>
+
+<? if ($usehtmleditor) {
+ helpbutton("richtext", get_string("helprichtext"));
+ } else {
+ helpbutton("text", get_string("helptext"));
+ }
+?>
+
+<P align=center>
+<? print_string("formattexttype");
+ echo ": ";
+ choose_from_menu(format_text_menu(), "format", $entry->format, ""); ?>
+</P>
+
+<P align=center>
<INPUT type="hidden" name=id value="<?=$cm->id ?>">
<INPUT type="submit" value="<? print_string("savechanges") ?>">
<INPUT type="reset" value="<? print_string("revert") ?>">
</P>
</FORM>
-</BLOCKQUOTE>
+
+<? if ($usehtmleditor) { ?>
+ <SCRIPT language="JavaScript" event="onload" for="window">
+ document.richedit.options = "history=no;source=no";
+ document.richedit.docHtml = theform.text.innerText;
+ </SCRIPT>
+<? } ?>
+
$timenow = time();
+ $text = clean_text($text, $format);
+
if ($entry) {
$newentry->id = $entry->id;
$newentry->text = $text;
$newentry->modified = $timenow;
+ $newentry->format = $format;
if (! update_record("journal_entries", $newentry)) {
error("Could not update your journal");
}
$newentry->journal = $journal->id;
$newentry->modified = $timenow;
$newentry->text = $text;
+ $newentry->format = $format;
if (! $newentry->id = insert_record("journal_entries", $newentry)) {
error("Could not insert a new journal entry");
}
$strjournals = get_string("modulenameplural", "journal");
$stredit = get_string("edit");
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $defaultformat = FORMAT_HTML;
+ $onsubmit = "onsubmit=\"copyrichtext(theform.text);\"";
+ } else {
+ $defaultformat = FORMAT_MOODLE;
+ }
+
if (! $entry ) {
$entry->text = "";
+ $entry->format = $defaultformat;
}
print_header("$course->shortname: $journal->name", "$course->fullname",
if ($entry->timemarked) {
echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
}
- echo "<BR><TEXTAREA NAME=\"c$entry->id\" ROWS=6 COLS=60 WRAP=virtual>";
+ echo "<BR><TEXTAREA NAME=\"c$entry->id\" ROWS=12 COLS=60 WRAP=virtual>";
p($entry->comment);
echo "</TEXTAREA><BR>";
echo "</TD></TR>";
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002082000;
+$module->version = 2002101200;
$module->cron = 60;
?>
if (empty($entry->text)) {
echo "<P ALIGN=center><B>".get_string("blankentry","journal")."</B></P>";
} else {
- echo text_to_html($entry->text);
+ echo format_text($entry->text, $entry->format);
}
} else {