Index: message/send.php
===================================================================
--- message/send.php	(revision 146)
+++ message/send.php	(revision 147)
@@ -1,4 +1,4 @@
-<?php // $Id: send.php,v 1.22.2.4 2008/05/08 03:41:11 jerome Exp $
+<?php // $Id: send.php 78 2009/08/04 20:33:25Z dlandau $
 
 require('../config.php');
 require('lib.php');
@@ -15,7 +15,6 @@
 
 if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
 
-
 /// Don't use print_header, for more speed
     $stylesheetshtml = '';
     foreach ($CFG->stylesheets as $stylesheet) {
@@ -36,6 +35,12 @@
     echo $stylesheetshtml;
     include($CFG->javascript);
 
+    require_once($CFG->libdir .'/editor/htmlEditor.class.php');
+    $htmlEditorObject = new htmlEditor();
+    echo $htmlEditorObject->configure();
+
+    echo '<title> </title></head>';
+
 /// Script parameters
     $userid   = required_param('id', PARAM_INT);
     $message  = optional_param('message', '', PARAM_CLEANHTML);
@@ -62,6 +67,7 @@
         }
     }
 
+    echo '<body class="message course-1" id="message-send">';
 
     if ($message!='' and confirm_sesskey()) {   /// Current user has just sent a message
 
@@ -89,28 +95,23 @@
         add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&amp;user2='.$USER->id.'#m'.$messageid, $user->id);
     }
 
-    echo '<title> </title></head>';
-
-
-    echo '<body class="message course-1" id="message-send">';
-    echo '<center>';
     echo '<form id="editing" method="post" action="send.php">';
-    echo '<div>';
+    echo '<div class="message-form">';
     echo '<input type="hidden" name="id" value="'.$user->id.'" />';
     echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
 
     $usehtmleditor = (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0));
     if ($usehtmleditor) {
-        echo '<table><tr><td class="fixeditor" align="center">';
-        print_textarea($usehtmleditor, 9, 200, 0, 0, 'message', '');
-        echo '</td></tr></table>';
-        echo '<input type="submit" value="'.get_string('sendmessage', 'message').'" />';
-        use_html_editor('message', 'formatblock subscript superscript copy cut paste clean undo redo justifyleft justifycenter justifyright justifyfull lefttoright righttoleft insertorderedlist insertunorderedlist outdent indent inserthorizontalrule createanchor nolink inserttable');
+        echo '<div class="message-send-box">';
+        print_textarea($usehtmleditor, 5, 34, 0, 0, 'message', '', 0, false, '', 'form-textarea-simple');
+        echo '</div>';
+        echo '<input class="message-send-button" type="submit" value="'.get_string('sendmessage', 'message').'" />';
+        //use_html_editor('message', 'formatblock subscript superscript copy cut paste clean undo redo justifyleft justifycenter justifyright justifyfull lefttoright righttoleft insertorderedlist insertunorderedlist outdent indent inserthorizontalrule createanchor nolink inserttable');
         echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
     } else {
         print_textarea(false, 5, 34, 0, 0, 'message', '');
         echo '<input type="hidden" name="format" value="'.FORMAT_MOODLE.'" />';
-        echo '<br /><input type="submit" value="'.get_string('sendmessage', 'message').'" />';
+        echo '<br /><input class="message-send-button" type="submit" value="'.get_string('sendmessage', 'message').'" />';
     }
     echo '</div>';
     echo '</form>';
@@ -118,11 +119,15 @@
         notify(get_string('mailsent', 'message'), 'notifysuccess');
     }
     echo '<div class="noframesjslink"><a target="_parent" href="discussion.php?id='.$userid.'&amp;noframesjs=1">'.get_string('noframesjs', 'message').'</a></div>';
-    echo '</center>';
 
-    echo "\n<script type=\"text/javascript\">\n<!--\n";                  /// Focus on the textarea
-    echo 'document.getElementById("edit-message").focus();'."\n";
-    echo "\n-->\n</script>\n\n";
+    echo <<<EOF
+<script type="text/javascript">
+//<![CDATA[
+document.getElementById("edit-message").focus();
+//]]>
+</script>
+
+EOF;
 
     echo '</body></html>';
 }

