Additions to cope with richtext editor being used in some forms.

This commit is contained in:
moodler
2002-10-10 07:26:10 +00:00
parent fa7d70c8c1
commit 0095d5cd3c
8 changed files with 125 additions and 13 deletions
+14
View File
@@ -65,6 +65,20 @@
<? print_string("configgdversion") ?>
</TD>
</TR>
<TR VALIGN=TOP>
<TD ALIGN=RIGHT><P>htmleditor:</TD>
<TD>
<? unset($options);
$options[0] = get_string("allownot");
$options[1] = get_string("allow");
choose_from_menu ($options, "htmleditor", $config->htmleditor, "", "", "");
formerr($err["htmleditor"]);
?>
</TD>
<TD>
<? print_string("confightmleditor") ?>
</TD>
</TR>
<TR VALIGN=TOP>
<TD ALIGN=RIGHT><P>maxeditingtime:</TD>
<TD>
+1 -1
View File
@@ -255,7 +255,7 @@
print_heading("Moodle $CFG->release ($CFG->version)", "CENTER", 1);
print_footer();
print_footer($site);
?>
+3
View File
@@ -74,6 +74,9 @@ function upgrade_moodle($oldversion=0) {
if ($oldversion < 2002092100) {
execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
}
if ($oldversion < 2002101001) {
execute_sql(" ALTER TABLE `user` ADD `htmleditor` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL AFTER `maildisplay` ");
}
return true;
}
+1
View File
@@ -175,6 +175,7 @@ CREATE TABLE `user` (
`description` text,
`mailformat` tinyint(1) unsigned NOT NULL default '1',
`maildisplay` tinyint(2) unsigned NOT NULL default '2',
`htmleditor` tinyint(1) unsigned NOT NULL default '1',
`timemodified` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
+2 -1
View File
@@ -13,7 +13,8 @@
"longtimenosee" => 100,
"zip" => "/usr/bin/zip",
"unzip" => "/usr/bin/unzip",
"slasharguments" => true,
"slasharguments" => 1,
"htmleditor" => true,
"proxyhost" => "",
"proxyport" => "",
"maxeditingtime" => 1800
+10 -5
View File
@@ -2,14 +2,19 @@
<SCRIPT LANGUAGE="JavaScript">
<!-- //hide
function fillmessagebox(text) {
document.form.message.value = text;
document.form.message.value = text;
}
function openpopup(url,name,height,width) {
fullurl = "<?=$CFG->wwwroot ?>" + url;
options = "menubar=0,location=0,scrollbars,resizable,width="+width+",height="+height;
windowobj = window.open(fullurl,name, options);
windowobj.focus();
fullurl = "<?=$CFG->wwwroot ?>" + url;
options = "menubar=0,location=0,scrollbars,resizable,width="+width+",height="+height;
windowobj = window.open(fullurl,name, options);
windowobj.focus();
}
function copyrichtext(textname) {
textname.value = document.richedit.docHtml;
return true;
}
<? if ($focus) { echo "function setfocus() { document.$focus.focus() }\n"; } ?>
+50 -3
View File
@@ -8,7 +8,6 @@
// Martin Dougiamas, 2000
//
/// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
function print_header ($title="", $heading="", $navigation="", $focus="", $meta="", $cache=true, $button="") {
@@ -769,20 +768,39 @@ function get_record_sql($sql) {
}
}
function get_records($table, $selector, $value, $sort="") {
function get_records($table, $selector, $value, $sort="", $fields="*") {
// Get a number of records as an array of objects
// Can optionally be sorted eg "time ASC" or "time DESC"
// If "fields" is specified, only those fields are returned
// The "key" is the first column returned, eg usually "id"
global $db;
if ($sort) {
$sortorder = "ORDER BY $sort";
}
$sql = "SELECT $fields FROM $table WHERE $selector = '$value' $sortorder";
return get_records_sql($sql);
}
function get_records_list($table, $selector, $values, $sort="", $fields="*") {
// Get a number of records as an array of objects
// Differs from get_records() in that the values variable
// can be a comma-separated list of values eg "4,5,6,10"
// Can optionally be sorted eg "time ASC" or "time DESC"
// The "key" is the first column returned, eg usually "id"
global $db;
if ($sort) {
$sortorder = "ORDER BY $sort";
}
$sql = "SELECT * FROM $table WHERE $selector = '$value' $sortorder";
$sql = "SELECT $fields FROM $table WHERE $selector in ($values) $sortorder";
return get_records_sql($sql);
}
function get_records_sql($sql) {
// Get a number of records as an array of objects
// The "key" is the first column returned, eg usually "id"
@@ -1928,6 +1946,33 @@ function check_php_version($version="4.1.0") {
return ($curversion >= $minversion);
}
function check_browser_version($brand="MSIE", $version=5.5) {
// Checks to see if is a browser matches the specified
// brand and is equal or better version.
global $HTTP_USER_AGENT;
if (!$HTTP_USER_AGENT) {
return false;
}
$string = explode(";", $HTTP_USER_AGENT);
if (!isset($string[1])) {
return false;
}
$string = explode(" ", trim($string[1]));
if (!isset($string[0]) and !isset($string[1])) {
return false;
}
if ($string[0] == $brand and (float)$string[1] >= $version ) {
return true;
}
return false;
}
function can_use_richtext_editor() {
global $USER, $CFG;
return (check_browser_version("MSIE", 5.5) and $USER->htmleditor and $CFG->htmleditor);
}
function check_gd_version() {
ob_start();
@@ -1952,4 +1997,6 @@ function check_gd_version() {
return $gdversion; // 1, 2 or 0
}
?>
+44 -3
View File
@@ -2,10 +2,19 @@
// weblib.php
//
// Library of useful PHP functions related to web pages.
// Library of useful PHP functions and constants related to web pages.
//
//
/// Constants
// Define text formatting types ... eventually we can add Wiki, BBcode etc
define("FORMAT_MOODLE", "0");
define("FORMAT_HTML", "1");
/// Functions
function s($var) {
// returns $var with HTML characters (like "<", ">", etc.) properly quoted,
// or if $var is empty, will return an empty string.
@@ -259,15 +268,47 @@ function get_slash_arguments($i=0) {
}
}
function format_text_menu() {
return array (FORMAT_MOODLE => get_string("formattext"),
FORMAT_HTML => get_string("formathtml") );
}
function cleantext($text) {
function format_text($text, $format, $options=NULL) {
// Given text in a variety of format codings, this function returns
// the text as safe HTML.
//
// $text is raw text (originally from a user)
// $format is one of the format constants, defined above
switch ($format) {
case FORMAT_MOODLE:
return text_to_html($text, $options->smiley, $options->para);
break;
case FORMAT_HTML:
return $text; // Is re-cleaning needed?
break;
}
}
function clean_text($text, $format) {
// Given raw text (eg typed in by a user), this function cleans it up
// and removes any nasty tags that could mess up Moodle pages.
return strip_tags($text, '<b><i><u><font><ol><ul><dl><li><dt><dd><h1><h2><h3><hr>');
switch ($format) {
case FORMAT_MOODLE:
return strip_tags($text, '<b><i><u><font><ol><ul><dl><li><dt><dd><h1><h2><h3><hr>');
break;
case FORMAT_HTML:
return $text; // XX May want to add some cleaning on this.
break;
}
}
function text_to_html($text, $smiley=true, $para=true) {
// Given plain text, makes it into HTML as nicely as possible.