| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: editorlib.php,v 1.3 2006/04/22 16:36:35 skodak Exp $ 2 3 /** 4 * Editor class for Moodle. 5 * 6 * This library is made to make easier to intergrate 7 * WYSIWYG editors into Moodle. 8 * 9 * @author Janne Mikkonen 10 * @version $Id: editorlib.php,v 1.3 2006/04/22 16:36:35 skodak Exp $ 11 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 12 * @package editorObject 13 */ 14 class editorObject { 15 16 /** 17 * Holds the internal $USER standard object. 18 * @var object $user 19 */ 20 var $user; 21 22 /** 23 * Holds the course id. 24 * @var int $courseid 25 */ 26 var $courseid; 27 28 /** 29 * Hold the internal $CFG standard class. 30 * @var object $cfg 31 */ 32 var $cfg; 33 34 /** 35 * PHP4 style class constructor. 36 * 37 * @uses $CFG, $USER 38 */ 39 function editorObject () { 40 global $CFG, $USER; 41 $this->cfg = &$CFG; 42 $this->user = &$USER; 43 $this->courseid = NULL; 44 } 45 46 /** 47 * PHP5 style class constructor. 48 * 49 */ 50 function __construct() { 51 $this->editorObject(); 52 } 53 54 /** 55 * Method to load necessary editor codes to 56 * $CFG->editorsrc array. 57 * 58 * @todo example code. 59 * @param mixed $args Course id or associative array holding course id and editor name. 60 */ 61 function loadeditor($args) { 62 63 global $CFG, $USER; 64 65 if ( is_array($args) ) { 66 // If args is an array search keys courseid and name. 67 // Name represents editor name to load. 68 if ( !array_key_exists('courseid', $args) ) { 69 error("Required variable courseid is missing!"); 70 } 71 72 if ( !array_key_exists('name', $args) ) { 73 error("Required variable name is missing!"); 74 } 75 76 $courseid = clean_param($args['courseid'], PARAM_INT); 77 $editorname = strtolower(clean_param($args['name'], PARAM_ALPHA)); 78 } else { 79 // If only single argument is passed 80 // this must be course id. 81 $courseid = clean_param($args, PARAM_INT); 82 } 83 84 $htmleditor = !empty($editorname) ? $editorname : intval($USER->htmleditor); 85 86 if ( can_use_html_editor() ) { 87 $CFG->editorsrc = array(); 88 $editorbaseurl = $CFG->httpswwwroot .'/lib/editor'; 89 $editorbasedir = $CFG->dirroot .'/lib/editor'; 90 91 switch ($htmleditor) { 92 case 1: 93 case 'htmlarea': 94 array_push($CFG->editorsrc, "$editorbaseurl/htmlarea/htmlarea.php?id={$courseid}"); 95 array_push($CFG->editorsrc, "$editorbaseurl/htmlarea/lang/en.php"); 96 $classfile = "$editorbasedir/htmlarea/htmlarea.class.php"; 97 include_once($classfile); 98 return (new htmlarea($courseid)); 99 break; 100 case 2: 101 case 'tinymce': 102 array_push($CFG->editorsrc, "$editorbaseurl/tinymce/jscripts/tiny_mce/tiny_mce_gzip.php"); 103 array_push($CFG->editorsrc, "$editorbaseurl/tinymce/moodledialog.js"); 104 $classfile = "$editorbasedir/tinymce/tinymce.class.php"; 105 include_once($classfile); 106 return (new tinymce($courseid)); 107 break; 108 } 109 110 } 111 112 } 113 114 /** 115 * Print out error message and stop outputting. 116 * 117 * @param string $message 118 */ 119 function error($message) { 120 echo '<div style="text-align: center; font-weight: bold; color: red;">'; 121 echo '<span style="color: black;">editorObject error:</span> '; 122 echo s($message, true); 123 echo '</div>'; 124 exit; 125 } 126 127 } 128 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |