Changes to integrate the new HTML editor into Moodle in an optional way

until it's stable enough to replace Richtext

To enable the new editor, add this line into config.php:

  $CFG->useneweditor = true;
This commit is contained in:
moodler 2003-10-29 08:06:11 +00:00
parent a800c94891
commit 4c46c425db
8 changed files with 299 additions and 73 deletions

View file

@ -1512,23 +1512,52 @@ 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.
if (empty($_SERVER["HTTP_USER_AGENT"])) {
$agent = $_SERVER["HTTP_USER_AGENT"];
if (empty($agent)) {
return false;
}
$string = explode(";", $_SERVER["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;
switch ($brand) {
case "Gecko": /// Gecko based browsers
if (substr_count($agent, "Camino")) { // MacOS X Camino not supported.
return false;
}
// the proper string - Gecko/CCYYMMDD Vendor/Version
if (ereg("^([a-zA-Z]+)/([0-9]+\.[0-9]+) \((.*)\) (.*)$", $agent, $match)) {
if (ereg("^([Gecko]+)/([0-9]+)",$match[4], $reldate)) {
if ($reldate[2] > $version) {
return true;
}
}
}
break;
case "MSIE": /// Internet Explorer
$string = explode(";", $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;
}
break;
}
return false;
}
function ini_get_bool($ini_get_arg) {
/// This function makes the return value of ini_get consistent if you are
/// setting server directives through the .htaccess file in apache.
@ -1545,10 +1574,17 @@ function ini_get_bool($ini_get_arg) {
}
function can_use_richtext_editor() {
/// Is the richedit editor enabled?
/// Is the HTML editor enabled? This depends on site and user
/// settings, as well as the current browser being used.
global $USER, $CFG;
if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
return check_browser_version("MSIE", 5.5);
if (check_browser_version("MSIE", 5.5)) {
return true;
} else if (check_browser_version("Gecko", 20030516) and !empty($CFG->useneweditor) ) {
return true;
}
}
return false;
}