Index: lib/editorlib.php
===================================================================
--- lib/editorlib.php	(revision 146)
+++ lib/editorlib.php	(revision 147)
@@ -1,13 +1,13 @@
-<?php // $Id: editorlib.php,v 1.3 2006/04/22 16:36:35 skodak Exp $
+<?php // $Id: editorlib.php 78 2009/08/04 20:33:25Z dlandau $
 
 /**
  * Editor class for Moodle.
  *
- * This library is made to make easier to intergrate
+ * This library is made to make easier to integrate
  * WYSIWYG editors into Moodle.
  *
  * @author Janne Mikkonen
- * @version $Id: editorlib.php,v 1.3 2006/04/22 16:36:35 skodak Exp $
+ * @version $Id: editorlib.php 78 2009/08/04 20:33:25Z dlandau $
  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  * @package editorObject
  */
@@ -32,24 +32,14 @@
     var $cfg;
 
     /**
-    * PHP4 style class constructor.
-    *
-    * @uses $CFG, $USER
+    * Constructor
     */
-    function editorObject () {
+    function __construct() {
         global $CFG, $USER;
         $this->cfg  = &$CFG;
         $this->user = &$USER;
         $this->courseid = NULL;
-    }
-
-    /**
-    * PHP5 style class constructor.
-    *
-    */
-    function __construct() {
-        $this->editorObject();
-    }
+     }
 
     /**
     * Method to load necessary editor codes to
@@ -99,16 +89,14 @@
                 break;
                 case 2:
                 case 'tinymce':
-                    array_push($CFG->editorsrc, "$editorbaseurl/tinymce/jscripts/tiny_mce/tiny_mce_gzip.php");
+                    array_push($CFG->editorsrc, "$editorbaseurl/tinymce/jscripts/tiny_mce/tiny_mce.js");
                     array_push($CFG->editorsrc, "$editorbaseurl/tinymce/moodledialog.js");
                     $classfile = "$editorbasedir/tinymce/tinymce.class.php";
                     include_once($classfile);
                     return (new tinymce($courseid));
                 break;
             }
-
         }
-
     }
 
     /**
@@ -123,6 +111,6 @@
         echo '</div>';
         exit;
     }
-
 }
-?>
\ No newline at end of file
+
+?>

Index: lib/deprecatedlib.php
===================================================================
--- lib/deprecatedlib.php	(revision 146)
+++ lib/deprecatedlib.php	(revision 147)
@@ -1689,4 +1689,7 @@
 
     die;
 }
+//function use_html_editor($name='', $editorhidebuttons='', $id='') {
+    // error('use_html_editor() not available anymore');
+//}
 ?>

Index: lib/moodlelib.php
===================================================================
--- lib/moodlelib.php	(revision 146)
+++ lib/moodlelib.php	(revision 147)
@@ -6517,6 +6517,9 @@
         } else if (check_browser_version('Gecko', 20030516)) {
             return 'Gecko';
         }
+else if (check_browser_version('Safari', 525)) {
+return 'KHTML';
+}
     }
     return false;
 }

Index: lib/adminlib.php
===================================================================
--- lib/adminlib.php	(revision 146)
+++ lib/adminlib.php	(revision 147)
@@ -1911,7 +1911,7 @@
         } 
 
         return format_admin_setting($this, $this->visiblename,
-                '<div class="form-textarea" ><textarea rows="'.$this->rows.'" cols="'.$this->cols.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'">'.s($data).'</textarea></div>',
+                   '<div class="form-textarea form-textarea-advanced" ><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
                 $this->description, true, '', $defaultinfo, $query);
     }
 }

Index: lib/editor/htmlEditor.class.php
===================================================================
--- lib/editor/htmlEditor.class.php	(revision 0)
+++ lib/editor/htmlEditor.class.php	(revision 147)
@@ -0,0 +1,210 @@
+<?php
+
+
+
+/**
+
+ *
+
+ * @copyright &copy; 2006 The Open University
+
+ * @author d.t.le@open.ac.uk, a.j.forth@open.ac.uk
+
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+
+ * @package portfolio
+
+ */
+
+
+
+
+
+class htmlEditor {
+
+
+
+    public function __construct() {
+
+    }
+
+
+
+    /**
+
+     * Does initial configuration for a given html editor.
+
+     * @param string editor the name of desired html editor, system default will be used if none is passed
+
+     * @param int courseid the courseid uploaded files should be linked to
+
+     * @return bool true if an editor was configured, false otherwise.
+
+     */
+
+    public function configure($editor = NULL, $courseid = NULL) {
+
+
+
+        global $CFG;
+
+        static $configured = Array();
+
+
+
+        if (!isset($CFG->htmleditor) or (!$CFG->htmleditor)) {
+
+            return;
+
+        }
+
+
+
+        if ($editor == '') {
+
+            $editor = (isset($CFG->defaulthtmleditor) ? $CFG->defaulthtmleditor : '');
+
+        }
+
+
+
+        if (isset($configured[$editor])) {
+
+            return $configured[$editor];
+
+        }
+
+
+
+        $configuration = array();
+
+
+
+        switch ($editor) {
+
+
+
+            case 'tinymce':
+
+                $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js";
+
+                $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce.js.php?course=". $courseid;
+
+                $configured['tinymce'] = true;
+
+                break;
+
+
+
+            case 'fckeditor':
+
+                $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor/fckeditor.js";
+
+                $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor.js.php?course=". $courseid;
+
+                $configured['fckeditor'] = true;
+
+                break;
+
+
+
+//            case 'xinha':
+
+//                $configuration = <<<EOF
+
+//<script type="text/javascript">
+
+//    _editor_url  = "{$CFG->wwwroot}/lib/editor/xinha/"
+
+//    _editor_lang = "en";
+
+//    _editor_skin = "blue-look";
+
+//</script>
+
+//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha/XinhaCore.js"></script>
+
+//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha.js.php"></script>
+
+//EOF;
+
+//                break;
+
+//
+
+//            case 'yuirte':
+
+//                $configuration = <<<EOF
+
+//<!-- Skin CSS file -->
+
+//<link rel="stylesheet" type="text/css" href="{$CFG->wwwroot}/lib/editor/yui/build/assets/skins/sam/skin.css">
+
+//
+
+//<!-- Utility Dependencies -->
+
+//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
+
+//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/element/element-beta-min.js"></script>
+
+//
+
+//<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
+
+//<script src="{$CFG->wwwroot}/lib/editor/yui/build/container/container_core-min.js"></script>
+
+//<script src="{$CFG->wwwroot}/lib/editor/yui/build/menu/menu-min.js"></script>
+
+//<script src="{$CFG->wwwroot}/lib/editor/yui/build/button/button-min.js"></script>
+
+//
+
+//<!-- Source file for Rich Text Editor-->
+
+//<script src="{$CFG->wwwroot}/lib/editor/yui/build/editor/editor-beta-min.js"></script>
+
+//
+
+//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yuirte.js.php"></script>
+
+//EOF;
+
+//                break;
+
+
+
+            default:
+
+                $configured[$editor] = false;
+
+                break;
+
+
+
+        }
+
+
+
+        if (isset($CFG->editorsrc) && is_array($CFG->editorsrc)) {
+
+            $CFG->editorsrc = $configuration + $CFG->editorsrc;
+
+        } else {
+
+            $CFG->editorsrc = $configuration;
+
+        }
+
+
+
+        return $configured[$editor];
+
+    }
+
+}
+
+
+
+?>
+

