File: FCKeditor.php

package info (click to toggle)
phpwiki 1.3.14-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,716 kB
  • ctags: 23,548
  • sloc: php: 88,295; sql: 1,476; sh: 1,378; perl: 765; makefile: 602; awk: 28
file content (128 lines) | stat: -rwxr-xr-x 3,941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
rcs_id('$Id: FCKeditor.php,v 1.2 2007/01/07 18:44:00 rurban Exp $');
/**
 * FCKeditor is compatible with most internet browsers which
 * include: IE 5.5+ (Windows), Firefox 1.0+, Mozilla 1.3+
 * and Netscape 7+.
 *
 * Download: http://fckeditor.net/
 * Suggested installation into themes/default/FCKeditor/
 * or the default /FCKeditor/. See $this->BasePath below.
 *
 * @package WysiwygEdit
 * @author Reini Urban
 */

require_once("lib/WysiwygEdit.php");

class WysiwygEdit_FCKeditor extends WysiwygEdit {

    function WysiwygEdit_FCKeditor() {
        global $LANG;
        $this->_transformer_tags = false;
	$this->BasePath = DATA_PATH.'/themes/default/FCKeditor/';
	$this->_htmltextid = "edit-content"; // FCKEditor1;
        $this->_wikitextid = "editareawiki";
    	$this->_jsdefault = "
oFCKeditor.BasePath	= '$this->BasePath';
oFCKeditor.Height	= 300;
// oFCKeditor.ToolbarSet	= 'Basic' ;
oFCKeditor.Config.DefaultLanguage = '$LANG';
oFCKeditor.Config.LinkBrowserURL  = oFCKeditor.BasePath + 'editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php';
oFCKeditor.Config.ImageBrowserURL = oFCKeditor.BasePath + 'editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php';
";
    	if (!empty($_REQUEST['start_debug']))
    	    $this->_jsdefault = "\noFCKeditor.Config.Debug = true;";
    }

    function Head($name='edit[content]') {
        global $WikiTheme;
        $WikiTheme->addMoreHeaders
            (Javascript('', array('src' => $this->BasePath . 'fckeditor.js',
                                  'language' => 'JavaScript')));
	return JavaScript("
window.onload = function()
{
var oFCKeditor = new FCKeditor( '$this->_htmltextid' ) ;"
. $this->_jsdefault . "
// force textarea in favor of iFrame?
// oFCKeditor._IsCompatibleBrowser = function() { return false; }
oFCKeditor.ReplaceTextarea();
}");
    }

    function Textarea ($textarea, $wikitext, $name='edit[content]') {
    	return $this->Textarea_Replace($textarea, $wikitext, $name);
    }

    /* either iframe or textarea */
    function Textarea_Create ($textarea, $wikitext, $name='edit[content]') {
        $htmltextid = $name;
        $out = HTML(
		    JavaScript("
var oFCKeditor = new FCKeditor( '$htmltextid' ) ;
oFCKeditor.Value	= '" . $textarea->_content[0]->asXML() . "';" 
. $this->_jsdefault . "
oFCKeditor.Create();"),
		    HTML::div(array("id"    => $this->_wikitextid, 
				    'style' => 'display:none'),
			      $wikitext),
		    "\n");
	return $out;
    }
    
    /* textarea only */
    function Textarea_Replace ($textarea, $wikitext, $name='edit[content]') {
        $htmltextid = $this->_htmltextid;
        $textarea->SetAttr('id', $htmltextid);
        $out = HTML($textarea,
		    HTML::div(array("id"    => $this->_wikitextid, 
				    'style' => 'display:none'),
			      $wikitext),
		    "\n");
	return $out;
    }
    
    /* via the PHP object */
    function Textarea_PHP ($textarea, $wikitext, $name='edit[content]') {
        global $LANG;
	$this->FilePath = realpath(PHPWIKI_DIR.'/themes/default/FCKeditor') . "/";

        $htmltextid = "edit-content";

	include_once($this->FilePath . 'fckeditor.php');
	$this->oFCKeditor = new FCKeditor($htmltextid) ;
	$this->oFCKeditor->BasePath = $this->BasePath;
	$this->oFCKeditor->Value = $textarea->_content[0]->asXML();

	$this->oFCKeditor->Config['AutoDetectLanguage']	= true ;
	$this->oFCKeditor->Config['DefaultLanguage'] = $LANG;
	$this->oFCKeditor->Create();
	
	return HTML::div(array("id"   => $this->_wikitextid, 
			      'style' => 'display:none'),
			      $wikitext);
    }

}


/*
 $Log: FCKeditor.php,v $
 Revision 1.2  2007/01/07 18:44:00  rurban
 Improve id: edit: to edit-

 Revision 1.1  2005/10/31 16:41:46  rurban
 added FCKeditor + spaw


*/

// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>