From: moodler Date: Sat, 12 Oct 2002 06:20:56 +0000 (+0000) Subject: Added richtext to Journal entries. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b2a5ee182296518bc7579ba478c0aae31505cbb4;p=moodle.git Added richtext to Journal entries. --- diff --git a/mod/journal/db/mysql.php b/mod/journal/db/mysql.php index 5d0c042552..7a3e8887a0 100644 --- a/mod/journal/db/mysql.php +++ b/mod/journal/db/mysql.php @@ -7,9 +7,12 @@ function journal_upgrade($oldversion) { $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; diff --git a/mod/journal/db/mysql.sql b/mod/journal/db/mysql.sql index c480ce41be..36bfcf64f4 100755 --- a/mod/journal/db/mysql.sql +++ b/mod/journal/db/mysql.sql @@ -36,6 +36,7 @@ CREATE TABLE journal_entries ( user int(10) unsigned NOT NULL default '0', modified int(10) unsigned NOT NULL default '0', text text NOT NULL, + format tinyint(2) NOT NULL default '0', rating tinyint(4) default '0', comment text, teacher int(10) unsigned NOT NULL default '0', diff --git a/mod/journal/edit.html b/mod/journal/edit.html index eacfeb308b..8a1e62af6d 100644 --- a/mod/journal/edit.html +++ b/mod/journal/edit.html @@ -1,10 +1,37 @@ -
-
- -

+ action="edit.php"> + + + + + + + + + + +

+format, ""); ?> +

+ +

"> ">

-
+ + + + + diff --git a/mod/journal/edit.php b/mod/journal/edit.php index 70d4ae8921..b158177e43 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -32,10 +32,13 @@ $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"); } @@ -45,6 +48,7 @@ $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"); } @@ -61,8 +65,16 @@ $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", diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 182ac5e20a..2d55f519a0 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -208,7 +208,7 @@ function journal_print_user_entry($course, $user, $entry, $teachers, $ratings) { if ($entry->timemarked) { echo "  ".userdate($entry->timemarked).""; } - echo "

"; echo ""; diff --git a/mod/journal/version.php b/mod/journal/version.php index 9f3f71f0a0..e66cd09b9f 100644 --- a/mod/journal/version.php +++ b/mod/journal/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2002082000; +$module->version = 2002101200; $module->cron = 60; ?> diff --git a/mod/journal/view.php b/mod/journal/view.php index 7d423476e8..6f2eb22930 100644 --- a/mod/journal/view.php +++ b/mod/journal/view.php @@ -86,7 +86,7 @@ if (empty($entry->text)) { echo "

".get_string("blankentry","journal")."

"; } else { - echo text_to_html($entry->text); + echo format_text($entry->text, $entry->format); } } else {