Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.mainResponder.discuss.getHtmlEditor

on getHtmlEditor (msgText="", pta=nil, wysiwygHeightPixels=300, fieldName="body", formName="editMessageForm") {
	<<Changes:
		<<8/22/03; 12:52:58 PM by JES
			<<Adjusted the size of the editor. It was too small when the browser was not WYSIWYG-capable.
		<<8/14/03; 12:41:14 AM by JES
			<<Added support for Mozilla's rich text editor.
		<<04/28/01; 2:46:27 PM by JES
			<<Return the editor for MSIE 6, as well as MSIE 5.
		<<10/03/00; 10:14:26 PM by JES
			<<No longer necessary to put JavaScript in head portion of page.
		<<10/03/00; 2:08:12 PM by PBS
			<<Support choice of editors -- WYSIWYG, HTML Tags, None.
		<<10/02/00; 6:03:52 PM by JES
			<<Return the WYSIWYG HTML editor instead of the older DHTML editor. Use the editor with MSIE4 as well as MSIE5
		<<4/10/00; 6:26:41 PM by JES
			<<Localized -- gets the editor itself using mainResponder.getString
		<<02/14/00; 9:13:54 AM by PBS
			<<Add the HTML Editor buttons and scripts.
	
	if pta == nil {
		pta = html.getPageTableAddress ()};
	
	try {
		local (adrLanguageTable = mainResponder.localization.getLanguageTableAddress (pta: pta));
		return (html.editor.get (msgText, fieldName, wysiwygHeightPixels/20, formName:formName, adrLanguageTable:adrLanguageTable))}
	else { //html.editor doesn't exist -- use old code
		local (flWysEditor = false, flTagEditor = true);
		local (editingToolName);
		if defined (pta^.editingToolName) {
			editingToolName = pta^.editingToolName;
			if string.lower (pta^.editingToolName) == "wysiwyg" {
				flWysEditor = true;
				flTagEditor = false}};
		
		bundle { //find reasons not to display an editor
			if string.lower (editingToolName) == "none" { //no editor
				return ("")};
			if defined (pta^.responderAttributes.flDiscussHtmlEditor) {
				if not (pta^.responderAttributes.flDiscussHtmlEditor) {
					return ("")}};
			if not defined (pta^.requestHeaders.["User-Agent"]) {
				return ("")};
			local (lowerUserAgent = string.lower (pta^.requestHeaders.["User-Agent"]));
			if not (lowerUserAgent contains "msie 5") { //PBS 10/03/00: msie 5; 04/28/2001 JES: added msie 6
				if not (lowerUserAgent contains "msie 6") {
					return ("")}};
			if not (lowerUserAgent contains "windows") {
				return ("")}};
		
		local (editorObjectName = "ieHtmlEditor"); //default is WYSIWYG editor
		if flTagEditor { //classic source-view editor, raw HTML
			editorObjectName = "htmlEditor"};
		local (adrEditor = @mainResponder.data.[editorObjectName]);
		
		local (s);
		bundle { //get editor for the current language
			if defined (pta^.language) and string.lower (pta^.language == "english") {
				s = string (adrEditor^)}
			else { // try to get an editor in the correct language
				local (languageTableAdr = mainResponder.localization.getLanguageTableAddress (pta: pta));
				if defined (languageTableAdr^.data.[editorObjectName]) {
					s = string (languageTableAdr^.data.[editorObjectName])}
				else {
					s = string (adrEditor^)}}};
		
		bundle { //get JavaScript only if this is the WYSIWYG editor
			if flWysEditor {
				<<if defined (pta^.javaScript) //JES 10/03/00: no longer needed
					<<if typeOf (pta^.javaScript) == addressType
						<<pta^.javaScript = string (pta^.javaScript^)
					<<pta^.javaScript = pta^.javaScript + string (mainResponder.data.ieHtmlEditorScript)
				<<else
					<<pta^.javaScript = string (mainResponder.data.ieHtmlEditorScript)
				
				s = string.replace (s, "[[messageText]]", msgText);
				s = string.replace (s, "[[heightPixels]]", wysiwygHeightPixels)}};
		
		return (s)}}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.