Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
Line 1... Line 1...
1
<?php 
1
<?php
2
/*
2
/*
3
 * FCKeditor - The text editor for internet
3
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
4
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
-
 
5
 *
-
 
6
 * == BEGIN LICENSE ==
5
 * 
7
 *
6
 * Licensed under the terms of the GNU Lesser General Public License:
8
 * Licensed under the terms of any of the following licenses at your
7
 * 		http://www.opensource.org/licenses/lgpl-license.php
9
 * choice:
8
 * 
10
 *
9
 * For further information visit:
11
 *  - GNU General Public License Version 2 or later (the "GPL")
10
 * 		http://www.fckeditor.net/
12
 *    http://www.gnu.org/licenses/gpl.html
11
 * 
13
 *
12
 * "Support Open Source software. What about a donation today?"
14
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
-
 
15
 *    http://www.gnu.org/licenses/lgpl.html
13
 * 
16
 *
14
 * File Name: fckeditor.php
17
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
15
 * 	This is the integration file for PHP.
18
 *    http://www.mozilla.org/MPL/MPL-1.1.html
16
 * 	
19
 *
17
 * 	It defines the FCKeditor class that can be used to create editor
20
 * == END LICENSE ==
-
 
21
 *
18
 * 	instances in PHP pages on server side.
22
 * This is the integration file for PHP (All versions).
19
 * 
23
 *
20
 * File Authors:
24
 * It loads the correct integration file based on the PHP version (avoiding
21
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
25
 * strict error messages with PHP 5).
22
 */
26
 */
Line 23... Line -...
23
 
-
 
24
class FCKeditor
-
 
25
{
-
 
26
	var $InstanceName ;
-
 
27
	var $BasePath ;
-
 
28
	var $Width ;
-
 
29
	var $Height ;
-
 
30
	var $ToolbarSet ;
-
 
31
	var $Value ;
-
 
32
	var $Config ;
-
 
33
 
-
 
34
	// PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)
-
 
35
	function __construct( $instanceName )
-
 
36
 	{
-
 
37
		$this->InstanceName	= $instanceName ;
-
 
38
		$this->BasePath		= '/fckeditor/' ;
-
 
39
		$this->Width		= '100%' ;
-
 
40
		$this->Height		= '200' ;
-
 
41
		$this->ToolbarSet	= 'Default' ;
-
 
42
		$this->Value		= '' ;
-
 
43
 
-
 
44
		$this->Config		= array() ;
-
 
45
	}
-
 
46
	
-
 
47
	// PHP 4 Contructor
-
 
48
	function FCKeditor( $instanceName )
-
 
49
	{
-
 
50
		$this->__construct( $instanceName ) ;
-
 
51
	}
-
 
52
 
-
 
53
	function Create()
-
 
54
	{
-
 
55
		echo $this->CreateHtml() ;
-
 
56
	}
-
 
57
	
-
 
58
	function CreateHtml()
-
 
59
	{
-
 
60
		$HtmlValue = htmlspecialchars( $this->Value ) ;
-
 
61
 
-
 
62
		$Html = '<div>' ;
-
 
63
		
-
 
64
		if ( $this->IsCompatible() )
-
 
65
		{
-
 
66
			if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
-
 
67
				$File = 'fckeditor.original.html' ;
-
 
68
			else
-
 
69
				$File = 'fckeditor.html' ;
-
 
70
 
-
 
71
			$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
-
 
72
			
-
 
73
			if ( $this->ToolbarSet != '' )
-
 
74
				$Link .= "&amp;Toolbar={$this->ToolbarSet}" ;
-
 
75
 
-
 
76
			// Render the linked hidden field.
-
 
77
			$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
-
 
78
 
-
 
79
			// Render the configurations hidden field.
-
 
80
			$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
-
 
81
 
-
 
82
			// Render the editor IFRAME.
-
 
83
			$Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
-
 
84
		}
-
 
85
		else
-
 
86
		{
-
 
87
			if ( strpos( $this->Width, '%' ) === false )
-
 
88
				$WidthCSS = $this->Width . 'px' ;
-
 
89
			else
-
 
90
				$WidthCSS = $this->Width ;
-
 
91
 
-
 
92
			if ( strpos( $this->Height, '%' ) === false )
-
 
93
				$HeightCSS = $this->Height . 'px' ;
-
 
94
			else
-
 
95
				$HeightCSS = $this->Height ;
-
 
96
 
-
 
97
			$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
-
 
98
		}
-
 
99
 
-
 
100
		$Html .= '</div>' ;
-
 
101
		
-
 
102
		return $Html ;
-
 
103
	}
-
 
104
 
-
 
105
	function IsCompatible()
-
 
106
	{
-
 
107
		global $HTTP_USER_AGENT ;
-
 
108
 
-
 
109
		if ( isset( $HTTP_USER_AGENT ) )
-
 
110
			$sAgent = $HTTP_USER_AGENT ;
-
 
111
		else
-
 
112
			$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
-
 
113
 
-
 
114
		if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
-
 
115
		{
-
 
116
			$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
-
 
117
			return ($iVersion >= 5.5) ;
-
 
118
		}
-
 
119
		else if ( strpos($sAgent, 'Gecko/') !== false )
-
 
120
		{
-
 
121
			$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
-
 
122
			return ($iVersion >= 20030210) ;
-
 
123
		}
-
 
124
		else
-
 
125
			return false ;
-
 
126
	}
-
 
127
 
-
 
128
	function GetConfigFieldString()
-
 
129
	{
-
 
130
		$sParams = '' ;
-
 
131
		$bFirst = true ;
-
 
132
 
-
 
133
		foreach ( $this->Config as $sKey => $sValue )
-
 
134
		{
-
 
135
			if ( $bFirst == false )
-
 
136
				$sParams .= '&amp;' ;
-
 
137
			else
-
 
138
				$bFirst = false ;
-
 
139
			
-
 
140
			if ( $sValue === true )
-
 
141
				$sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
-
 
142
			else if ( $sValue === false )
-
 
143
				$sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
-
 
144
			else
-
 
145
				$sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
-
 
146
		}
-
 
147
		
-
 
148
		return $sParams ;
-
 
149
	}
-
 
150
 
-
 
151
	function EncodeConfig( $valueToEncode )
-
 
152
	{
-
 
153
		$chars = array( 
-
 
154
			'&' => '%26', 
-
 
155
			'=' => '%3D', 
-
 
156
			'"' => '%22' ) ;
-
 
157
 
-
 
158
		return strtr( $valueToEncode,  $chars ) ;
-
 
159
	}
-
 
160
}
-
 
161
 
-
 
162
?>
27
 
-
 
28
if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) )
-
 
29
	include_once( 'fckeditor_php4.php' ) ;
-
 
30
else
-
 
31
	include_once( 'fckeditor_php5.php' ) ;