Index: lib/weblib.php
===================================================================
--- lib/weblib.php	(revision 146)
+++ lib/weblib.php	(revision 147)
@@ -2730,6 +2730,12 @@
 
     $bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"';
 
+//john 3 below
+require_once($CFG->libdir .'/editor/htmlEditor.class.php');
+    $htmlEditorObject = new htmlEditor();
+    $htmlEditor = $htmlEditorObject->configure(NULL, $COURSE->id);
+
+
     ob_start();
     include($CFG->header);
     $output = ob_get_contents();
@@ -4973,12 +4979,11 @@
  * @param int $courseid ?
  * @todo Finish documenting this function
  */
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {
-/// $width and height are legacy fields and no longer used as pixels like they used to be.
-/// However, you can set them to zero to override the mincols and minrows values below.
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='', $editorclass='form-textarea-advanced') {
+    /// $width and height are legacy fields and no longer used as pixels like they used to be.
+    /// However, you can set them to zero to override the mincols and minrows values below.
 
-    global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
-    static $scriptcount = 0; // For loading the htmlarea script only once.
+    global $CFG, $COURSE, $HTTPSPAGEREQUIRED, $THEME;
 
     $mincols = 65;
     $minrows = 10;
@@ -4988,40 +4993,22 @@
         $id = 'edit-'.$name;
     }
 
