<?php
/**
 * @author krku
 */

include_once(dirname(__FILE__) . '/function.formField.php');

//Via PHP
function smarty_function_insertCkEditor($params, &$smarty) {
	$value = "";


	if (isset($params['width'])) {
		$width = $params['width'];
	}

	if (isset($params['height'])) {
		$height = $params['height'];
	}

	if (isset($params['value']) && is_string($params['value'])) {
		$value = $params['value'];
	}
	if (isset($params['name']) && is_string($params['name'])) {
		$name = $params['name'];
	}



	$pathStatic = URL_STATIC_CONTENT;
	//Utils::ArrayDisplay($pathStatic);

	$ckEditor = "
<textarea name=\"".$name."\" id=\"".$name."\" width=\"".$width."\" height=\"".$height."\">
".$value."
</textarea>

<script> 

	var roxyFileman = '".$pathStatic."/../Admin/plugins/ckeditor/plugins/fileman/dev.html';
	
	CKEDITOR.replace( '".$name."',{filebrowserBrowseUrl:roxyFileman,
	filebrowserImageBrowseUrl:roxyFileman+'?type=image',
	removeDialogTabs: 'link:upload;image:upload',
	height: ".$height.",
	width: ".$width.",
	contentsCss: '".$pathStatic."/css/Strona/CKStyle.css',
	allowedContent: true
	});
	
	

</script>

";
	return $ckEditor;
}

////Via Javascript
//function smarty_function_insertFckEditor($params, &$smarty) {
//	$name = 'oFCKeditor' . ucfirst($params['name']);
//
//	$ret = '<script language="javascript" type="text/javascript">' .
//				"var $name = new FCKeditor('$params[name]') ;
//
//				$name.Config['ToolbarStartExpanded'] = false ;
//				$name.BasePath  = 'plugins/fckeditor/';
//				$name.ToolbarSet = '$params[toolbar]' ;";
//	if (isset($params['width'])) {
//		$ret .= "$name.Width = $params[width];";
//	}
//
//	if (isset($params['height'])) {
//		$ret .= "$name.Height = $params[height];";
//	}
//
//	if (isset($params['value']) && is_string($params['value'])) {
//		$ret .= "$name.Value = $params[value];";
//	}
//	else if (Request::Check($params['name'])) {
//		$ret .= "$name.Value = $params[value];";
//	}
//
//	$ret .= "$name.Create() ;";
//
//	$ret .= "</script>";
//	return $ret;
//}
?>
