]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WysiwygEdit/FCKeditor.php
private
[SourceForge/phpwiki.git] / lib / WysiwygEdit / FCKeditor.php
1 <?php
2
3 /**
4  * FCKeditor 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://fckeditor.net/
9  * Suggested installation into themes/default/FCKeditor/
10  * or the default /FCKeditor/. See $this->BasePath below.
11  *
12  * @package WysiwygEdit
13  * @author Reini Urban
14  */
15
16 require_once 'lib/WysiwygEdit.php';
17
18 class WysiwygEdit_FCKeditor extends WysiwygEdit
19 {
20
21     function WysiwygEdit_FCKeditor()
22     {
23         global $LANG;
24         $this->_transformer_tags = false;
25         $this->BasePath = DATA_PATH . '/themes/default/FCKeditor/';
26         $this->_htmltextid = "edit-content"; // FCKEditor1;
27         $this->_wikitextid = "editareawiki";
28         $this->_jsdefault = "
29 oFCKeditor.BasePath     = '$this->BasePath';
30 oFCKeditor.Height       = 300;
31 // oFCKeditor.ToolbarSet        = 'Basic' ;
32 oFCKeditor.Config.DefaultLanguage = '$LANG';
33 oFCKeditor.Config.LinkBrowserURL  = oFCKeditor.BasePath + 'editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php';
34 oFCKeditor.Config.ImageBrowserURL = oFCKeditor.BasePath + 'editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php';
35 ";
36         if (!empty($_REQUEST['start_debug']))
37             $this->_jsdefault = "\noFCKeditor.Config.Debug = true;";
38     }
39
40     function Head($name = 'edit[content]')
41     {
42         global $WikiTheme;
43         $WikiTheme->addMoreHeaders
44         (Javascript('', array('src' => $this->BasePath . 'fckeditor.js',
45             'language' => 'JavaScript')));
46         return JavaScript("
47 window.onload = function()
48 {
49 var oFCKeditor = new FCKeditor( '$this->_htmltextid' ) ;"
50             . $this->_jsdefault . "
51 // force textarea in favor of iFrame?
52 // oFCKeditor._IsCompatibleBrowser = function() { return false; }
53 oFCKeditor.ReplaceTextarea();
54 }");
55     }
56
57     function Textarea($textarea, $wikitext, $name = 'edit[content]')
58     {
59         return $this->Textarea_Replace($textarea, $wikitext, $name);
60     }
61
62     /* either iframe or textarea */
63     function Textarea_Create($textarea, $wikitext, $name = 'edit[content]')
64     {
65         $htmltextid = $name;
66         $out = HTML(
67             JavaScript("
68 var oFCKeditor = new FCKeditor( '$htmltextid' ) ;
69 oFCKeditor.Value        = '" . $textarea->_content[0]->asXML() . "';"
70                 . $this->_jsdefault . "
71 oFCKeditor.Create();"),
72             HTML::div(array("id" => $this->_wikitextid,
73                     'style' => 'display:none'),
74                 $wikitext),
75             "\n");
76         return $out;
77     }
78
79     /* textarea only */
80     function Textarea_Replace($textarea, $wikitext, $name = 'edit[content]')
81     {
82         $htmltextid = $this->_htmltextid;
83         $textarea->SetAttr('id', $htmltextid);
84         $out = HTML($textarea,
85             HTML::div(array("id" => $this->_wikitextid,
86                     'style' => 'display:none'),
87                 $wikitext),
88             "\n");
89         return $out;
90     }
91
92     /* via the PHP object */
93     function Textarea_PHP($textarea, $wikitext, $name = 'edit[content]')
94     {
95         global $LANG;
96         $this->FilePath = realpath(PHPWIKI_DIR . '/themes/default/FCKeditor') . "/";
97
98         $htmltextid = "edit-content";
99
100         include_once($this->FilePath . 'fckeditor.php');
101         $this->oFCKeditor = new FCKeditor($htmltextid);
102         $this->oFCKeditor->BasePath = $this->BasePath;
103         $this->oFCKeditor->Value = $textarea->_content[0]->asXML();
104
105         $this->oFCKeditor->Config['AutoDetectLanguage'] = true;
106         $this->oFCKeditor->Config['DefaultLanguage'] = $LANG;
107         $this->oFCKeditor->Create();
108
109         return HTML::div(array("id" => $this->_wikitextid,
110                 'style' => 'display:none'),
111             $wikitext);
112     }
113
114 }
115
116 // Local Variables:
117 // mode: php
118 // tab-width: 8
119 // c-basic-offset: 4
120 // c-hanging-comment-ender-p: nil
121 // indent-tabs-mode: nil
122 // End: