moved code up one level to eliminate the docs subdirectory
[acontent.git] / include / lib / tinymce.inc.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14
15 function load_editor($simple = TRUE, $name = FALSE, $mode="textareas") {
16         global $_base_path, $content_base_href, $_course_id;
17
18          if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) { 
19                 $course_base_href = 'get.php/'; 
20         } else {  
21                 $course_base_href = 'content/' . $_course_id . '/'; 
22         }
23
24 // Note: Some tinymce buttons are removed due to lack of accessibility for disabled.
25 // They are:
26 //New Document: newdocument
27 //Insert Time: inserttime
28 //Insert Date: insertdate
29 //Preview: preview
30 //toggle guidelines: visualaid
31 //spellcheck: iespell
32 //embed media: media
33 //print: print
34 //Insert Layer: insertlayer
35 //move forward: moveforward
36 //move backward: movebackward
37 //toggle absolute positioning: absolute
38 //citation: cite
39 //deletion: del
40 //insertion: ins
41 //visual control characters on/off: visualchars
42 //insert non-breaking space character: nonbreaking
43 //insert predefined template: template
44 //insert page break: pagebreak
45
46 echo '<script language="javascript" type="text/javascript" src="'.TR_BASE_HREF.'include/jscripts/tiny_mce/tiny_mce_src.js"></script>
47 <script language="javascript" type="text/javascript">';
48
49 echo 'var ATutor = ATutor || {};
50       trans.tinymce = trans.tinymce || {};
51
52       (function () {
53 ';
54
55 echo 'tinymce.PluginManager.load("insert_tag", "'.TR_BASE_HREF.'include/jscripts/tiny_mce_plugins/insert_tag/editor_plugin.js");
56 ';
57 echo 'tinymce.PluginManager.load("swap_toolbar", "'.TR_BASE_HREF.'include/jscripts/tiny_mce_plugins/swap_toolbar/editor_plugin.js");
58 ';
59
60 echo 'var initSettings = {';
61     if ($name) {
62         echo '  mode : "exact",';
63         echo '  elements : "'.$name.'",';
64     } else {
65         echo '  mode : "'.$mode.'",';
66     }   
67 echo 'theme: "advanced",
68       relative_urls : true,
69       content_css :"'.$_base_path.'/include/lib/tinymce_styles.css",
70       convert_urls : true,
71       accessibility_warnings : true,
72       entity_encoding : "raw",
73       accessibility_focus : true,
74       plugins : "-insert_tag, -swap_toolbar, acheck, table,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
75       theme_advanced_toolbar_location : "top",
76       theme_advanced_toolbar_align : "left",
77       theme_advanced_path_location : "bottom",
78       theme_advanced_resizing : true,
79       remove_linebreaks: false,
80       plugin_insertdate_dateFormat : "%Y-%m-%d",
81       plugin_insertdate_timeFormat : "%H:%M:%S",
82       extended_valid_elements : "a[name|href|target|title|onclick|style|class],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
83       document_base_url: "'.TR_BASE_HREF.$course_base_href.$content_base_href.'"
84     };
85
86     //these are the simple tools used on the content editor page
87     var simpleToolBars = {
88         theme_advanced_buttons1 : "swap_toolbar_complex,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,pasteword,link,unlink,|,acheck",
89         theme_advanced_buttons2 : "",
90         theme_advanced_buttons3 : "",
91         theme_advanced_buttons4 : ""
92     };
93     
94     //these are the more complex tools used on the content editor page
95     var complexToolBars = {
96         theme_advanced_buttons1 : "swap_toolbar_simple,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
97         theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,|,sub,sup,|,tablecontrols",
98         theme_advanced_buttons3 : "cut,copy,paste,pastetext,pasteword,|,link,unlink,anchor,image,|,abbr,acronym,|,charmap,emotions,advhr,|,insert_term_tag, insert_media_tag, insert_tex_tag",
99         theme_advanced_buttons4 : "search,replace,|,removeformat,undo,redo,|,styleprops,attribs,|,cleanup,code,|,fullscreen ,|,acheck"
100     };
101
102     trans.tinymce.initSimple = function() {
103         tinyMCE.init(jQuery.extend({}, initSettings, simpleToolBars));
104     };
105       
106     trans.tinymce.initComplex = function() {
107         tinyMCE.init(jQuery.extend({}, initSettings, complexToolBars));
108     };
109 ';
110     
111     if ($simple) {
112       echo 'trans.tinymce.initSimple();
113       ';
114     } else {
115       echo 'trans.tinymce.initComplex();
116       ';
117     }
118 echo '})();
119 ';
120 echo '</script>';
121 }
122
123 ?>