<?php

/*
 *	W-AGORA 4.0
 *	-----------
 *	$Id: fckeditor.php,v 1.2 2006/06/24 23:02:39 mdruilhe Exp $
 *	Usage:	FCKEditor 2.x Wysigyg editor handling (see http://www.fckeditor.net/)
 *	Author:	Marc Druilhe <mdruilhe@w-agora.net>
 *
 */

	define('HTML_EDITOR_DIR', 'FCKEditor');
	define('HTML_EDITOR_URL', 'FCKEditor');


# Disable wysiwyg editor if HTML not allowed or module not installed
# -------------------------------------------------------------------
	if (!file_exists(HTML_EDITOR_DIR."/fckeditor.js") || empty($bn_allow_html) ) {
		$use_html_editor = false;
		return;
	}

# Set the editor language according to the w-agora current settings
# -------------------------------------------------------------------
	if ( isset($lang) && file_exists(HTML_EDITOR_DIR."/editor/lang/$lang.js") ) {
		$editor_lang = $lang;
	} elseif ( isset($default_lang)&& file_exists(HTML_EDITOR_DIR."/editor/lang/$default_lang.js") ) {
		$editor_lang = $default_lang;
	} else {
		$editor_lang = 'fr';
	}

?>
<script type="text/javascript" src="<?php echo HTML_EDITOR_URL?>/fckeditor.js"></script>
<script type="text/javascript">

var _use_html_editor = true;

var oFCKeditor;
/*
// Configuration
editorConfig () {
	FCKConfig.AutoDetectLanguage	= false ;
	FCKConfig.DefaultLanguage		= '<?php echo $editor_lang?>' ;
	FCKConfig.ContentLangDirection	= '<?php echo $bn_html_dir?>' ;
}
*/

window.onload = function() {
	oFCKeditor = new FCKeditor( 'body' );
	oFCKeditor.BasePath	= '<?php echo HTML_EDITOR_URL?>/';
	oFCKeditor.ReplaceTextarea();
	editorConfig();
}

// trigger function called on form submit
// usually : moves the contents from the editor to the textarea form field
function editorSubmit(f) {
}

// set the focus on the editor
function editorFocus(elem) {
	var oEditor = FCKeditorAPI.GetInstance('body') ;
	oEditor.Focus();
}

// copy the contents of text into the element (by name)
function editorQuoteText (elem, text) {
	var oEditor = FCKeditorAPI.GetInstance('body') ;
	text = text.replace(/\n/g, '<br />');
	oEditor.InsertHtml(text);
}

// reset the editor to its initial contents
// usually called by an input type="reset" button in the form
function editorReset (f) {
}

</script>

