<? 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>
print_heading("Moodle $CFG->release ($CFG->version)", "CENTER", 1);
- print_footer();
+ print_footer($site);
?>
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;
}
`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`),
"longtimenosee" => 100,
"zip" => "/usr/bin/zip",
"unzip" => "/usr/bin/unzip",
- "slasharguments" => true,
+ "slasharguments" => 1,
+ "htmleditor" => true,
"proxyhost" => "",
"proxyport" => "",
"maxeditingtime" => 1800
<SCRIPT LANGUAGE="JavaScript">\r
<!-- //hide\r
function fillmessagebox(text) {\r
- document.form.message.value = text;\r
+ document.form.message.value = text;\r
}\r
\r
function openpopup(url,name,height,width) {\r
-fullurl = "<?=$CFG->wwwroot ?>" + url;\r
-options = "menubar=0,location=0,scrollbars,resizable,width="+width+",height="+height;\r
-windowobj = window.open(fullurl,name, options);\r
-windowobj.focus();\r
+ fullurl = "<?=$CFG->wwwroot ?>" + url;\r
+ options = "menubar=0,location=0,scrollbars,resizable,width="+width+",height="+height;\r
+ windowobj = window.open(fullurl,name, options);\r
+ windowobj.focus();\r
+}\r
+\r
+function copyrichtext(textname) { \r
+ textname.value = document.richedit.docHtml;\r
+ return true;\r
}\r
\r
<? if ($focus) { echo "function setfocus() { document.$focus.focus() }\n"; } ?>\r
// Martin Dougiamas, 2000
//
-
/// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
function print_header ($title="", $heading="", $navigation="", $focus="", $meta="", $cache=true, $button="") {
}
}
-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"
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();
return $gdversion; // 1, 2 or 0
}
+
+
?>
// 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.
}
}
+function format_text_menu() {
+ return array (FORMAT_MOODLE => get_string("formattext"),
+ FORMAT_HTML => get_string("formathtml") );
+}
+
+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;
-function cleantext($text) {
+ 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.