]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WysiwygEdit/Wikiwyg.php
warn user about beta quality, not to save wrong edits
[SourceForge/phpwiki.git] / lib / WysiwygEdit / Wikiwyg.php
1 <?php
2 rcs_id('$Id: Wikiwyg.php,v 1.6 2006-08-25 22:42:51 rurban Exp $');
3 /**
4  * Wikiwyg is compatible with most internet browsers which
5  * include: IE 5.5+ (Windows), Firefox 1.0+, Mozilla 1.3+
6  * and Netscape 7+.
7  *
8  * Download: http://openjsan.org/doc/i/in/ingy/Wikiwyg/
9  * Suggested installation into themes/default/Wikiwyg/
10  *
11  * @package WysiwygEdit
12  * @author  Reini Urban, based on a patch by Jean-Nicolas GEREONE, STMicroelectronics, 2006
13  */
14
15 require_once("lib/WysiwygEdit.php");
16
17 class WysiwygEdit_Wikiwyg extends WysiwygEdit {
18
19     function WysiwygEdit_Wikiwyg() {
20         global $LANG;
21         $this->_transformer_tags = false;
22         $this->BasePath = DATA_PATH.'/themes/default/Wikiwyg';
23         $this->_htmltextid = "edit:content";
24         $this->_wikitextid = "editareawiki";
25         $this->_jsdefault = "
26 var base_url = '".DATA_PATH."';
27 var data_url = '$this->BasePath';
28 var script_url = '".deduce_script_name()."';
29 ";
30     }
31
32     function Head($name='edit[content]') {
33         global $WikiTheme;
34         foreach (array("Wikiwyg.js","Wikiwyg/Toolbar.js","Wikiwyg/Preview.js","Wikiwyg/Wikitext.js",
35                        "Wikiwyg/Wysiwyg.js","Wikiwyg/Phpwiki.js","Wikiwyg/HTML.js",
36                        "Wikiwyg/Toolbar.js") as $js) {
37             $WikiTheme->addMoreHeaders
38                 (Javascript('', array('src' => $this->BasePath . '/' . $js,
39                                       'language' => 'JavaScript')));
40         }
41         $doubleClickToEdit = ($GLOBALS['request']->getPref('doubleClickEdit') or ENABLE_DOUBLECLICKEDIT) 
42             ? 'true' : 'false';
43         return JavaScript($this->_jsdefault . "
44 window.onload = function() {
45    var wikiwyg = new Wikiwyg.Phpwiki();
46    var config = {
47             doubleClickToEdit:  $doubleClickToEdit,
48             javascriptLocation: base_url+'/themes/default/Wikiwyg/',
49             toolbar: {
50                 imagesLocation: base_url+'/themes/default/Wikiwyg/images/',
51                 controlLayout: [
52                        'save','preview','|','save_button','|',
53                        'mode_selector', '/',
54                        'p','|',
55                        'h2', 'h3', 'h4','|',
56                        'bold', 'italic', '|',
57                        'sup', 'sub', '|',
58                        'toc',
59                        'wikitext','|',
60                        'pre','|',
61                        'ordered', 'unordered','hr','|',
62                        'link','|',
63                        'table'
64                        ],
65                 styleSelector: [
66                        'label', 'p', 'h2', 'h3', 'h4', 'pre'
67                                 ], 
68                 controlLabels: {
69                        save:     '"._("Apply changes")."',
70                        cancel:   '"._("Exit toolbar")."',
71                        h2:       '"._("Title 1")."',
72                        h3:       '"._("Title 2")."',
73                        h4:       '"._("Title 3")."',
74                        verbatim: '"._("Verbatim")."',
75                        toc:   '"._("Table of content")."', 
76                        wikitext:   '"._("Insert Wikitext section")."', 
77                        sup:      '"._("Sup")."', 
78                        sub:      '"._("Sub")."',
79                        preview:  '"._("Preview")."',   
80                        save_button:'"._("Save")."'   
81                       }
82             },
83             wysiwyg: {
84                 iframeId: 'iframe0'
85             },
86             wikitext: {
87               supportCamelCaseLinks: true
88             }
89    };
90    var div = document.getElementById(\"" . $this->_htmltextid . "\");
91    wikiwyg.createWikiwygArea(div, config);
92    wikiwyg_divs.push(wikiwyg);
93    wikiwyg.editMode();
94 }");
95     }
96
97     function Textarea ($textarea, $wikitext, $name='edit[content]') {
98         $htmltextid = $this->_htmltextid;
99         $textarea->SetAttr('id', $htmltextid);
100         $iframe0 = new RawXml('<iframe id="iframe0" height="0" width="0" frameborder="0"></iframe>');
101         $out = HTML(HTML::div(array('class' => 'hint'), 
102                               _("Warning: This Wikiwyg editor has only Beta quality!")),
103                     $textarea,
104                     $iframe0,
105                     "\n");
106         return $out;
107     }
108
109     /**
110      * Handler to convert the Wiki Markup to HTML before editing.
111      * This will be converted back by WysiwygEdit_ConvertAfter if required.
112      *  *text* => '<b>text<b>'
113      */
114     function ConvertBefore($text) {
115         return $text;
116     }
117
118     /* 
119      * No special PHP HTML->Wikitext conversion needed. This is done in js thanksfully. 
120      * Avoided in editpage.php: PageEditor->getContent
121      */
122     function ConvertAfter($text) {
123         return TransformInline($text);
124     }
125 }
126
127
128 /*
129  $Log: not supported by cvs2svn $
130  Revision 1.5  2006/06/28 14:28:14  jeannicolas
131
132
133  Add preview and save button on the toolbar.
134  Fix an IE issue in wikitext mode.
135
136  Revision 1.4  2006/06/19 17:33:06  jeannicolas
137
138  Add button to insert table of content plugin
139  Add button to insert wikitext section in wysiwyg mode
140
141  Fix internet explorer issue in wikitext mode. The toolbar in this mode didn't work.
142
143  Revision 1.3  2006/05/31 19:59:57  jeannicolas
144
145
146  Added wysiwyg_editor 1.1b
147
148  Revision 1.2  2006/05/14 17:52:20  rurban
149  fix syntax error. delete a left-over attempt to add CSS links also. We did put everything into phpwiki.css for browser compatibility.
150
151  Revision 1.1  2006/05/13 19:59:55  rurban
152  added wysiwyg_editor-1.3a feature by Jean-Nicolas GEREONE <jean-nicolas.gereone@st.com>
153  converted wysiwyg_editor-1.3a js to WysiwygEdit framework
154  changed default ENABLE_WYSIWYG = true and added WYSIWYG_BACKEND = Wikiwyg
155
156
157 */
158
159 // Local Variables:
160 // mode: php
161 // tab-width: 8
162 // c-basic-offset: 4
163 // c-hanging-comment-ender-p: nil
164 // indent-tabs-mode: nil
165 // End:
166 ?>