<?php
require("session_check.php");
$step=1;
$plugin_name="";
$path=get_args('path');
$next="install_plugin_2.php?path=$path";
$plugin_dir=dir(dirname(__file__)."/../plugins");
chdir(dirname(__file__)."/../plugins");
//根据位置获取插件信息
function getInfo($path)
{
	global $next;
	$pluginxml=dirname(__file__)."/../plugins/$path/plugin.xml";
	if(file_exists($pluginxml))
	{	
		$dom = new DOMDocument();
		$dom->load($pluginxml);
		$plugin=$dom->getElementsByTagName("plugin");
		$infos=$plugin->item(0)->childNodes;
		$plugin_id="";
		$auto_checked="";
		$valid_checked="";
		$inurl='';
		
		foreach($infos as $info)
		{
			if($info->nodeName!="#text")
			{
				$tem=$info->nodeName;
				$$tem=$info->nodeValue;
			}
		}
		//if($autoorder)$auto_checked="checked='checked'";
		//if($valid)$valid_checked="checked='checked'";
		if(!isset($show))$show=0;
		$next.="&type=$show";
		if(isset($sqlpath))
		{
			$next.="&sql=$sqlpath";
		}
		else
		{
			$sqlpath="";
		}
		if(isset($show))
		{
			$show=intval($show);
			if($show==0)$show="Widget插件";
			else if($show==1) $show="APP应用";
			else $show="Widget+APP";
		}
		else
		{
			$show="";
		}
		if(!isset($csspath))$csspath='';
		if(!isset($image))$image='';
		if(isset($title) && isset($author) && isset($version)&&(isset($jspath) || isset($callfunction) || isset($inurl)))
		{
		echo <<<EOD
			<div id="container">
<div id="title">
<ul>
<li id="tag1"><a href="#" onClick="switchTag('tag1','content1',3);this.blur();" class="selectli1"><span class="selectspan1">插件描述</span></a></li>
<li id="tag2"><a href="#" onClick="switchTag('tag2','content2',3);this.blur();"><span>详细说明</span></a></li>
</ul>
</div>
<div id="content" class="content1">
<div id="content1">
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <tr>
        <td width="23%">插件名称：</td>
        <td width="60%">&nbsp;$title</td>
        <td width="80" width="80" rowspan="5"><img  src="../plugins/$path/$image" width="80" height="80"/></td>
      </tr>
      <tr>
        <td>版本号：</td>
        <td>&nbsp;$version</td>
      </tr>
      <tr>
        <td>作者：</td>
        <td>&nbsp;$author</td>
      </tr>
      <tr>
        <td>开发者主页：</td>
        <td>&nbsp;$website</td>
      </tr>
		<tr>
        <td>插件类型：</td>
        <td>&nbsp;$show</td>
      </tr>
      <tr>
        <td colspan="3">插件描述：<br/>$description</td>
      </tr>
    </table>
</div>
<div id="content2" class="hidecontent">
<table  width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="28%">CSS文件</td>
      <td width="72%">&nbsp;$csspath</td>
    </tr>
    <tr>
      <td>JavaScript文件</td>
      <td>&nbsp;$jspath</td>
    </tr>
    <tr>
      <td>JavaScript启动函数</td>
      <td>&nbsp;$callfunction</td>
    </tr>
    <tr>
      <td>入口文件地址</td>
      <td>&nbsp;$inurl</td>
    </tr>
    <tr>
      <td>插件类型</td>
      <td>&nbsp;&nbsp;</td>
    </tr>
    <tr>
      <td>数据数据库文件</td>
      <td>&nbsp;$sqlpath</td>
    </tr>
  </table>
</div>
</div>
</div>
EOD;
		return true;
	}
	else
	{
		echo "插件配制信息不全，不具备安装条件！";
		return false;
	}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function switchTag(tag,content,num){
for(i=1; i <num; i++){
   if("tag"+i==tag){
    document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
    document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
   }else{
    document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
    document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
   }
   if("content"+i==content){
    document.getElementById(content).className="";
   }else{
    document.getElementById("content"+i).className="hidecontent";
   }
   document.getElementById("content").className=content;
}
}
</script>
<link rel="stylesheet" type="text/css" href="css/right.css">
<title></title>
</head>

<body>
<h1>IWebSNS插件安装向导</h1>
<hr />
<?php $flag=getInfo(get_args('path'));
if($flag)
{
?>
	  <script>parent.right.diag_install.URL='<?php echo $next?>';</script>
<?php }?>
</body>
</html>