]> git.mjollnir.org Git - moodle.git/commitdiff
Added richtext to Journal entries.
authormoodler <moodler>
Sat, 12 Oct 2002 06:20:56 +0000 (06:20 +0000)
committermoodler <moodler>
Sat, 12 Oct 2002 06:20:56 +0000 (06:20 +0000)
mod/journal/db/mysql.php
mod/journal/db/mysql.sql
mod/journal/edit.html
mod/journal/edit.php
mod/journal/lib.php
mod/journal/version.php
mod/journal/view.php

index 5d0c042552db1e55f82ce1d92c259a073d76e74c..7a3e8887a0f1170ee0d2f2c5c9394c79938b70a5 100644 (file)
@@ -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;
index c480ce41be4cdc03f336cc2e1fbf229c12137aa5..36bfcf64f481f5d766d04cce04c621945c03dbb2 100755 (executable)
@@ -36,6 +36,7 @@ CREATE TABLE journal_entries (
   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
index eacfeb308b4a63927a53bddb277377238e1d3ad1..8a1e62af6da2eb55fb3028a1cd43d56a03f9f8f5 100644 (file)
@@ -1,10 +1,37 @@
-<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 ":&nbsp;";
+   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>
+<? } ?>
+
index 70d4ae89210be9be481ef749cbac879fa3c96d4f..b158177e43bab445f3f8e2fee81a0f7a03c6f956 100644 (file)
 
                $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");
                        }
     $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",
index 182ac5e20a5fe079e00be9dd7a26bcad54974d95..2d55f519a0146fa7b78ee30a732c3aa60eaf85fc 100644 (file)
@@ -208,7 +208,7 @@ function journal_print_user_entry($course, $user, $entry, $teachers, $ratings) {
         if ($entry->timemarked) {
             echo "&nbsp;&nbsp;<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>";
index 9f3f71f0a02e97bcb599a67d79e768f9c5a98a7c..e66cd09b9fea95fc681e68b6f9e43833ee2b5d68 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002082000;
+$module->version  = 2002101200;
 $module->cron     = 60;
 
 ?>
index 7d423476e812b892a03720ca2030fcddfb4af815..6f2eb229309983e1f61e08b434d1834334451fb9 100644 (file)
@@ -86,7 +86,7 @@
             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 {