~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/FCK/fckeditor_php4.php

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

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