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

This commit is contained in:
moodler 2002-10-10 07:27:57 +00:00
parent d2fce839b6
commit 73bb08357c
6 changed files with 43 additions and 7 deletions

View File

@ -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 File

@ -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 File

@ -24,6 +24,7 @@ $FORUM_OPEN_MODES = array ("2" => get_string("openmode2", "forum"),
"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 File

@ -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 File

@ -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 File

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002100300;
$module->version = 2002101001;
$module->cron = 60;
?>