fckeditor.lasso 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. [//lasso
  2. /*
  3. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. * Copyright (C) 2003-2009 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 Lasso.
  23. *
  24. * It defines the FCKeditor class ("custom type" in Lasso terms) that can
  25. * be used to create editor instances in Lasso pages on server side.
  26. */
  27. define_type(
  28. 'editor',
  29. -namespace='fck_',
  30. -description='Creates an instance of FCKEditor.'
  31. );
  32. local(
  33. 'instancename' = 'FCKEditor1',
  34. 'width' = '100%',
  35. 'height' = '200',
  36. 'toolbarset' = 'Default',
  37. 'initialvalue' = string,
  38. 'basepath' = '/fckeditor/',
  39. 'config' = array,
  40. 'checkbrowser' = true,
  41. 'displayerrors' = false
  42. );
  43. define_tag(
  44. 'onCreate',
  45. -required='instancename', -type='string',
  46. -optional='width', -type='string',
  47. -optional='height', -type='string',
  48. -optional='toolbarset', -type='string',
  49. -optional='initialvalue', -type='string',
  50. -optional='basepath', -type='string',
  51. -optional='config', -type='array'
  52. );
  53. self->instancename = #instancename;
  54. local_defined('width') ? self->width = #width;
  55. local_defined('height') ? self->height = #height;
  56. local_defined('toolbarset') ? self->toolbarset = #toolbarset;
  57. local_defined('initialvalue') ? self->initialvalue = #initialvalue;
  58. local_defined('basepath') ? self->basepath = #basepath;
  59. local_defined('config') ? self->config = #config;
  60. /define_tag;
  61. define_tag('create');
  62. if(self->isCompatibleBrowser);
  63. local('out' = '
  64. <input type="hidden" id="' + self->instancename + '" name="' + self->instancename + '" value="' + encode_html(self->initialvalue) + '" style="display:none" />
  65. ' + self->parseConfig + '
  66. <iframe id="' + self->instancename + '___Frame" src="' + self->basepath + 'editor/fckeditor.html?InstanceName=' + self->instancename + '&Toolbar=' + self->toolbarset + '" width="' + self->width + '" height="' + self->height + '" frameborder="0" scrolling="no"></iframe>
  67. ');
  68. else;
  69. local('out' = '
  70. <textarea name="' + self->instancename + '" rows="4" cols="40" style="width: ' + self->width + '; height: ' + self->height + '">' + encode_html(self->initialvalue) + '</textarea>
  71. ');
  72. /if;
  73. return(@#out);
  74. /define_tag;
  75. define_tag('isCompatibleBrowser');
  76. local('result' = false);
  77. if (client_browser->Find("MSIE") && !client_browser->Find("mac") && !client_browser->Find("Opera"));
  78. #result = client_browser->Substring(client_browser->Find("MSIE")+5,3)>=5.5;
  79. /if;
  80. if (client_browser->Find("Gecko/"));
  81. #result = client_browser->Substring(client_browser->Find("Gecko/")+6,8)>=20030210;
  82. /if;
  83. if (client_browser->Find("Opera/"));
  84. #result = client_browser->Substring(client_browser->Find("Opera/")+6,4)>=9.5;
  85. /if;
  86. if (client_browser->Find("AppleWebKit/"));
  87. #result = client_browser->Substring(client_browser->Find("AppleWebKit/")+12,3)>=522;
  88. /if;
  89. return(#result);
  90. /define_tag;
  91. define_tag('parseConfig');
  92. if(self->config->size);
  93. local('out' = '<input type="hidden" id="' + self->instancename + '___Config" value="');
  94. iterate(self->config, local('this'));
  95. loop_count > 1 ? #out += '&amp;';
  96. #out += encode_html(#this->first) + '=' + encode_html(#this->second);
  97. /iterate;
  98. #out += '" style="display:none" />\n';
  99. return(@#out);
  100. /if;
  101. /define_tag;
  102. /define_type;
  103. ]