/source/Plug-in/fck/fckeditor.afp

http://prosporous.googlecode.com/ · Unknown · 161 lines · 136 code · 25 blank · 0 comment · 0 complexity · 7388816a5df49d54b081cef353fe920d MD5 · raw file

  1. <%
  2. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  3. * Copyright (C) 2003-2007 Frederico Caldeira Knabben
  4. *
  5. * == BEGIN LICENSE ==
  6. *
  7. * Licensed under the terms of any of the following licenses at your
  8. * choice:
  9. *
  10. * - GNU General Public License Version 2 or later (the "GPL")
  11. * http://www.gnu.org/licenses/gpl.html
  12. *
  13. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14. * http://www.gnu.org/licenses/lgpl.html
  15. *
  16. * - Mozilla Public License Version 1.1 or later (the "MPL")
  17. * http://www.mozilla.org/MPL/MPL-1.1.html
  18. *
  19. * == END LICENSE ==
  20. *
  21. * This is the integration file for Active FoxPro Pages.
  22. *
  23. DEFINE CLASS goFckeditor AS CONTAINER OLEPUBLIC
  24. cInstanceName =""
  25. BasePath =""
  26. cWIDTH =""
  27. cHEIGHT =""
  28. ToolbarSet =""
  29. cValue=""
  30. DIMENSION aConfig(10,2)
  31. && -----------------------------------------------------------------------
  32. FUNCTION fckeditor( tcInstanceName )
  33. LOCAL lnLoop,lnLoop2
  34. THIS.cInstanceName = tcInstanceName
  35. THIS.BasePath = '/fckeditor/'
  36. THIS.cWIDTH = '100%'
  37. THIS.cHEIGHT = '200'
  38. THIS.ToolbarSet = 'Default'
  39. THIS.cValue = ''
  40. FOR lnLoop=1 TO 10
  41. FOR lnLoop2=1 TO 2
  42. THIS.aConfig(lnLoop,lnLoop2) = ""
  43. NEXT
  44. NEXT
  45. RETURN
  46. ENDFUNC
  47. && -----------------------------------------------------------------------
  48. FUNCTION CREATE()
  49. ? THIS.CreateHtml()
  50. RETURN
  51. ENDFUNC
  52. && -----------------------------------------------------------------------
  53. FUNCTION CreateHtml()
  54. LOCAL html
  55. LOCAL lcLink
  56. HtmlValue = THIS.cValue && HTMLSPECIALCHARS()
  57. html = [<div>]
  58. IF THIS.IsCompatible()
  59. lcLink = THIS.BasePath+[editor/fckeditor.html?InstanceName=]+THIS.cInstanceName
  60. IF ( !THIS.ToolbarSet == '' )
  61. lcLink = lcLink + [&Toolbar=]+THIS.ToolbarSet
  62. ENDIF
  63. && Render the LINKED HIDDEN FIELD.
  64. html = html + [<input type="hidden" id="]+THIS.cInstanceName +[" name="]+THIS.cInstanceName +[" value="]+HtmlValue+[" style="display:none" />]
  65. && Render the configurations HIDDEN FIELD.
  66. html = html + [<input type="hidden" id="]+THIS.cInstanceName +[___Config" value="]+THIS.GetConfigFieldString() + [" style="display:none" />] +CHR(13)+CHR(10)
  67. && Render the EDITOR IFRAME.
  68. html = html + [<iframe id="]+THIS.cInstanceName +[___Frame" src="Link" width="]+THIS.cWIDTH+[" height="]+THIS.cHEIGHT+[" frameborder="0" scrolling="no"></iframe>]
  69. ELSE
  70. IF ( AT("%", THIS.cWIDTH)=0 )
  71. WidthCSS = THIS.cWIDTH + 'px'
  72. ELSE
  73. WidthCSS = THIS.cWIDTH
  74. ENDIF
  75. IF ( AT("%",THIS.cHEIGHT)=0 )
  76. HeightCSS = THIS.cHEIGHT + 'px'
  77. ELSE
  78. HeightCSS = THIS.cHEIGHT
  79. ENDIF
  80. html = html + [<textarea name="]+THIS.cInstanceName +[" rows="4" cols="40" style="width: ]+WidthCSS+[ height: ]+HeightCSS+[">]+HtmlValue+[</textarea>]
  81. ENDIF
  82. html = html + [</div>]
  83. RETURN (html)
  84. ENDFUNC
  85. && -----------------------------------------------------------------------
  86. FUNCTION IsCompatible()
  87. LOCAL llRetval
  88. LOCAL sAgent
  89. llRetval=.F.
  90. SET POINT TO "."
  91. sAgent = LOWER(ALLTRIM(request.servervariables("HTTP_USER_AGENT")))
  92. IF AT("msie",sAgent) >0 .AND. AT("mac",sAgent)=0 .AND. AT("opera",sAgent)=0
  93. iVersion=VAL(SUBSTR(sAgent,AT("msie",sAgent)+5,3))
  94. llRetval= iVersion > 5.5
  95. ELSE
  96. IF AT("gecko/",sAgent)>0
  97. iVersion=VAL(SUBSTR(sAgent,AT("gecko/",sAgent)+6,8))
  98. llRetval =iVersion > 20030210
  99. ENDIF
  100. ELSE
  101. IF AT("opera/",sAgent)>0
  102. iVersion=VAL(SUBSTR(sAgent,AT("opera/",sAgent)+6,4))
  103. llRetval =iVersion >= 9.5
  104. ENDIF
  105. ELSE
  106. IF AT("applewebkit/",sAgent)>0
  107. iVersion=VAL(SUBSTR(sAgent,AT("applewebkit/",sAgent)+12,3))
  108. llRetval =iVersion >= 522
  109. ENDIF
  110. ENDIF
  111. SET POINT TO
  112. RETURN (llRetval)
  113. ENDFUNC
  114. && -----------------------------------------------------------------------
  115. FUNCTION GetConfigFieldString()
  116. LOCAL sParams
  117. LOCAL bFirst
  118. LOCAL sKey
  119. sParams = ""
  120. bFirst = .T.
  121. FOR lnLoop=1 TO 10 && ALEN(this.aconfig)
  122. IF !EMPTY(THIS.aConfig(lnLoop,1))
  123. IF bFirst = .F.
  124. sParams = sParams + "&"
  125. ELSE
  126. bFirst = .F.
  127. ENDIF
  128. sParams = sParams +THIS.aConfig(lnLoop,1)+[=]+THIS.aConfig(lnLoop,2)
  129. ELSE
  130. EXIT
  131. ENDIF
  132. NEXT
  133. RETURN(sParams)
  134. ENDFUNC
  135. ENDDEFINE
  136. %>