Files
admin
FCKeditor
_samples
editor
_documentation.html
_upgrade.html
_whatsnew.html
fckconfig.js
fckeditor.afp
fckeditor.asp
fckeditor.cfc
fckeditor.cfm
fckeditor.js
fckeditor.lasso
fckeditor.php
fckeditor.pl
fckeditor.py
fckeditor_php4.php
fckeditor_php5.php
fckpackager.xml
fckstyles.xml
fcktemplates.xml
htaccess.txt
license.txt
Uebersicht1
Uebersicht2
bescheinigung
import
livesearch
adm_anleg.php
adm_bearb.php
adminrechte.php
adminrechte_del.php
anmschluss.php
anwesenheit.php
ausg_aush.php
ausgabe.php
aushang.php
bearbeiten.php
bescheinigung_admin.php
cross.jpg
detailansicht.php
doz_anleg.php
doz_bearb.php
doz_del.php
erfassen.php
expo.php
export.php
export_themen.php
hauptframe.htm
hauptframe_jahr.php
index.php
jahrgang.php
kennwortwechsel_admin.php
ldap_search.php
liste.php
livesearch_stud.php
login_doz.php
login_log.php
logout_admin.php
mail.php
mail_doz.php
mail_unangemeldet.php
mail_vert.php
mailadressen.php
mailcompare.php
menuframe.php
menuframe_28.09.2005.php
noteneingabe_admin.php
ok.gif
pass_back.php
registrierung.php
seminarscheine.php
skik_bearbeiten.php
skik_del.php
skik_useronline.php
stud_bearb.php
stud_neubelegen.php
studbeleg.php
suche.php
topframe.htm
ubersicht.php
ubersicht_prio.php
ubersicht_themen.php
unangemeldet.php
doz
html2pdf_v4.03
htmlpurifier-4.10.0
images
prints
prints3
stud
Kennwortwechsel.php
hauptframe.php
htmlpurifier-4.10.0.zip
index.php
index_alt.php
index_db.php
index_frame.htm
index_ldap.php
login.php
logout.php
menuframe.htm
styles_pc.css
testpdf.php
topframe.php
skik/admin/FCKeditor/fckeditor.py
2023-02-27 10:20:09 +01:00

150 lines
3.9 KiB
Python
Executable File

"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2007 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http://www.gnu.org/licenses/gpl.html
- GNU Lesser General Public License Version 2.1 or later (the "LGPL")
http://www.gnu.org/licenses/lgpl.html
- Mozilla Public License Version 1.1 or later (the "MPL")
http://www.mozilla.org/MPL/MPL-1.1.html
== END LICENSE ==
This is the integration file for Python.
"""
import cgi
import os
import string
def escape(text, replace=string.replace):
"""Converts the special characters '<', '>', and '&'.
RFC 1866 specifies that these characters be represented
in HTML as &lt; &gt; and &amp; respectively. In Python
1.5 we use the new string.replace() function for speed.
"""
text = replace(text, '&', '&amp;') # must be done 1st
text = replace(text, '<', '&lt;')
text = replace(text, '>', '&gt;')
text = replace(text, '"', '&quot;')
text = replace(text, "'", '&#39;')
return text
# The FCKeditor class
class FCKeditor(object):
def __init__(self, instanceName):
self.InstanceName = instanceName
self.BasePath = '/fckeditor/'
self.Width = '100%'
self.Height = '200'
self.ToolbarSet = 'Default'
self.Value = '';
self.Config = {}
def Create(self):
return self.CreateHtml()
def CreateHtml(self):
HtmlValue = escape(self.Value)
Html = "<div>"
if (self.IsCompatible()):
File = "fckeditor.html"
Link = "%seditor/%s?InstanceName=%s" % (
self.BasePath,
File,
self.InstanceName
)
if (self.ToolbarSet is not None):
Link += "&amp;ToolBar=%s" % self.ToolbarSet
# Render the linked hidden field
Html += "<input type=\"hidden\" id=\"%s\" name=\"%s\" value=\"%s\" style=\"display:none\" />" % (
self.InstanceName,
self.InstanceName,
HtmlValue
)
# Render the configurations hidden field
Html += "<input type=\"hidden\" id=\"%s___Config\" value=\"%s\" style=\"display:none\" />" % (
self.InstanceName,
self.GetConfigFieldString()
)
# Render the editor iframe
Html += "<iframe id=\"%s\__Frame\" src=\"%s\" width=\"%s\" height=\"%s\" frameborder=\"0\" scrolling=\"no\"></iframe>" % (
self.InstanceName,
Link,
self.Width,
self.Height
)
else:
if (self.Width.find("%%") < 0):
WidthCSS = "%spx" % self.Width
else:
WidthCSS = self.Width
if (self.Height.find("%%") < 0):
HeightCSS = "%spx" % self.Height
else:
HeightCSS = self.Height
Html += "<textarea name=\"%s\" rows=\"4\" cols=\"40\" style=\"width: %s; height: %s;\" wrap=\"virtual\">%s</textarea>" % (
self.InstanceName,
WidthCSS,
HeightCSS,
HtmlValue
)
Html += "</div>"
return Html
def IsCompatible(self):
if (os.environ.has_key("HTTP_USER_AGENT")):
sAgent = os.environ.get("HTTP_USER_AGENT", "")
else:
sAgent = ""
if (sAgent.find("MSIE") >= 0) and (sAgent.find("mac") < 0) and (sAgent.find("Opera") < 0):
i = sAgent.find("MSIE")
iVersion = float(sAgent[i+5:i+5+3])
if (iVersion >= 5.5):
return True
return False
elif (sAgent.find("Gecko/") >= 0):
i = sAgent.find("Gecko/")
iVersion = int(sAgent[i+6:i+6+8])
if (iVersion >= 20030210):
return True
return False
else:
return False
def GetConfigFieldString(self):
sParams = ""
bFirst = True
for sKey in self.Config.keys():
sValue = self.Config[sKey]
if (not bFirst):
sParams += "&amp;"
else:
bFirst = False
if (sValue):
k = escape(sKey)
v = escape(sValue)
if (sValue == "true"):
sParams += "%s=true" % k
elif (sValue == "false"):
sParams += "%s=false" % k
else:
sParams += "%s=%s" % (k, v)
return sParams