source: trunk/expressoMail1_2/inc/fckeditor.php @ 1040

Revision 1040, 4.2 KB checked in by amuller, 15 years ago (diff)

Ticket #559 - Atualização de download de arquivos e sessão

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