Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: fck editor.

fck editor

From MoodleDocs
Revision as of 02:57, 12 December 2007 by Julian Ridden (talk | contribs)

The print_textarea function to replace the one currently in weblib.php to implement fck editor.

Make sure fck editor is unzipped to "Moodle/lib/editor" in a folder "fckeditor"

Steps to installation

1. in moodle/lib/weblib.php replace the print_textarea function with the one provided. 2. download fck editor to moodle/lib/editor (be sure to name the folder with the editor as "fckeditor" 3. adjust the config file for fck editor to options you want to test 4. make sure in the print_textarea function that the path to fckeditor.js is correct If there is a change in your file structure



/* test FCKeditor implementation*/
 
 
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0) {
/// $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;
 static $scriptcount; // For loading the htmlarea script only once.

 if (empty($courseid)) {

 if (!empty($course->id)) { // search for it in global context

 $courseid = $course->id;

 }

 }

 if (empty($scriptcount)) {

 $scriptcount = 0;

 }


 if ($usehtmleditor) {

 if (!empty($courseid) and isteacher($courseid)) {

 echo ($scriptcount < 1) ? '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/fckeditor/fckeditor.js"></script>' . "\n" : '';

 } else {

 echo ($scriptcount < 1) ? '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/fckeditor/fckeditor.js"></script>'."\n" : '';

 }


 echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/fckeditor/fckeditor.js"></script>

  
    
  <script type="text/javascript">
      window.onload = function()
      {
        var oFCKeditor = new FCKeditor("MyTextarea") ;
        oFCKeditor.BasePath = "'. $CFG->wwwroot .'/lib/editor/fckeditor/" ;
        oFCKeditor.Height	= 400 ;
        oFCKeditor.Width	= 700 ;
        oFCKeditor.ReplaceTextarea() ;
      }
    </script>';

 

 $scriptcount++;





 if ($height) { // Usually with legacy calls

 if ($rows < $minrows) {

 $rows = $minrows;

 }

 }

 if ($width) { // Usually with legacy calls

 if ($cols < $mincols) {

 $cols = $mincols;

 }

 } 
 

 }

 echo '<textarea id= "MyTextarea"  name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';

 p($value);

 echo '</textarea>'."\n";

}


For Moodle 1.8.2: This FCKEditor integration only semi-works. It has the only-loading-in-first-textarea bug. see [1] for background and [2] for more on the whole editor issue at large. --Andrew Grothe 12:38, 9 October 2007 (CDT)