<?php
class Xheditor{
	private $content='';
	function show($name=null,$content=null){
		$tmp = "<script type=\"text/javascript\" id=\"jquery\"></script>";
		$tmp .= "<script type=\"text/javascript\">if(typeof(jQuery)==\"undefined\"){document.getElementById(\"jquery\").setAttribute(\"src\",\"http://lib.qkweb.net/js/jquery/jquery-1.7.2.min.js\")}</script>";
		$tmp .= "<script type=\"text/javascript\" src=\"/".APP_DIR."plugins/editor/xheditor/xheditor-1.2.1.min.js\"></script>";
		$tmp .= "<script type=\"text/javascript\" src=\"/".APP_DIR."plugins/editor/xheditor/xheditor_lang/zh-cn.js\"></script>";
		$tmp .= "<textarea id=\"editor\" name=\"content\" style=\"width:770px;height:300px\">".($this->content?$this->content:'')."</textarea>";
		$tmp .= "<script type=\"text/javascript\">";
		$tmp .= '$("#editor").xheditor({upImgUrl:"/'.APP_DIR.'plugins/editor/xheditor/upload.php",upImgExt:"jpg,jpeg,gif,png"})';
		$tmp .= "</script>";
		echo $tmp;
	}

	function html($name=null,$content=null){
		if(!$name){$name="content";}
		$tmp = "<script type=\"text/javascript\" id=\"jquery\"></script>";
		$tmp .= "<script type=\"text/javascript\">if(typeof(jQuery)==\"undefined\"){document.getElementById(\"jquery\").setAttribute(\"src\",\"http://lib.qkweb.net/js/jquery/jquery-1.7.2.min.js\")}</script>";
		$tmp .= "<script type=\"text/javascript\" src=\"/".APP_DIR."plugins/editor/xheditor/xheditor-1.2.1.min.js\"></script>";
		$tmp .= "<script type=\"text/javascript\" src=\"/".APP_DIR."plugins/editor/xheditor/xheditor_lang/zh-cn.js\"></script>";
		$tmp .= "<textarea id=\"editor\" name=\"".$name."\" style=\"width:770px;height:300px\">".($this->content?$this->content:'')."</textarea>";
		$tmp .= "<script type=\"text/javascript\">";
		$tmp .= '$("#editor").xheditor({upImgUrl:"/'.APP_DIR.'plugins/editor/xheditor/upload.php",upImgExt:"jpg,jpeg,gif,png"})';
		$tmp .= "</script>";
		return $tmp;
	}

	function setContent($content=""){
		$this->content = $content;
	}

}
?>