-    if ( empty($CFG->editorsrc) ) { // for backward compatibility.
-        if (empty($courseid)) {
-            $courseid = $COURSE->id;
+    if ( empty($CFG->editorsrc) && $usehtmleditor ) { // for backward compatibility.
+        if ($height && ($rows < $minrows)) {
+            $rows = $minrows;
         }
-
-        if ($usehtmleditor) {
-            if (!empty($courseid) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid))) {
-                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '&amp;httpsrequired=1';
-                // needed for course file area browsing in image insert plugin
-                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-                        $CFG->httpswwwroot .'/lib/editor/htmlarea/htmlarea.php?id='.$courseid.$httpsrequired.'"></script>'."\n" : '';
-            } else {
-                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '?httpsrequired=1';
-                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-                         $CFG->httpswwwroot .'/lib/editor/htmlarea/htmlarea.php'.$httpsrequired.'"></script>'."\n" : '';
-
-            }
-            $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
-                    $CFG->httpswwwroot .'/lib/editor/htmlarea/lang/en.php?id='.$courseid.'"></script>'."\n" : '';
-            $scriptcount++;
-
-            if ($height) {    // Usually with legacy calls
-                if ($rows < $minrows) {
-                    $rows = $minrows;
-                }
-            }
-            if ($width) {    // Usually with legacy calls
-                if ($cols < $mincols) {
-                    $cols = $mincols;
-                }
-            }
+        if ($width && ($cols < $mincols)) {
+            $cols = $mincols;
         }
     }
-    $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
+
+    if ($usehtmleditor) {
+        $THEME->htmleditors[] = $id;
+    } else {
+        $editorclass = '';
+    }
+
+    $str .= "\n".'<textarea class="form-textarea '. $editorclass .'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
     if ($usehtmleditor) {
         $str .= htmlspecialchars($value); // needed for editing of cleaned text!
     } else {
@@ -5030,12 +5017,17 @@
     $str .= '</textarea>'."\n";
 
     if ($usehtmleditor) {
+        $str_toggle = '<span class="helplink"><a href="javascript:mce_toggleEditor(\''. $id .'\');"><img width="50" height="17" src="'. $CFG->httpswwwroot .'/lib/editor/tinymce/images/toggle.gif" alt="'. get_string('editortoggle') .'" title="'. get_string('editortoggle') .'" class="icontoggle" /></a></span>';
         // Show shortcuts button if HTML editor is in use, but only if JavaScript is enabled (MDL-9556)
+        $str .= '<div class="textareaicons">';
         $str .= '<script type="text/javascript">
 //<![CDATA[
+mce_saveOnSubmit(\''.addslashes_js($id).'\');
+document.write(\''.addslashes_js($str_toggle).'\');
 document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
 //]]>
 </script>';
+        $str .= '</div>';
     }
 
     if ($return) {
@@ -5044,6 +5036,7 @@
     echo $str;
 }
 
+
 /**
  * Sets up the HTML editor on textareas in the current page.
  * If a field name is provided, then it will only be

Index: lib/form/htmleditor.php
===================================================================
--- lib/form/htmleditor.php	(revision 146)
+++ lib/form/htmleditor.php	(revision 147)
@@ -60,13 +60,11 @@
     }
 
     function toHtml(){
-        if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
-            ob_start();
-            use_html_editor($this->getName(), '', $this->getAttribute('id'));
-            $script=ob_get_clean();
-        } else {
-            $script='';
-        }
+        //if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
+        //    $script = '';
+        //} else {
+        //    $script='';
+        //}
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();
         } else {
@@ -78,9 +76,9 @@
                                     $this->_options['height'],
                                     $this->getName(),
                                     preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
-                                    $this->_options['course'],
+                                    0, // unused anymore
                                     true,
-                                    $this->getAttribute('id')).$script;
+                                    $this->getAttribute('id'));//.$script;
         }
     } //end func toHtml
 

Index: admin/settings.php
===================================================================
--- admin/settings.php	(revision 146)
+++ admin/settings.php	(revision 147)
@@ -164,7 +164,7 @@
 }
 
 if (!empty($CFG->adminusehtmleditor)) {
-    use_html_editor();
+    //use_html_editor();
 }
 
 print_footer();

Index: admin/settings/appearance.php
===================================================================
--- admin/settings/appearance.php	(revision 146)
+++ admin/settings/appearance.php	(revision 147)
@@ -51,6 +51,7 @@
     // "htmleditor" settingpage
     $temp = new admin_settingpage('htmleditor', get_string('htmleditor', 'admin'));
     $temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1));
+    /*
     $temp->add(new admin_setting_configtext('editorbackgroundcolor', get_string('editorbackgroundcolor', 'admin'), get_string('edhelpbgcolor'), '#ffffff', PARAM_NOTAGS));
     $temp->add(new admin_setting_configtext('editorfontfamily', get_string('editorfontfamily', 'admin'), get_string('edhelpfontfamily'), 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif', PARAM_NOTAGS));
     $temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS));
@@ -62,6 +63,7 @@
     }
     $temp->add(new admin_setting_special_editorhidebuttons());
     $temp->add(new admin_setting_emoticons());
+    */
     $ADMIN->add('appearance', $temp);
 
     // "htmlsettings" settingpage

Index: config.php
===================================================================
--- config.php	(revision 146)
+++ config.php	(revision 147)
@@ -21,6 +21,8 @@
 $CFG->passwordsaltmain = 'ciWL(JV4df:o)(+x`qNUH::bY F';
 
 require_once("$CFG->dirroot/lib/setup.php");
+$CFG->validateforms = 'server';
+$CFG->defaulthtmleditor='tinymce';
 // MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
 // RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
 ?>
\ No newline at end of file
Index: config-dist.php
===================================================================
--- config-dist.php	(revision 146)
+++ config-dist.php	(revision 147)
@@ -389,6 +389,8 @@
     }
     die;
 }
+$CFG->validateforms = 'server';
+$CFG->defaulthtmleditor='tinymce';
 // MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
 // RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
 ?>

Index: install.php
===================================================================
--- install.php	(revision 146)
+++ install.php	(revision 147)
@@ -559,6 +559,9 @@
     $str .= "\r\n";
 
     $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n";
+   // $str .= '// Force server-side form validation; required for FCKeditor'."\r\n";
+    $str .= '$CFG->validateforms = \'server'."';\r\n";
+    $str .= '$CFG->defaulthtmleditor=\'tinymce'."';\r\n";
     $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\r\n";
     $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\r\n";
     $str .= '?>';

Index: course/editsection.html
===================================================================
--- course/editsection.html	(revision 146)
+++ course/editsection.html	(revision 147)
@@ -16,7 +16,7 @@
     
     </td>
     <td>
-      <?php print_textarea($usehtmleditor, 25, 60, 660, 200, "summary", $form->summary); ?>
+       <?php print_textarea($usehtmleditor, 25, 60, 0, 0, 'summary', $form->summary, 0, false, 'summary'); ?>
     </td>
 </tr>
 </table>

