Permalink
Browse files

Initial attempt at adding html text editor features to these forms.

  • Loading branch information...
1 parent d2fce83 commit 73bb08357c7314391e74336c5bf345ab920f9e87 moodler committed Oct 10, 2002
Showing with 43 additions and 7 deletions.
  1. +3 −0 mod/forum/db/mysql.php
  2. +1 −0 mod/forum/db/mysql.sql
  3. +4 −3 mod/forum/lib.php
  4. +29 −2 mod/forum/post.html
  5. +5 −1 mod/forum/post.php
  6. +1 −1 mod/forum/version.php
View
@@ -46,6 +46,9 @@ function forum_upgrade($oldversion) {
execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
}
+ if ($oldversion < 2002101001) {
+ execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` ");
+ }
return true;
View
@@ -47,6 +47,7 @@ CREATE TABLE forum_posts (
mailed tinyint(1) unsigned NOT NULL default '0',
subject varchar(255) NOT NULL default '',
message text NOT NULL,
+ format tinyint(2) NOT NULL default '0',
attachment VARCHAR(100) NOT NULL default '',
totalscore tinyint(4) NOT NULL default '0',
PRIMARY KEY (id)
View
@@ -24,6 +24,7 @@
"1" => get_string("openmode1", "forum"),
"0" => get_string("openmode0", "forum") );
+
$FORUM_SHORT_POST = 300; // Less than this is "short"
$FORUM_LONG_POST = 600; // More than this is "long"
@@ -123,7 +124,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
$output .= "</DIV>";
}
- $output .= text_to_html($post->message);
+ $output .= format_text($post->message, $post->format);
$output .= "<P ALIGN=right><FONT SIZE=-1>";
@@ -202,14 +203,14 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
if ($link && (strlen($post->message) > $FORUM_LONG_POST)) {
// Print shortened version
- echo text_to_html(forum_shorten_post($post->message));
+ echo format_text(forum_shorten_post($post->message), $post->format);
$numwords = count_words($post->message);
echo "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion\">";
echo get_string("readtherest", "forum");
echo "</A> (".get_string("numwords", "", $numwords).")...";
} else {
// Print whole message
- echo text_to_html($post->message);
+ echo format_text($post->message, $post->format);
}
echo "<P ALIGN=right><FONT SIZE=-1>";
View
@@ -1,4 +1,4 @@
-<form name="form" method="post" action="post.php" enctype="multipart/form-data">
+<form name="theform" method="post" action="post.php" <?=$onsubmit ?> enctype="multipart/form-data">
<table cellpadding=5>
<tr valign=top>
<td align=right><P><B><? print_string("subject", "forum"); ?>:</B></P></TD>
@@ -12,7 +12,15 @@
<tr valign=top>
<td align=right><P><B><? print_string("message", "forum"); ?>:</B><BR><BR><? helpbutton("text", get_string("helptext")) ?></P></TD>
<td>
- <textarea name=message rows=15 cols=50 wrap="virtual"><? p($post->message) ?></textarea>
+ <? 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="message" ROWS=1 COLS=50><? p($post->message) ?></TEXTAREA>
+ <? } else { ?>
+ <TEXTAREA name=message rows=15 cols=50 wrap="virtual"><? p($post->message) ?></TEXTAREA>
+ <? } ?>
+
</td>
<td rowspan=2>
<FONT SIZE=1>
@@ -21,6 +29,17 @@
</FONT>
</td>
</tr>
+<tr valign=top>
+ <td align=right><P><B><? print_string("formattexttype"); ?>:</B></P></TD>
+ <td>
+ <?PHP
+ $POST_FORMATS = format_text_menu();
+ choose_from_menu($POST_FORMATS, "format", $post->format, ""); ?>
+ </td>
+ <td>
+ &nbsp;
+ </td>
+</tr>
<tr valign=top>
<td><P><B><? print_string("attachment", "forum") ?>:<BR>(<? print_string("optional") ?>)</B></P></td>
<td>
@@ -42,3 +61,11 @@
<tr valign=top>
</table>
</FORM>
+
+<? if ($usehtmleditor) { ?>
+ <SCRIPT language="JavaScript" event="onload" for="window">
+ document.richedit.options = "history=no;source=no";
+ document.richedit.docHtml = theform.message.innerText;
+ </SCRIPT>
+<? } ?>
+
View
@@ -14,7 +14,7 @@
$post = (object)$HTTP_POST_VARS;
$post->subject = strip_tags($post->subject); // Strip all tags
- $post->message = cleantext($post->message); // Clean up any bad tags
+ $post->message = clean_text($post->message, $post->format); // Clean up any bad tags
$post->attachment = $HTTP_POST_FILES["attachment"];
@@ -262,6 +262,10 @@
$strforums = get_string("modulenameplural", "forum");
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $onsubmit = "onsubmit=\"copyrichtext(theform.message);\"";
+ }
+
$navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">$strforums</A> -> <A HREF=\"view.php?f=$forum->id\">$forum->name</A>";
if ($course->category) {
View
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002100300;
+$module->version = 2002101001;
$module->cron = 60;
?>

0 comments on commit 73bb083

Please sign in to comment.