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